Skip to content

Commit 8a760b0

Browse files
committed
stm: Pin.c: Compute GPIO_PORT_COUNT instead of specifying manually
1 parent a580f0f commit 8a760b0

File tree

1 file changed

+7
-10
lines changed
  • ports/stm/common-hal/microcontroller

1 file changed

+7
-10
lines changed

ports/stm/common-hal/microcontroller/Pin.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,20 @@ bool neopixel_in_use;
3737
#endif
3838

3939
#if defined(TFBGA216)
40-
#define GPIO_PORT_COUNT 11
41-
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK};
40+
GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK};
4241
#elif defined(LQFP144)
43-
#define GPIO_PORT_COUNT 7
44-
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG};
42+
GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG};
4543
#elif defined(LQFP100_f4) || (LQFP100_x7)
46-
#define GPIO_PORT_COUNT 5
47-
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE};
44+
GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE};
4845
#elif defined(LQFP64)
49-
#define GPIO_PORT_COUNT 4
50-
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC, GPIOD};
46+
GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD};
5147
#elif defined(UFQFPN48)
52-
#define GPIO_PORT_COUNT 3
53-
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC};
48+
GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC};
5449
#endif
5550

5651

52+
#define GPIO_PORT_COUNT (MP_ARRAY_SIZE(ports))
53+
5754
STATIC uint16_t claimed_pins[GPIO_PORT_COUNT];
5855
STATIC uint16_t never_reset_pins[GPIO_PORT_COUNT];
5956

0 commit comments

Comments
 (0)