diff options
| author | Jeff Epler <jepler@gmail.com> | 2021-01-09 13:59:54 -0600 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2021-01-09 14:02:47 -0600 |
| commit | e20c65d8f044cb9522cd1a7f4a3030efefa77cbb (patch) | |
| tree | 369c1a0bffa199d715c560a5c9ec42ed814d50d5 /supervisor | |
| parent | 4735cf4747764f0694e1285085e99f06a7a11a81 (diff) | |
background tasks: Add, use port_wake_main_task
Some ports need an extra operation to ensure that the main task is
awoken so that a queued background task will execute during an ongoing
light sleep.
This removes the need to enable supervisor ticks while I2SOut is operating.
Closes: #3952
Diffstat (limited to 'supervisor')
| -rw-r--r-- | supervisor/port.h | 4 | ||||
| -rw-r--r-- | supervisor/shared/background_callback.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/supervisor/port.h b/supervisor/port.h index 862400986..812cf715b 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -99,4 +99,8 @@ void port_background_task(void); void port_start_background_task(void); void port_finish_background_task(void); +// Some ports need special handling to wake the main task from an interrupt +// context or other task. The port must implement the necessary code in this +// function. A default weak implementation is provided that does nothing. +void port_wake_main_task(void); #endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c index ef686cbab..288c9a4df 100644 --- a/supervisor/shared/background_callback.c +++ b/supervisor/shared/background_callback.c @@ -38,6 +38,8 @@ STATIC volatile background_callback_t *callback_head, *callback_tail; #define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts()) #define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts()) +MP_WEAK void port_wake_main_task(void) {} + void background_callback_add_core(background_callback_t *cb) { CALLBACK_CRITICAL_BEGIN; if (cb->prev || callback_head == cb) { @@ -55,6 +57,8 @@ void background_callback_add_core(background_callback_t *cb) { } callback_tail = cb; CALLBACK_CRITICAL_END; + + port_wake_main_task(); } void background_callback_add(background_callback_t *cb, background_callback_fun fun, void *data) { |
