1 year, 9 months ago.

GPIO Port to pin association

In stm32f30x_gpio.h it makes reference to GPIO_Pin_X how do these relate to the physical pins on the device

  1. define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */
  2. define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */
  3. define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */
  4. define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */
  5. define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */
  6. define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */
  7. define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */
  8. define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */
  9. define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */
  10. define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */
  11. define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */
  12. define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */
  13. define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */
  14. define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */
  15. define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */
  16. define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */
  17. define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F302R8T6 microcontroller.
Comment on this question

2 Answers

1 year, 9 months ago.

Hi

I couldn't find stm32f30x_gpio.h file...

Jerome

1 year, 9 months ago.

Hello Peter,

Those defines in stm32f3xx_hal_gpio.h are designed to select a particular pin (or all pins) of a given port. For example, after configuring pin #7 of port C (available as physical pin PC_7 at connector CN5 on your NUCLEO-F302R8 board) as DigitalOut you can toggle it also by calling the HAL_GPIO_TogglePin STM HAL function as below:

#include "mbed.h"

DigitalOut  led1(LED1);
DigitalOut  myPin(PC_7);

int main()
{
    while (true)
    {
        led1 = !led1;   // toggle LED1 using mbed library
        HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_7); // toggle PC_7 by calling an STM HAL library function
        wait(0.5);
    }
}

Best regards,

Zoltan


You need to log in to post a question