diff options
| author | Damien George <damien@micropython.org> | 2024-06-27 11:19:16 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-06-27 12:00:20 +1000 |
| commit | 096adca0c88cd779b3e5e391e42db1d46f87bba1 (patch) | |
| tree | cd0a62c79ecc722bcc202cecbbb9142be82f66c3 | |
| parent | 74f52374e49e3b2370c5fec0e9cfbadc7ec8121e (diff) | |
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>
| -rw-r--r-- | ports/stm32/pin.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ports/stm32/pin.h b/ports/stm32/pin.h index 04479bd04..33f34ebcc 100644 --- a/ports/stm32/pin.h +++ b/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 |
