Skip to content

Commit

Permalink
esp32/esp32_rmt: Call rmt_driver_install directly if running on core 1.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Jan 21, 2022
1 parent 3570785 commit 648656d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ports/esp32/esp32_rmt.c
Expand Up @@ -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);
Expand All @@ -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} },
Expand Down

0 comments on commit 648656d

Please sign in to comment.