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.
This commit is contained in:
Ihor Nehrutsa 2022-10-28 19:02:28 +03:00 committed by Damien George
parent 12f9948151
commit 5b2929a0e6
1 changed files with 4 additions and 4 deletions

View File

@ -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