cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube, GPIO and GPIO_InitStruct.Alternate initialization

hbarta2
Associate III
Posted on January 23, 2015 at 13:29

I've used STMCube to generate initialization code for a project using the STM32F429I-DISCO board. In MX_GPIO_Init()I find the following code:

/*Configure GPIO pins : PD3 PD6 */
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/*Configure GPIO pin : PD5 */
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

I'm curious about the lack of initialization ofGPIO_InitStruct.Alternate for PD5. I expect that there should be a default value for that or something other thanGPIO_AF14_LTDC which is set when initializing PD3 and PD6. Or is the value forGPIO_AF14_LTDC a 'don't care' when initializing PD5? I looked at the header that definesGPIO_AF14_LTDC and it was not at all obvious what a default value should be if GPIO_InitStruct was not previously initialized. Thanks! #stmcube-gpio
1 REPLY 1
Amel NASRI
ST Employee
Posted on January 23, 2015 at 14:09

PD5 will not be used in alternate function mode, so there is no need to initialize ''Alternate'' member in the structure.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.