From 816e4537f27ce6e1737225dbfaece0ec75150913 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 1 Jul 2022 14:48:59 -0500 Subject: [PATCH] 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 --- ports/stm32/extint.c | 2 ++ ports/stm32/machine_i2s.c | 2 ++ ports/stm32/main.c | 2 ++ ports/stm32/mpconfigport.h | 29 ----------------------------- ports/stm32/mphalport.c | 2 ++ ports/stm32/pin.c | 3 +++ ports/stm32/pyb_can.c | 2 ++ ports/stm32/timer.c | 2 ++ ports/stm32/uart.c | 2 ++ ports/stm32/usb.c | 5 +++++ ports/stm32/usrsw.c | 2 ++ 11 files changed, 24 insertions(+), 29 deletions(-) diff --git a/ports/stm32/extint.c b/ports/stm32/extint.c index fd4dca276b..d68275bf19 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 a9d0da43d4..4f583a53e8 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 54d9b05be1..44732cef9e 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 83986296c9..bb73b83371 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 477192330b..619bde69bf 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 b490a09b7f..af6bafc43f 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 3fa0f6baea..ff41de3186 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 8181885e2e..0cef60cb62 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 34d8246d5f..cea49f4ba1 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 cf9faed112..2a669b2a28 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 596efba053..60aae1c883 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