summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32s2/common-hal/audiobusio/I2SOut.c4
-rw-r--r--ports/esp32s2/supervisor/port.c12
-rw-r--r--supervisor/port.h4
-rw-r--r--supervisor/shared/background_callback.c4
4 files changed, 19 insertions, 5 deletions
diff --git a/ports/esp32s2/common-hal/audiobusio/I2SOut.c b/ports/esp32s2/common-hal/audiobusio/I2SOut.c
index ee16c6ca8..86322be86 100644
--- a/ports/esp32s2/common-hal/audiobusio/I2SOut.c
+++ b/ports/esp32s2/common-hal/audiobusio/I2SOut.c
@@ -63,8 +63,6 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self,
self->bit_clock = bit_clock;
self->word_select = word_select;
self->data = data;
-
- supervisor_enable_tick();
}
bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t* self) {
@@ -95,8 +93,6 @@ void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) {
port_i2s_reset_instance(self->peripheral.instance);
}
self->peripheral.instance = -1;
-
- supervisor_disable_tick();
}
void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c
index a5215fdef..6491e7430 100644
--- a/ports/esp32s2/supervisor/port.c
+++ b/ports/esp32s2/supervisor/port.c
@@ -111,6 +111,12 @@ safe_mode_t port_init(void) {
heap = NULL;
never_reset_module_internal_pins();
+ #if defined(DEBUG)
+ // debug UART
+ common_hal_never_reset_pin(&pin_GPIO43);
+ common_hal_never_reset_pin(&pin_GPIO44);
+ #endif
+
#if defined(DEBUG) || defined(ENABLE_JTAG)
// JTAG
common_hal_never_reset_pin(&pin_GPIO39);
@@ -291,10 +297,14 @@ void port_disable_tick(void) {
esp_timer_stop(_tick_timer);
}
-void sleep_timer_cb(void* arg) {
+void port_wake_main_task() {
xTaskNotifyGive(circuitpython_task);
}
+void sleep_timer_cb(void* arg) {
+ port_wake_main_task();
+}
+
void port_interrupt_after_ticks(uint32_t ticks) {
uint64_t timeout_us = ticks * 1000000ull / 1024;
if (esp_timer_start_once(_sleep_timer, timeout_us) != ESP_OK) {
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) {