Can we test if GPIO PC3 is present on STM32F412CE with HAL_Driver Library ?
Hi,
I've two kind of STM32CubeMX project : one for a STM32F401RE MCU and one for STM32F412CE. The fact is there is no, for example, PC3 pin on STM32F412CE MCU unlike on STM32F401RE MCU. (but STM32F412CE MCU has got a PC15 pin)
it looks like that there is no macro that takes into account that PC3 is not present on STM32F412CE.
Here is some code to illustrate my question :
void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
/* Check the parameters */
assert_param(IS_GPIO_PIN(GPIO_Pin)); // 1 --> See comments below
assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); // 2 --> See comments below
// do some stuff (here it's the core of HAL_GPIO_TogglePin)
if ((GPIOx->ODR & GPIO_Pin) == GPIO_Pin)
{
GPIOx->BSRR = (uint32_t)GPIO_Pin << GPIO_NUMBER;
}
else
{
GPIOx->BSRR = GPIO_Pin;
}
}1 :
IS_GPIO_PIN should be ok because GPIO_PIN_MASK == 0x0000FFFFU so
(((((uint32_t)PIN) & GPIO_PIN_MASK ) != 0x00U) && ((((uint32_t)PIN) & ~GPIO_PIN_MASK) == 0x00U))returns true value.
2 : Should be ok because PORT C is defined in stm32f4xx_hal_gpio_ex.h
#if defined(STM32F412Cx)
#define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\
((__GPIOx__) == (GPIOB))? 1U :\
((__GPIOx__) == (GPIOC))? 2U : 7U)
#endif /* STM32F412Cx */Conclusion :
It seems that i can't catch some particular cases, for example when not all pins are present on MCU for one port.
