Skip to content

Commit

Permalink
ports/renesas: Replace MICROPY_EVENT_POLL_HOOK with mp_event_wait.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
pi-anl committed Sep 29, 2024
1 parent eec5eb4 commit 1cf893a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ports/renesas-ra/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ static mp_uint_t mp_machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, uint
if (!uart_tx_busy(self)) {
return 0;
}
MICROPY_EVENT_POLL_HOOK
mp_event_wait_indefinite();
} while (mp_hal_ticks_ms() < timeout);
*errcode = MP_ETIMEDOUT;
ret = MP_STREAM_ERROR;
Expand Down
15 changes: 1 addition & 14 deletions ports/renesas-ra/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,30 +265,17 @@ typedef long mp_off_t;
#endif

#if MICROPY_PY_THREAD
#define MICROPY_EVENT_POLL_HOOK \
#define MICROPY_INTERNAL_EVENT_HOOK \
do { \
extern void mp_handle_pending(bool); \
MICROPY_HW_USBDEV_TASK_HOOK \
mp_handle_pending(true); \
if (pyb_thread_enabled) { \
MP_THREAD_GIL_EXIT(); \
pyb_thread_yield(); \
MP_THREAD_GIL_ENTER(); \
} else { \
__WFI(); \
} \
} while (0);

#define MICROPY_THREAD_YIELD() pyb_thread_yield()
#else
#define MICROPY_EVENT_POLL_HOOK \
do { \
extern void mp_handle_pending(bool); \
MICROPY_HW_USBDEV_TASK_HOOK \
mp_handle_pending(true); \
__WFI(); \
} while (0);

#define MICROPY_THREAD_YIELD()
#endif

Expand Down
2 changes: 1 addition & 1 deletion ports/renesas-ra/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int mp_hal_stdin_rx_chr(void) {
return dupterm_c;
}
#endif
MICROPY_EVENT_POLL_HOOK
mp_event_wait_indefinite();
}
}

Expand Down
2 changes: 1 addition & 1 deletion ports/renesas-ra/systick.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void mp_hal_delay_ms(mp_uint_t Delay) {
// This macro will execute the necessary idle behaviour. It may
// raise an exception, switch threads or enter sleep mode (waiting for
// (at least) the SysTick interrupt).
MICROPY_EVENT_POLL_HOOK
mp_event_wait_indefinite();
} while (uwTick - start < Delay);
} else {
// IRQs disabled, so need to use a busy loop for the delay.
Expand Down
4 changes: 2 additions & 2 deletions ports/renesas-ra/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ bool uart_rx_wait(machine_uart_obj_t *self, uint32_t timeout) {
if (HAL_GetTick() - start >= timeout) {
return false; // timeout
}
MICROPY_EVENT_POLL_HOOK
mp_event_wait_indefinite();
}
}

Expand All @@ -498,7 +498,7 @@ bool uart_tx_wait(machine_uart_obj_t *self, uint32_t timeout) {
if (HAL_GetTick() - start >= timeout) {
return false; // timeout
}
MICROPY_EVENT_POLL_HOOK
mp_event_wait_indefinite();
}
}

Expand Down

0 comments on commit 1cf893a

Please sign in to comment.