Browse Source

stm32/pin: Decrease machine_pin_obj_t.pin width from 5 to 4 bits.

Compiling using arm-none-eabi-gcc 14.1.0 with -O2 will give warnings about
possible overflow indexing extint arrays, such as `pyb_extint_callback`.
This is due to `machine_pin_obj_t.pin` having a bit-width of 5, and so a
possible value up to 31, which is usually larger than
`PYB_EXTI_NUM_VECTORS`.

To fix this, change `machine_pin_obj_t.pin` to a bit-width of 4.  Only 4
bits are needed for ST MCUs, which have up to 16 pins per port.

Signed-off-by: Damien George <damien@micropython.org>
pull/15355/head
Damien George 4 months ago
parent
commit
096adca0c8
  1. 4
      ports/stm32/pin.h

4
ports/stm32/pin.h

@ -45,8 +45,8 @@ typedef struct {
typedef struct {
mp_obj_base_t base;
qstr name;
uint32_t port : 4;
uint32_t pin : 5; // Some ARM processors use 32 bits/PORT
uint32_t port : 4; // Allows GPIOA through GPIOP
uint32_t pin : 4; // ST MCUs have a maximum of 16 pins per port
uint32_t num_af : 4;
uint32_t adc_channel : 5; // Some ARM processors use 32 bits/PORT
uint32_t adc_num : 3; // 1 bit per ADC

Loading…
Cancel
Save