Skip to content

Commit 7d0cda2

Browse files
committed
gc all pointers in hid_devices properly
1 parent 9a7a2bb commit 7d0cda2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

shared-module/usb_hid/__init__.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,13 @@ void usb_hid_save_report_descriptor(uint8_t *report_descriptor_space, size_t rep
257257
void usb_hid_gc_collect(void) {
258258
gc_collect_ptr(hid_devices_tuple);
259259

260-
// Mark any heap pointers in the static device list as in use.
260+
// Mark possible heap pointers in the static device list as in use.
261261
for (mp_int_t i = 0; i < hid_devices_num; i++) {
262-
gc_collect_ptr(&hid_devices[i]);
262+
// Cast away the const for .report_descriptor. It could be in flash or on the heap.
263+
// The const is necessary to have the bytes be placed only in flash.
264+
gc_collect_ptr((void *)hid_devices[i].report_descriptor);
265+
gc_collect_ptr(hid_devices[i].in_report_buffer);
266+
gc_collect_ptr(hid_devices[i].out_report_buffer);
263267
}
264268
}
265269

0 commit comments

Comments
 (0)