Commit 1743a7d7 authored by iabdalkader's avatar iabdalkader Committed by Damien George

extmod/modopenamp: Use mp_event_* functions for poll/wait.

These are the new helper functions to use for polling/waiting.
Signed-off-by: default avatariabdalkader <i.abdalkader@gmail.com>
parent 9a48ce30
...@@ -192,13 +192,13 @@ static mp_obj_t endpoint_send(uint n_args, const mp_obj_t *pos_args, mp_map_t *k ...@@ -192,13 +192,13 @@ static mp_obj_t endpoint_send(uint n_args, const mp_obj_t *pos_args, mp_map_t *k
for (mp_uint_t start = mp_hal_ticks_ms(); ;) { for (mp_uint_t start = mp_hal_ticks_ms(); ;) {
bytes = rpmsg_send_offchannel_raw(&self->ep, src, dest, rbuf.buf, rbuf.len, false); bytes = rpmsg_send_offchannel_raw(&self->ep, src, dest, rbuf.buf, rbuf.len, false);
if (bytes > 0 || timeout == 0) { if (bytes > 0 || timeout == 0) {
MICROPY_EVENT_POLL_HOOK mp_event_handle_nowait();
break; break;
} }
if (timeout > 0 && (mp_hal_ticks_ms() - start > timeout)) { if (timeout > 0 && (mp_hal_ticks_ms() - start > timeout)) {
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("timeout waiting for a free buffer")); mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("timeout waiting for a free buffer"));
} }
MICROPY_EVENT_POLL_HOOK mp_event_wait_ms(1);
} }
return mp_obj_new_int(bytes); return mp_obj_new_int(bytes);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment