#include "stm32g4xx.h"
#include "drill_button_target.h"
#include "drill_click.h"
#include <assert.h>
#include <stdio.h>
GPIO_TypeDef a103_gpio;RCC_TypeDef a103_rcc;
int main(void){
 assert(!drill_button_init(0));
 a103_rcc.AHB2ENR=1;a103_gpio.MODER=0xffffffffu;a103_gpio.PUPDR=0xffffffffu;a103_gpio.IDR=1u<<11;
 assert(drill_button_init(0));
 assert(a103_gpio.MODER==(0xffffffffu&~(3u<<22)));
 assert(a103_gpio.PUPDR==(0xffffffffu&~(3u<<22)));
 for(unsigned t=1000;t<=30000;t+=1000)drill_button_poll(t);
 a103_gpio.IDR=0;
 for(unsigned t=31000;t<=60000;t+=1000)drill_button_poll(t);
 a103_gpio.IDR=1u<<11;
 for(unsigned t=61000;t<=550000;t+=1000)drill_button_poll(t);
 assert(drill_debug_button.events==1 && drill_debug_button.last_command==DC_TOGGLE_RUN_REQUEST);
 assert(!(drill_debug_button.epoch&1u) && drill_debug_button.available==1);
 a103_gpio.MODER|=1u<<22;drill_button_poll(551000);
 assert(drill_debug_button.available==0 && !(drill_debug_button.epoch&1u));
 unsigned samples=drill_debug_button.samples;drill_button_poll(552000);assert(drill_debug_button.samples==samples);
 puts("PASS: PA11-only input config, active-low release, snapshot commit, pin ownership loss disables capture");
}
