mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
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>
This commit is contained in:
@@ -45,8 +45,8 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
qstr name;
|
qstr name;
|
||||||
uint32_t port : 4;
|
uint32_t port : 4; // Allows GPIOA through GPIOP
|
||||||
uint32_t pin : 5; // Some ARM processors use 32 bits/PORT
|
uint32_t pin : 4; // ST MCUs have a maximum of 16 pins per port
|
||||||
uint32_t num_af : 4;
|
uint32_t num_af : 4;
|
||||||
uint32_t adc_channel : 5; // Some ARM processors use 32 bits/PORT
|
uint32_t adc_channel : 5; // Some ARM processors use 32 bits/PORT
|
||||||
uint32_t adc_num : 3; // 1 bit per ADC
|
uint32_t adc_num : 3; // 1 bit per ADC
|
||||||
|
|||||||
Reference in New Issue
Block a user