diff options
| author | Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com> | 2022-10-28 19:02:28 +0300 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-10-31 11:42:20 +1100 |
| commit | 5b2929a0e69a4f3667ae9f0dbbfe3677ebc840ad (patch) | |
| tree | 03059d4d4a388b30337556b73cd02ad993b86ba4 | |
| parent | 12f99481518b0ebcb14f00b2323865a845c2a4f1 (diff) | |
esp32/machine_pin: Fix size of machine_pin_irq_handler array.
Set the size of machine_pin_irq_handler array to GPIO_NUM_MAX:
- Min GPIO_NUM_MAX is 22 for IDF_TARGET_ESP32C3.
- Max GPIO_NUM_MAX is 49 for IDF_TARGET_ESP32S3.
The MP_REGISTER_ROOT_POINTER entry must be hard-coded, because the location
that it's evaluated by the compiler does not include the relevant IDF
header to get a definition of GPIO_NUM_MAX.
| -rw-r--r-- | ports/esp32/machine_pin.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ports/esp32/machine_pin.c b/ports/esp32/machine_pin.c index 4f6f948d5..8a892d231 100644 --- a/ports/esp32/machine_pin.c +++ b/ports/esp32/machine_pin.c @@ -64,7 +64,7 @@ typedef struct _machine_pin_irq_obj_t { gpio_num_t id; } machine_pin_irq_obj_t; -STATIC const machine_pin_obj_t machine_pin_obj[] = { +STATIC const machine_pin_obj_t machine_pin_obj[GPIO_NUM_MAX] = { #if CONFIG_IDF_TARGET_ESP32 {{&machine_pin_type}, GPIO_NUM_0}, @@ -225,7 +225,7 @@ STATIC const machine_pin_obj_t machine_pin_obj[] = { }; // forward declaration -STATIC const machine_pin_irq_obj_t machine_pin_irq_object[]; +STATIC const machine_pin_irq_obj_t machine_pin_irq_object[GPIO_NUM_MAX]; void machine_pins_init(void) { static bool did_install = false; @@ -545,7 +545,7 @@ MP_DEFINE_CONST_OBJ_TYPE( STATIC const mp_obj_type_t machine_pin_irq_type; -STATIC const machine_pin_irq_obj_t machine_pin_irq_object[] = { +STATIC const machine_pin_irq_obj_t machine_pin_irq_object[GPIO_NUM_MAX] = { #if CONFIG_IDF_TARGET_ESP32 {{&machine_pin_irq_type}, GPIO_NUM_0}, @@ -732,4 +732,4 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( locals_dict, &machine_pin_irq_locals_dict ); -MP_REGISTER_ROOT_POINTER(mp_obj_t machine_pin_irq_handler[40]); +MP_REGISTER_ROOT_POINTER(mp_obj_t machine_pin_irq_handler[49]); // 49 is the biggest of GPIO_NUM_MAX's |
