File tree Expand file tree Collapse file tree 5 files changed +22
-0
lines changed
common-hal/microcontroller Expand file tree Collapse file tree 5 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1111,6 +1111,8 @@ void gc_collect(void) {
1111
1111
// have lost their references in the VM even though they are mounted.
1112
1112
gc_collect_root ((void * * )& MP_STATE_VM (vfs_mount_table ), sizeof (mp_vfs_mount_t ) / sizeof (mp_uint_t ));
1113
1113
1114
+ port_gc_collect ();
1115
+
1114
1116
background_callback_gc_collect ();
1115
1117
1116
1118
#if CIRCUITPY_ALARM
@@ -1143,6 +1145,10 @@ void gc_collect(void) {
1143
1145
gc_collect_end ();
1144
1146
}
1145
1147
1148
+ // Ports may provide an implementation of this function if it is needed
1149
+ MP_WEAK void port_gc_collect () {
1150
+ }
1151
+
1146
1152
void NORETURN nlr_jump_fail (void * val ) {
1147
1153
reset_into_safe_mode (SAFE_MODE_NLR_JUMP_FAIL );
1148
1154
while (true) {
Original file line number Diff line number Diff line change 28
28
#include "shared-bindings/microcontroller/__init__.h"
29
29
#include "shared-bindings/microcontroller/Pin.h"
30
30
31
+ #include "py/gc.h"
32
+
31
33
STATIC bool claimed_pins [IOMUXC_SW_PAD_CTL_PAD_COUNT ];
32
34
STATIC bool never_reset_pins [IOMUXC_SW_PAD_CTL_PAD_COUNT ];
33
35
@@ -147,6 +149,11 @@ typedef struct {
147
149
148
150
volatile static pin_change_interrupt_data pcid [MP_ARRAY_SIZE (s_gpioBases )][32 ];
149
151
152
+ // The 'data' pointers may be to gc objects, they must be kept alive.
153
+ void pin_gc_collect () {
154
+ gc_collect_root ((void * * )& pcid , sizeof (pcid ) / sizeof (void * ));
155
+ }
156
+
150
157
void enable_pin_change_interrupt (const mcu_pin_obj_t * pin , gpio_change_interrupt_t func , void * data ) {
151
158
int instance = GPIO_GetInstance (pin -> gpio );
152
159
volatile pin_change_interrupt_data * pci = & pcid [instance ][pin -> number ];
Original file line number Diff line number Diff line change @@ -48,5 +48,6 @@ extern bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin);
48
48
typedef void (gpio_change_interrupt_t )(void * data );
49
49
void disable_pin_change_interrupt (const mcu_pin_obj_t * pin );
50
50
void enable_pin_change_interrupt (const mcu_pin_obj_t * pin , gpio_change_interrupt_t func , void * data );
51
+ void pin_gc_collect (void );
51
52
52
53
#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H
Original file line number Diff line number Diff line change @@ -555,6 +555,10 @@ void port_idle_until_interrupt(void) {
555
555
common_hal_mcu_enable_interrupts ();
556
556
}
557
557
558
+ void port_gc_collect (void ) {
559
+ pin_gc_collect ();
560
+ }
561
+
558
562
// Catch faults where the memory access violates MPU settings.
559
563
void MemManage_Handler (void );
560
564
__attribute__((used )) void PLACE_IN_ITCM (MemManage_Handler )(void ) {
Original file line number Diff line number Diff line change @@ -128,4 +128,8 @@ void port_post_boot_py(bool heap_valid);
128
128
// A default weak implementation is provided that does nothing.
129
129
void port_boot_info (void );
130
130
131
+ // Some ports want to mark additional pointers as gc roots.
132
+ // A default weak implementation is provided that does nothing.
133
+ void port_gc_collect (void );
134
+
131
135
#endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H
You can’t perform that action at this time.
0 commit comments