AnsweredAssumed Answered

Bug: HAL_GPIO_Init -> GPIO_MODE_AF and EXTI_MODE

Question asked by isaev.michael on Jul 28, 2015
Latest reply on Aug 3, 2015 by 68516
Combination of GPIO_MODE_AF and EXTI_MODE is non-working.
In my case that was NSS pin in SPI Slave Mode.

HAL code (stm32fxxx_hal_gpio):

      /*--------------------- GPIO Mode Configuration ------------------------*/
      /* In case of Alternate function mode selection */
      if((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))

and

      /* In case of Output or Alternate function mode selection */
      if((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) ||
         (GPIO_Init->Mode == GPIO_MODE_OUTPUT_OD) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
      {


Solution:

Change code by applying mask:

      /*--------------------- GPIO Mode Configuration ------------------------*/
      /* In case of Alternate function mode selection */
      if((GPIO_Init->Mode & GPIO_MODE) == GPIO_MODE_AF_PP)
      {

and

      /* In case of Output or Alternate function mode selection */
      if ((GPIO_Init->Mode & GPIO_MODE) != GPIO_MODE_INPUT)
      {

Outcomes