esp32/esp32_rmt: Call rmt_driver_install directly if running on core 1.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-01-22 00:02:27 +11:00
parent 357078504d
commit 648656dbbd
1 changed files with 16 additions and 4 deletions

View File

@ -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} },