' Project name: ' Button_Test (Sample usage of Button() function) [...]
program Button_Test dim oldstate as byte main: GPIO_Digital_Input(@GPIOA_BASE, _GPIO_PINMASK_0) ' Set PA0 as digital input GPIO_Digital_Output(@GPIOD_BASE, _GPIO_PINMASK_ALL) ' Set PORTD as digital output oldstate = 0
while TRUE if (Button(GPIOA_IDR, 0, 1, 1) <> 0) then ' detect logical one on PA0 pin oldstate = 1 ' update flag end if if (oldstate and Button(GPIOA_IDR, 0, 1, 0)) then ' detect one-to-zero transition on PA0 pin GPIOD_ODR = not GPIOD_ODR ' invert PORTD value oldstate = 0 ' update flag end if wend ' endless loop end.