summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2022-07-01 14:48:59 -0500
committerDamien George <damien@micropython.org>2022-07-18 13:50:34 +1000
commit816e4537f27ce6e1737225dbfaece0ec75150913 (patch)
tree1ade863381aeb422970671085f51fef3107c81bf
parentffa22b8f97dcd4696d1e7628c56f9fe2d93f3049 (diff)
stm32: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register all port-specific root pointers in the stm32 port. Signed-off-by: David Lechner <david@pybricks.com>
-rw-r--r--ports/stm32/extint.c2
-rw-r--r--ports/stm32/machine_i2s.c2
-rw-r--r--ports/stm32/main.c2
-rw-r--r--ports/stm32/mpconfigport.h29
-rw-r--r--ports/stm32/mphalport.c2
-rw-r--r--ports/stm32/pin.c3
-rw-r--r--ports/stm32/pyb_can.c2
-rw-r--r--ports/stm32/timer.c2
-rw-r--r--ports/stm32/uart.c2
-rw-r--r--ports/stm32/usb.c5
-rw-r--r--ports/stm32/usrsw.c2
11 files changed, 24 insertions, 29 deletions
diff --git a/ports/stm32/extint.c b/ports/stm32/extint.c
index fd4dca276..d68275bf1 100644
--- a/ports/stm32/extint.c
+++ b/ports/stm32/extint.c
@@ -720,3 +720,5 @@ void Handle_EXTI_Irq(uint32_t line) {
}
}
}
+
+MP_REGISTER_ROOT_POINTER(mp_obj_t pyb_extint_callback[PYB_EXTI_NUM_VECTORS]);
diff --git a/ports/stm32/machine_i2s.c b/ports/stm32/machine_i2s.c
index a9d0da43d..4f583a53e 100644
--- a/ports/stm32/machine_i2s.c
+++ b/ports/stm32/machine_i2s.c
@@ -1125,4 +1125,6 @@ const mp_obj_type_t machine_i2s_type = {
.locals_dict = (mp_obj_dict_t *)&machine_i2s_locals_dict,
};
+MP_REGISTER_ROOT_POINTER(struct _machine_i2s_obj_t *machine_i2s_obj[MICROPY_HW_MAX_I2S]);
+
#endif // MICROPY_HW_ENABLE_I2S
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 54d9b05be..44732cef9 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -659,3 +659,5 @@ soft_reset_exit:
goto soft_reset;
}
+
+MP_REGISTER_ROOT_POINTER(mp_obj_t pyb_config_main);
diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h
index 83986296c..bb73b8337 100644
--- a/ports/stm32/mpconfigport.h
+++ b/ports/stm32/mpconfigport.h
@@ -243,35 +243,6 @@ extern const struct _mod_network_nic_type_t mod_network_nic_type_cc3k;
#endif
#define MICROPY_PORT_ROOT_POINTERS \
- mp_obj_t pyb_hid_report_desc; \
- \
- mp_obj_t pyb_config_main; \
- \
- mp_obj_t pyb_switch_callback; \
- \
- mp_obj_t pin_class_mapper; \
- mp_obj_t pin_class_map_dict; \
- \
- mp_obj_t pyb_extint_callback[PYB_EXTI_NUM_VECTORS]; \
- \
- /* pointers to all Timer objects (if they have been created) */ \
- struct _pyb_timer_obj_t *pyb_timer_obj_all[MICROPY_HW_MAX_TIMER]; \
- \
- /* stdio is repeated on this UART object if it's not null */ \
- struct _pyb_uart_obj_t *pyb_stdio_uart; \
- \
- /* pointers to all UART objects (if they have been created) */ \
- struct _pyb_uart_obj_t *pyb_uart_obj_all[MICROPY_HW_MAX_UART + MICROPY_HW_MAX_LPUART]; \
- \
- /* pointers to all CAN objects (if they have been created) */ \
- struct _pyb_can_obj_t *pyb_can_obj_all[MICROPY_HW_MAX_CAN]; \
- \
- /* pointers to all I2S objects (if they have been created) */ \
- struct _machine_i2s_obj_t *machine_i2s_obj[MICROPY_HW_MAX_I2S]; \
- \
- /* USB_VCP IRQ callbacks (if they have been set) */ \
- mp_obj_t pyb_usb_vcp_irq[MICROPY_HW_USB_CDC_NUM]; \
- \
/* root pointers defined by a board */ \
MICROPY_BOARD_ROOT_POINTERS \
diff --git a/ports/stm32/mphalport.c b/ports/stm32/mphalport.c
index 477192330..619bde69b 100644
--- a/ports/stm32/mphalport.c
+++ b/ports/stm32/mphalport.c
@@ -177,3 +177,5 @@ void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
}
+
+MP_REGISTER_ROOT_POINTER(struct _pyb_uart_obj_t *pyb_stdio_uart);
diff --git a/ports/stm32/pin.c b/ports/stm32/pin.c
index b490a09b7..af6bafc43 100644
--- a/ports/stm32/pin.c
+++ b/ports/stm32/pin.c
@@ -675,3 +675,6 @@ const mp_obj_type_t pin_af_type = {
.print = pin_af_obj_print,
.locals_dict = (mp_obj_dict_t *)&pin_af_locals_dict,
};
+
+MP_REGISTER_ROOT_POINTER(mp_obj_t pin_class_mapper);
+MP_REGISTER_ROOT_POINTER(mp_obj_t pin_class_map_dict);
diff --git a/ports/stm32/pyb_can.c b/ports/stm32/pyb_can.c
index 3fa0f6bae..ff41de318 100644
--- a/ports/stm32/pyb_can.c
+++ b/ports/stm32/pyb_can.c
@@ -1081,4 +1081,6 @@ const mp_obj_type_t pyb_can_type = {
.locals_dict = (mp_obj_dict_t *)&pyb_can_locals_dict,
};
+MP_REGISTER_ROOT_POINTER(struct _pyb_can_obj_t *pyb_can_obj_all[MICROPY_HW_MAX_CAN]);
+
#endif // MICROPY_HW_ENABLE_CAN
diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c
index 8181885e2..0cef60cb6 100644
--- a/ports/stm32/timer.c
+++ b/ports/stm32/timer.c
@@ -1684,3 +1684,5 @@ void timer_irq_handler(uint tim_id) {
}
}
}
+
+MP_REGISTER_ROOT_POINTER(struct _pyb_timer_obj_t *pyb_timer_obj_all[MICROPY_HW_MAX_TIMER]);
diff --git a/ports/stm32/uart.c b/ports/stm32/uart.c
index 34d8246d5..cea49f4ba 100644
--- a/ports/stm32/uart.c
+++ b/ports/stm32/uart.c
@@ -1202,3 +1202,5 @@ const mp_irq_methods_t uart_irq_methods = {
.trigger = uart_irq_trigger,
.info = uart_irq_info,
};
+
+MP_REGISTER_ROOT_POINTER(struct _pyb_uart_obj_t *pyb_uart_obj_all[MICROPY_HW_MAX_UART + MICROPY_HW_MAX_LPUART]);
diff --git a/ports/stm32/usb.c b/ports/stm32/usb.c
index cf9faed11..2a669b2a2 100644
--- a/ports/stm32/usb.c
+++ b/ports/stm32/usb.c
@@ -1152,4 +1152,9 @@ void USR_KEYBRD_ProcessData(uint8_t pbuf) {
#endif // USE_HOST_MODE
+#if MICROPY_HW_USB_HID
+MP_REGISTER_ROOT_POINTER(mp_obj_t pyb_hid_report_desc);
+#endif
+MP_REGISTER_ROOT_POINTER(mp_obj_t pyb_usb_vcp_irq[MICROPY_HW_USB_CDC_NUM]);
+
#endif // MICROPY_HW_ENABLE_USB
diff --git a/ports/stm32/usrsw.c b/ports/stm32/usrsw.c
index 596efba05..60aae1c88 100644
--- a/ports/stm32/usrsw.c
+++ b/ports/stm32/usrsw.c
@@ -143,4 +143,6 @@ const mp_obj_type_t pyb_switch_type = {
.locals_dict = (mp_obj_dict_t *)&pyb_switch_locals_dict,
};
+MP_REGISTER_ROOT_POINTER(mp_obj_t pyb_switch_callback);
+
#endif // MICROPY_HW_HAS_SWITCH