AnsweredAssumed Answered

HAL gpio libary code bug

Question asked by sulik.daniel on Sep 4, 2015
Latest reply on Sep 17, 2015 by John F.
This problem has been reported in the following link.
https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fbug%20in%20HAL%20library%20stm32l1xx_hal_gpio_ex%2eh&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=74

Apparently none at ST really cares!!! stm32l1xx_hal_gpio_ex.h incorrectly maps ports F, G, H when using EXTI capability. The bug is in  inSTM32Cube_FW_L1_V1.0.0The and STM32Cube_FW_L1_V1.3.0 library code.

The file defines the following
#if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE)
#define GET_GPIO_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
                                   ((__GPIOx__) == (GPIOB))? 1U :\
                                   ((__GPIOx__) == (GPIOC))? 2U :\
                                   ((__GPIOx__) == (GPIOD))? 3U :\
                                   ((__GPIOx__) == (GPIOE))? 4U :\
                                   ((__GPIOx__) == (GPIOF))? 5U :\
                                   ((__GPIOx__) == (GPIOG))? 6U :\
                                   ((__GPIOx__) == (GPIOH))? 7U : 8U)
#endif 

It should be as follows:
#if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE)
#define GET_GPIO_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
                                   ((__GPIOx__) == (GPIOB))? 1U :\
                                   ((__GPIOx__) == (GPIOC))? 2U :\
                                   ((__GPIOx__) == (GPIOD))? 3U :\
                                   ((__GPIOx__) == (GPIOE))? 4U :\
                                   ((__GPIOx__) == (GPIOF))? 6U :\
                                   ((__GPIOx__) == (GPIOG))? 7U :\
                                   ((__GPIOx__) == (GPIOH))? 5U : 8U)

Regards
Daniel

Outcomes