rp2/mpconfigport: Factor core event handling to EVENT_POLL_HOOK_FAST.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-07-05 16:11:42 +10:00
parent 4b9a2abbde
commit 85be3d3da8
3 changed files with 10 additions and 8 deletions

View File

@ -248,12 +248,17 @@ extern const struct _mod_network_nic_type_t mod_network_nic_type_wiznet5k;
#define MICROPY_HW_USBDEV_TASK_HOOK
#endif
#define MICROPY_EVENT_POLL_HOOK \
#define MICROPY_EVENT_POLL_HOOK_FAST \
do { \
MICROPY_HW_USBDEV_TASK_HOOK \
extern void mp_handle_pending(bool); \
mp_handle_pending(true); \
} while (0)
#define MICROPY_EVENT_POLL_HOOK \
do { \
MICROPY_EVENT_POLL_HOOK_FAST; \
best_effort_wfe_or_timeout(make_timeout_time_ms(1)); \
MICROPY_HW_USBDEV_TASK_HOOK \
} while (0);
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1))

View File

@ -157,9 +157,8 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
void mp_hal_delay_ms(mp_uint_t ms) {
absolute_time_t t = make_timeout_time_ms(ms);
while (!time_reached(t)) {
mp_handle_pending(true);
MICROPY_EVENT_POLL_HOOK_FAST;
best_effort_wfe_or_timeout(t);
MICROPY_HW_USBDEV_TASK_HOOK
}
}

View File

@ -657,8 +657,7 @@ STATIC mp_obj_t rp2_state_machine_get(size_t n_args, const mp_obj_t *args) {
for (;;) {
while (pio_sm_is_rx_fifo_empty(self->pio, self->sm)) {
// This delay must be fast.
mp_handle_pending(true);
MICROPY_HW_USBDEV_TASK_HOOK
MICROPY_EVENT_POLL_HOOK_FAST;
}
uint32_t value = pio_sm_get(self->pio, self->sm) >> shift;
if (dest == NULL) {
@ -716,8 +715,7 @@ STATIC mp_obj_t rp2_state_machine_put(size_t n_args, const mp_obj_t *args) {
}
while (pio_sm_is_tx_fifo_full(self->pio, self->sm)) {
// This delay must be fast.
mp_handle_pending(true);
MICROPY_HW_USBDEV_TASK_HOOK
MICROPY_EVENT_POLL_HOOK_FAST;
}
pio_sm_put(self->pio, self->sm, value << shift);
}