Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 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
- define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */
- define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */
- define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */
- define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */
- define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */
- define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */
- define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */
- define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */
- define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */
- define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */
- define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */
- define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */
- define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */
- define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */
- define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */
- define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */
- define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */
Question relating to:
2 Answers
7 years, 8 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