Skip to content
Snippets Groups Projects
Commit 19b671c5 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

stmhal/moduselect: Use mp_hal_ticks_ms().

parent f4decdc4
No related branches found
No related tags found
No related merge requests found
...@@ -138,13 +138,13 @@ STATIC mp_obj_t select_select(uint n_args, const mp_obj_t *args) { ...@@ -138,13 +138,13 @@ STATIC mp_obj_t select_select(uint n_args, const mp_obj_t *args) {
poll_map_add(&poll_map, w_array, rwx_len[1], MP_IOCTL_POLL_WR, true); poll_map_add(&poll_map, w_array, rwx_len[1], MP_IOCTL_POLL_WR, true);
poll_map_add(&poll_map, x_array, rwx_len[2], MP_IOCTL_POLL_ERR | MP_IOCTL_POLL_HUP, true); poll_map_add(&poll_map, x_array, rwx_len[2], MP_IOCTL_POLL_ERR | MP_IOCTL_POLL_HUP, true);
mp_uint_t start_tick = HAL_GetTick(); mp_uint_t start_tick = mp_hal_ticks_ms();
rwx_len[0] = rwx_len[1] = rwx_len[2] = 0; rwx_len[0] = rwx_len[1] = rwx_len[2] = 0;
for (;;) { for (;;) {
// poll the objects // poll the objects
mp_uint_t n_ready = poll_map_poll(&poll_map, rwx_len); mp_uint_t n_ready = poll_map_poll(&poll_map, rwx_len);
if (n_ready > 0 || (timeout != -1 && HAL_GetTick() - start_tick >= timeout)) { if (n_ready > 0 || (timeout != -1 && mp_hal_ticks_ms() - start_tick >= timeout)) {
// one or more objects are ready, or we had a timeout // one or more objects are ready, or we had a timeout
mp_obj_t list_array[3]; mp_obj_t list_array[3];
list_array[0] = mp_obj_new_list(rwx_len[0], NULL); list_array[0] = mp_obj_new_list(rwx_len[0], NULL);
...@@ -232,12 +232,12 @@ STATIC mp_obj_t poll_poll(uint n_args, const mp_obj_t *args) { ...@@ -232,12 +232,12 @@ STATIC mp_obj_t poll_poll(uint n_args, const mp_obj_t *args) {
} }
} }
mp_uint_t start_tick = HAL_GetTick(); mp_uint_t start_tick = mp_hal_ticks_ms();
for (;;) { for (;;) {
// poll the objects // poll the objects
mp_uint_t n_ready = poll_map_poll(&self->poll_map, NULL); mp_uint_t n_ready = poll_map_poll(&self->poll_map, NULL);
if (n_ready > 0 || (timeout != -1 && HAL_GetTick() - start_tick >= timeout)) { if (n_ready > 0 || (timeout != -1 && mp_hal_ticks_ms() - start_tick >= timeout)) {
// one or more objects are ready, or we had a timeout // one or more objects are ready, or we had a timeout
mp_obj_list_t *ret_list = mp_obj_new_list(n_ready, NULL); mp_obj_list_t *ret_list = mp_obj_new_list(n_ready, NULL);
n_ready = 0; n_ready = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment