diff --git a/ports/nrf/boards/microbit/modules/microbitdisplay.c b/ports/nrf/boards/microbit/modules/microbitdisplay.c index a0508886d7..b35703ad6f 100644 --- a/ports/nrf/boards/microbit/modules/microbitdisplay.c +++ b/ports/nrf/boards/microbit/modules/microbitdisplay.c @@ -574,3 +574,5 @@ void microbit_display_init(void) { nrf_gpio_cfg_output(i); } } + +MP_REGISTER_ROOT_POINTER(void *async_data[2]); diff --git a/ports/nrf/drivers/softpwm.c b/ports/nrf/drivers/softpwm.c index 517880c8c9..6acdf7aa76 100644 --- a/ports/nrf/drivers/softpwm.c +++ b/ports/nrf/drivers/softpwm.c @@ -255,4 +255,7 @@ void pwm_release(int32_t pin) { nrf_gpio_pin_clear(pin); } +MP_REGISTER_ROOT_POINTER(const struct _pwm_events *pwm_active_events); +MP_REGISTER_ROOT_POINTER(const struct _pwm_events *pwm_pending_events); + #endif // MICROPY_PY_MACHINE_SOFT_PWM diff --git a/ports/nrf/modules/machine/pin.c b/ports/nrf/modules/machine/pin.c index 170caf6dde..3a45c22d18 100644 --- a/ports/nrf/modules/machine/pin.c +++ b/ports/nrf/modules/machine/pin.c @@ -37,6 +37,12 @@ #include "nrf_gpio.h" #include "nrfx_gpiote.h" +#if defined(NRF52840_XXAA) +#define NUM_OF_PINS 48 +#else +#define NUM_OF_PINS 32 +#endif + extern const pin_obj_t machine_board_pin_obj[]; extern const uint8_t machine_pin_num_of_board_pins; @@ -671,3 +677,7 @@ 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); +MP_REGISTER_ROOT_POINTER(mp_obj_t pin_irq_handlers[NUM_OF_PINS]); diff --git a/ports/nrf/modules/music/modmusic.c b/ports/nrf/modules/music/modmusic.c index a950b03920..a0ae7f7c8e 100644 --- a/ports/nrf/modules/music/modmusic.c +++ b/ports/nrf/modules/music/modmusic.c @@ -70,7 +70,7 @@ enum { ASYNC_MUSIC_STATE_ARTICULATE, }; -#define music_data MP_STATE_PORT(music_data) +#define music_data MP_STATE_PORT(modmusic_music_data) extern volatile uint32_t ticks; @@ -510,5 +510,6 @@ const mp_obj_module_t music_module = { }; MP_REGISTER_MODULE(MP_QSTR_music, music_module); +MP_REGISTER_ROOT_POINTER(struct _music_data_t *modmusic_music_data); #endif // MICROPY_PY_MUSIC diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index fcbe71c5a0..b3a95614a4 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -310,41 +310,6 @@ typedef long mp_off_t; #define MP_STATE_PORT MP_STATE_VM -#if MICROPY_PY_MUSIC -#define ROOT_POINTERS_MUSIC \ - struct _music_data_t *music_data; -#else -#define ROOT_POINTERS_MUSIC -#endif - -#if MICROPY_PY_MACHINE_SOFT_PWM -#define ROOT_POINTERS_SOFTPWM \ - const struct _pwm_events *pwm_active_events; \ - const struct _pwm_events *pwm_pending_events; -#else -#define ROOT_POINTERS_SOFTPWM -#endif - -#if defined(NRF52840_XXAA) -#define NUM_OF_PINS 48 -#else -#define NUM_OF_PINS 32 -#endif - -#define MICROPY_PORT_ROOT_POINTERS \ - mp_obj_t pin_class_mapper; \ - mp_obj_t pin_class_map_dict; \ - mp_obj_t pin_irq_handlers[NUM_OF_PINS]; \ - \ - /* stdio is repeated on this UART object if it's not null */ \ - struct _machine_hard_uart_obj_t *board_stdio_uart; \ - \ - ROOT_POINTERS_MUSIC \ - ROOT_POINTERS_SOFTPWM \ - \ - /* micro:bit root pointers */ \ - void *async_data[2]; \ - #if MICROPY_HW_USB_CDC #define MICROPY_HW_USBDEV_TASK_HOOK extern void tud_task(void); tud_task(); #else diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index 1b31ad5acc..9405cb2e3a 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -374,3 +374,5 @@ const char *nrfx_error_code_lookup(uint32_t err_code) { } #endif // NRFX_LOG_ENABLED + +MP_REGISTER_ROOT_POINTER(struct _machine_hard_uart_obj_t *board_stdio_uart);