1 #pragma once
2 
3 /* helper defines for STM32 platforms */
4 
5 /* flag to gpio_configure */
6 #define GPIO_STM32_AF (0x1 << 16)
7 #define GPIO_STM32_OD (0x2 << 16)
8 #define GPIO_STM32_AFn(n) ((n) << 24)
9 
10 /* gpio port/pin is packed into a single unsigned int in 16x:8port:8pin format */
11 #define GPIO(port, pin) ((unsigned int)(((port) << 8) | (pin)))
12 
13 #define GPIO_PORT(gpio) (((gpio) >> 8) & 0xff)
14 #define GPIO_PIN(gpio) ((gpio) & 0xff)
15 #define GPIO_AFNUM(gpio) (((gpio) >> 24) & 0xf)
16 
17 #define GPIO_PORT_A 0
18 #define GPIO_PORT_B 1
19 #define GPIO_PORT_C 2
20 #define GPIO_PORT_D 3
21 #define GPIO_PORT_E 4
22 #define GPIO_PORT_F 5
23 #define GPIO_PORT_G 6
24 #define GPIO_PORT_H 7
25 #define GPIO_PORT_I 8
26 
27