Skip to content

Commit 801d9a5

Browse files
committed
Fix running the USB task on nRF.
It wasn't being run due to a rework done only on the atmel-samd port. The rework itself isn't needed now that the heap check triggers safe mode instead of throwing a Python exception. So, I've removed the rework.
1 parent 2fbaceb commit 801d9a5

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ bool run_code_py(safe_mode_t safe_mode) {
215215
rgb_status_animation_t animation;
216216
prep_rgb_status_animation(&result, found_main, safe_mode, &animation);
217217
while (true) {
218-
#ifdef CIRCUITPY_SUPERVISOR_BACKGROUND
219-
CIRCUITPY_SUPERVISOR_BACKGROUND
218+
#ifdef MICROPY_VM_HOOK_LOOP
219+
MICROPY_VM_HOOK_LOOP
220220
#endif
221221
if (reload_requested) {
222222
return true;

ports/atmel-samd/background.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ volatile uint64_t last_finished_tick = 0;
3939
bool stack_ok_so_far = true;
4040

4141
void run_background_tasks(void) {
42+
assert_heap_ok();
4243
#if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51)
4344
audio_dma_background();
4445
#endif
@@ -50,16 +51,11 @@ void run_background_tasks(void) {
5051
network_module_background();
5152
#endif
5253
usb_background();
54+
assert_heap_ok();
5355

5456
last_finished_tick = ticks_ms;
5557
}
5658

57-
void run_background_vm_tasks(void) {
58-
assert_heap_ok();
59-
run_background_tasks();
60-
assert_heap_ok();
61-
}
62-
6359
bool background_tasks_ok(void) {
6460
return ticks_ms - last_finished_tick < 1000;
6561
}

ports/atmel-samd/mpconfigport.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,8 @@ extern const struct _mp_obj_module_t wiznet_module;
451451
NETWORK_ROOT_POINTERS \
452452

453453
void run_background_tasks(void);
454-
void run_background_vm_tasks(void);
455-
#define MICROPY_VM_HOOK_LOOP run_background_vm_tasks();
456-
#define MICROPY_VM_HOOK_RETURN run_background_vm_tasks();
457-
#define CIRCUITPY_SUPERVISOR_BACKGROUND run_background_tasks();
454+
#define MICROPY_VM_HOOK_LOOP run_background_tasks();
455+
#define MICROPY_VM_HOOK_RETURN run_background_tasks();
458456

459457
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
460458
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"

ports/nrf/background.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
#include "supervisor/usb.h"
2929
#endif
3030

31+
#include "supervisor/shared/stack.h"
32+
3133
void run_background_tasks(void) {
3234
#ifdef NRF52840
3335
usb_background();
3436
#endif
37+
assert_heap_ok();
3538
}

0 commit comments

Comments
 (0)