summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-01-22 00:02:27 +1100
committerDamien George <damien@micropython.org>2022-01-22 00:11:14 +1100
commit648656dbbd841aae129628487a71037236aac739 (patch)
tree10cc9ff71331fec002da94a4e51cb48c747cedb1
parent357078504d0d2c3a3f06ec4bd69e0ab3bcf9e016 (diff)
esp32/esp32_rmt: Call rmt_driver_install directly if running on core 1.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/esp32/esp32_rmt.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/ports/esp32/esp32_rmt.c b/ports/esp32/esp32_rmt.c
index 639e0467a..ca751d42a 100644
--- a/ports/esp32/esp32_rmt.c
+++ b/ports/esp32/esp32_rmt.c
@@ -60,16 +60,18 @@ typedef struct _esp32_rmt_obj_t {
bool loop_en;
} esp32_rmt_obj_t;
+// Current channel used for machine.bitstream, in the machine_bitstream_high_low_rmt
+// implementation. A value of -1 means do not use RMT.
+int8_t esp32_rmt_bitstream_channel_id = RMT_CHANNEL_MAX - 1;
+
+#if MP_TASK_COREID == 0
+
typedef struct _rmt_install_state_t {
SemaphoreHandle_t handle;
uint8_t channel_id;
esp_err_t ret;
} rmt_install_state_t;
-// Current channel used for machine.bitstream, in the machine_bitstream_high_low_rmt
-// implementation. A value of -1 means do not use RMT.
-int8_t esp32_rmt_bitstream_channel_id = RMT_CHANNEL_MAX - 1;
-
STATIC void rmt_install_task(void *pvParameter) {
rmt_install_state_t *state = pvParameter;
state->ret = rmt_driver_install(state->channel_id, 0, 0);
@@ -92,6 +94,16 @@ esp_err_t rmt_driver_install_core1(uint8_t channel_id) {
return state.ret;
}
+#else
+
+// MicroPython runs on core 1, so we can call the RMT installer directly and its
+// interrupt handler will also run on core 1.
+esp_err_t rmt_driver_install_core1(uint8_t channel_id) {
+ return rmt_driver_install(channel_id, 0, 0);
+}
+
+#endif
+
STATIC mp_obj_t esp32_rmt_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_id, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = -1} },