uint32_t Buttons_GetState (void) explanation?
Hi All,
Just saw the BSP for buttons on Keil, came across this, can anyone explain how this actually works when one presses the button.
Apparently if one was supposed to press button say at pin 13 in this case, GPIOC->IDR 13th bit would be set to 1 and in this case wouldn't the if condition become false? If it is false then return value of (val) = 0 ?
&sharpdefine USER 1
uint32_t Buttons_GetState (void)
{
uint32_t val = 0;
if ((GPIOC->IDR & (1ul << 13)) == 0)
{
/* USER button */ val |= USER; }return (val);
}#stm32f401re #button #bsp