CMSIS-Driver_STM32  
CMSIS Drivers for STMicroelectronics STM32 Series devices
 
Loading...
Searching...
No Matches
GPIO

Revision History

  • Version 1.0
    • Initial release

Requirements

This driver requires the STM32 device specific HAL and STM32CubeMX (CubeMX) initialization code generator. The driver instance is mapped to hardware as shown in the table below:

CMSIS Driver Instance STM32 Hardware Resource
Driver_GPIO0 PORTA .. PORTZ

Pin mapping

Pin Id STM32 Hardware Resource
0 .. 15 PORTA 0..15
16 .. 31 PORTB 0..15
32 .. 47 PORTC 0..15
48 .. 63 PORTD 0..15
64 .. 79 PORTE 0..15
80 .. 95 PORTF 0..15
96 .. 111 PORTG 0..15
112 .. 127 PORTH 0..15
128 .. 143 PORTI 0..15
144 .. 159 PORTJ 0..15
160 .. 175 PORTK 0..15
176 .. 191 PORTZ 0..15

Deviations

This driver has the following deviations from the CMSIS-Driver specification:

Conceptual deviations:

  • CubeMX generated initialization code (function MX_GPIO_Init) already configures the peripheral. Power, clocks, pins, and interrupts are enabled after execution of initialization that executes in main.c.

CubeMX Configuration

Important

Pins requiring edge detection must be configured as such in CubeMX.

This driver requires the following configuration in CubeMX:

  • pins used for edge detection:
    • pin function selected as GPIO_EXTIn.
    • for GPIO mode selected External Interrupt Mode any edge trigger detection (Rising or Falling or Rising/Falling).
    • for GPIO Pull-up/Pull-down selected No pull-up and no pull-down.
  • pins not used for edge detection:
    • pin function selected as GPIO_Input.
    • for GPIO mode selected Input mode.
    • for GPIO Pull-up/Pull-down selected No pull-up and no pull-down.
  • interrupts: enabled appropriate EXTI line interrupt and IRQ handlers that Call HAL handlers.

Notes

  • configuration information in the file MX_Device.h file is based on CubeMX configuration.
  • due to hardware limitations only one pin at the same port position can be configured with edge detection functionality (for example, for pins PC5 and PG5 only one can be selected for edge detection at one point in time).

Example

Pinout & Configuration tab

  1. In the Pinout view window click on a pin and select it's functionality:
    Pin Functionality
    PG5 GPIO_EXTI5

  2. Under Categories: System Core select GPIO:

    PG5 Configuration:

    • GPIO Settings:
      Pin Name Signal on Pin GPIO output.. GPIO mode GPIO Pull-up/Pull.. User Label
      PG5 n/a n/a External Interrupt Mode with Rising edge.. No pull-up and no.. .

  3. Under Categories: System Core select NVIC:

    Configuration:

    • NVIC:
      NVIC Interrupt Table Enabled Preemption Priority Sub Priority
      EXTI line[9:5] interrupts checked 0 0

    • Code generation:
      Enabled interrupt table Select for.. Generate Enable in.. Generate IRQ h.. Call HAL handler
      EXTI line[9:5] interrupts unchecked checked checked checked