FreeRTOS polling button on STM32F11

Hi, I have this initialization for a button ~~~~ /*Configure GPIO pin : B1_Pin */ GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;//GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); ~~~~ Why is the button always read as 1, regardless if the button is pushed or not, has an onboard pull-upresistor if(HAL_GPIO_ReadPin(GPIOx, B1_Pin == 0)){...

FreeRTOS polling button on STM32F11

Hi Lasse, Don’t you have a typo here?
if(HAL_GPIO_ReadPin(GPIOx, B1_Pin == 0)){...
( look at ‘B1_Pin == 0’ which probably evaluates to 0 ) The parameters of HAL_GPIO_ReadPin() are: ~~~~~ GPIOPinState HALGPIOReadPin( GPIOTypeDef* GPIOx, uint16t GPIOPin ); ~~~~~ For example:
if( HAL_GPIO_ReadPin( B1_GPIO_Port, B1_Pin ) == 0 )
{
}
else
{
}
Regards.

FreeRTOS polling button on STM32F11

With respect, this is a FreeRTOS forum, not a general programming forum, and to keep this resource valuable to our users it is important this remains the case. Your question does not appear to be related to FreeRTOS in any way, so in future I would appreciate it if you were to post similar such questions to a more appropriate forum – such as a general programming news group, stack overflow, or in this particular case, the ST forum as you appear to be asking a question about their drivers.

FreeRTOS polling button on STM32F11

Sorry, it was only I typo, didn’t have it in my code 🙁