8000 Allow RMT pulses_send() to be called without waiting for it be done · pycom/pycom-micropython-sigfox@45b4662 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 45b4662

Browse files
committed
Allow RMT pulses_send() to be called without waiting for it be done
Added the (optional) keyword argument 'wait_tx_done' to the pulses_send() function to allow the caller to decide if it wants to wait for it to be done or not. Also unlock the GIL while waiting for transmissions.
1 parent 8152cdf commit 45b4662

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

esp32/mods/machrmt.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ STATIC mp_obj_t mach_rmt_pulses_send(mp_uint_t n_args, const mp_obj_t *pos_args,
247247
{ MP_QSTR_duration, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
248248
{ MP_QSTR_data, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
249249
{ MP_QSTR_start_level, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
250+
{ MP_QSTR_wait_tx_done, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_obj = mp_const_true} },
250251
};
251252

252253
// parse args
@@ -270,6 +271,7 @@ STATIC mp_obj_t mach_rmt_pulses_send(mp_uint_t n_args, const mp_obj_t *pos_args,
270271
mp_int_t duration = 0;
271272
mp_obj_t* data_ptr = NULL;
272273
mp_obj_t* duration_ptr = NULL;
274+
bool wait_tx_done = args[4].u_bool;
273275

274276
/* Get the "duration" mandatory parameter */
275277
if(MP_OBJ_IS_SMALL_INT(args[1].u_obj) == true) {
@@ -390,8 +392,14 @@ STATIC mp_obj_t mach_rmt_pulses_send(mp_uint_t n_args, const mp_obj_t *pos_args,
390392
}
391393
}
392394

393-
/* Do not return until transmission is done */
394-
esp_err_t retval = rmt_write_items(self->config.channel, items_to_send, items_to_send_count, true);
395+
MP_THREAD_GIL_EXIT();
396+
397+
/* Wait for any asynchronous transmissions to be done */
398+
rmt_wait_tx_done(self->config.channel, portMAX_DELAY);
399+
400+
esp_err_t retval = rmt_write_items(self->config.channel, items_to_send, items_to_send_count, wait_tx_done);
401+
402+
MP_THREAD_GIL_ENTER();
395403

396404
m_free(items_to_send);
397405

0 commit comments

Comments
 (0)
0