2015-04-20 10:36 AM
I'm migrating from PIC32s, so bear with me please. I'm trying to get up to speed on the STM32 using the Cube examples in EWARM. I'll try to keep this simple (I apologize, I don't know the syntax for code tags in this forum). When I use the following defines:
#define LCD_GPIO GPIOA#define LCD_RS GPIO_Pin_0#define LCD_RW GPIO_Pin_1The following code compiles fine: GPIO_InitStruct.Pin = (GPIO_PIN_0 | GPIO_PIN_1); GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(LCD_GPIO, &GPIO_InitStruct);But if I try to substitute the GPIO pin names with the more intuitive names by # defining them, I get an error: GPIO_InitStruct.Pin = (LCD_RS | LCD_RW); GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(LCD_GPIO, &GPIO_InitStruct); The error is: ''GPIO_PIN_0 is undefined''. Even more confusing is that it is apparently accepting the #define of ''LCD_GPIO'', but it is not seeing the define of the individual pins. Any thoughts would be greatly appreciated. Thanks.2015-04-20 11:32 AM
Case sensitive?
#define LCD_RS GPIO_Pin_0 // Looks like SPL syntax#define LCD_RW GPIO_Pin_1GPIO_InitStruct.Pin = (LCD_RS | LCD_RW);vsGPIO_InitStruct.Pin = (GPIO_PIN_0 | GPIO_PIN_1); // HAL/CubeFormat code block is the ''Paintbrush [<>]'' icon.2015-04-20 01:01 PM
Clive,
Wow. Ok. You have no idea how much time I have wasted on this, and it was that. Sorry for wasting your time. Thanks a bunch!Joe2015-04-20 01:14 PM
No problem, we've all had those days when we stare into the cupboard looking for the thing that's right in front of us.