Merge pull request #1385 from tannewt/fix_background_task

Fix running the USB task on nRF.
This commit is contained in:
Dan Halbert 2018-12-07 22:01:50 -05:00 committed by GitHub
commit 2a5891809a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 12 deletions

4
main.c
View File

@ -215,8 +215,8 @@ bool run_code_py(safe_mode_t safe_mode) {
rgb_status_animation_t animation; rgb_status_animation_t animation;
prep_rgb_status_animation(&result, found_main, safe_mode, &animation); prep_rgb_status_animation(&result, found_main, safe_mode, &animation);
while (true) { while (true) {
#ifdef CIRCUITPY_SUPERVISOR_BACKGROUND #ifdef MICROPY_VM_HOOK_LOOP
CIRCUITPY_SUPERVISOR_BACKGROUND MICROPY_VM_HOOK_LOOP
#endif #endif
if (reload_requested) { if (reload_requested) {
return true; return true;

View File

@ -39,6 +39,7 @@ volatile uint64_t last_finished_tick = 0;
bool stack_ok_so_far = true; bool stack_ok_so_far = true;
void run_background_tasks(void) { void run_background_tasks(void) {
assert_heap_ok();
#if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51) #if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51)
audio_dma_background(); audio_dma_background();
#endif #endif
@ -50,16 +51,11 @@ void run_background_tasks(void) {
network_module_background(); network_module_background();
#endif #endif
usb_background(); usb_background();
assert_heap_ok();
last_finished_tick = ticks_ms; last_finished_tick = ticks_ms;
} }
void run_background_vm_tasks(void) {
assert_heap_ok();
run_background_tasks();
assert_heap_ok();
}
bool background_tasks_ok(void) { bool background_tasks_ok(void) {
return ticks_ms - last_finished_tick < 1000; return ticks_ms - last_finished_tick < 1000;
} }

View File

@ -451,10 +451,8 @@ extern const struct _mp_obj_module_t wiznet_module;
NETWORK_ROOT_POINTERS \ NETWORK_ROOT_POINTERS \
void run_background_tasks(void); void run_background_tasks(void);
void run_background_vm_tasks(void); #define MICROPY_VM_HOOK_LOOP run_background_tasks();
#define MICROPY_VM_HOOK_LOOP run_background_vm_tasks(); #define MICROPY_VM_HOOK_RETURN run_background_tasks();
#define MICROPY_VM_HOOK_RETURN run_background_vm_tasks();
#define CIRCUITPY_SUPERVISOR_BACKGROUND run_background_tasks();
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_AUTORELOAD_DELAY_MS 500
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"

View File

@ -28,8 +28,11 @@
#include "supervisor/usb.h" #include "supervisor/usb.h"
#endif #endif
#include "supervisor/shared/stack.h"
void run_background_tasks(void) { void run_background_tasks(void) {
#ifdef NRF52840 #ifdef NRF52840
usb_background(); usb_background();
#endif #endif
assert_heap_ok();
} }