diff options
| -rw-r--r-- | ports/rp2/cyw43_configport.h | 6 | ||||
| -rw-r--r-- | ports/rp2/modmachine.c | 2 | ||||
| -rw-r--r-- | ports/rp2/mpnetworkport.c | 5 | ||||
| -rw-r--r-- | ports/rp2/pendsv.c | 4 | ||||
| -rw-r--r-- | ports/rp2/pendsv.h | 1 |
5 files changed, 11 insertions, 7 deletions
diff --git a/ports/rp2/cyw43_configport.h b/ports/rp2/cyw43_configport.h index bb99bb297..ead1a3953 100644 --- a/ports/rp2/cyw43_configport.h +++ b/ports/rp2/cyw43_configport.h @@ -140,10 +140,12 @@ uint cyw43_get_pin_wl(cyw43_pin_index_t pin_id); #endif void cyw43_post_poll_hook(void); -extern volatile int cyw43_has_pending; +static inline bool cyw43_poll_is_pending(void) { + return pendsv_is_pending(PENDSV_DISPATCH_CYW43); +} static inline void cyw43_yield(void) { - if (!cyw43_has_pending) { + if (!cyw43_poll_is_pending()) { best_effort_wfe_or_timeout(make_timeout_time_ms(1)); } } diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c index 954ea2164..31665a764 100644 --- a/ports/rp2/modmachine.c +++ b/ports/rp2/modmachine.c @@ -145,7 +145,7 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) { uint32_t my_interrupts = MICROPY_BEGIN_ATOMIC_SECTION(); #if MICROPY_PY_NETWORK_CYW43 - if (cyw43_has_pending && cyw43_poll != NULL) { + if (cyw43_poll_is_pending()) { MICROPY_END_ATOMIC_SECTION(my_interrupts); return; } diff --git a/ports/rp2/mpnetworkport.c b/ports/rp2/mpnetworkport.c index 2687a5687..7a6df7f6e 100644 --- a/ports/rp2/mpnetworkport.c +++ b/ports/rp2/mpnetworkport.c @@ -57,7 +57,6 @@ static soft_timer_entry_t mp_network_soft_timer; #define CYW43_IRQ_LEVEL GPIO_IRQ_LEVEL_HIGH #define CYW43_SHARED_IRQ_HANDLER_PRIORITY PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY -volatile int cyw43_has_pending = 0; // The Pico SDK only lets us set GPIO wake on the current running CPU, but the // hardware doesn't have this limit. We need to always enable/disable the pin @@ -89,9 +88,8 @@ static void gpio_irq_handler(void) { // cyw43_poll(). It is re-enabled in cyw43_post_poll_hook(), implemented // below. gpio_set_cpu0_host_wake_irq_enabled(false); - cyw43_has_pending = 1; - __sev(); pendsv_schedule_dispatch(PENDSV_DISPATCH_CYW43, cyw43_poll); + __sev(); CYW43_STAT_INC(IRQ_COUNT); } } @@ -106,7 +104,6 @@ void cyw43_irq_init(void) { // This hook will run on whichever CPU serviced the PendSV interrupt void cyw43_post_poll_hook(void) { - cyw43_has_pending = 0; gpio_set_cpu0_host_wake_irq_enabled(true); } diff --git a/ports/rp2/pendsv.c b/ports/rp2/pendsv.c index 2c086f894..0bf64d0ae 100644 --- a/ports/rp2/pendsv.c +++ b/ports/rp2/pendsv.c @@ -99,6 +99,10 @@ static inline int pendsv_suspend_count(void) { #endif +bool pendsv_is_pending(size_t slot) { + return pendsv_dispatch_table[slot] != NULL; +} + static inline void pendsv_resume_run_dispatch(void) { // Run pendsv if needed. Find an entry with a dispatch and call pendsv dispatch // with it. If pendsv runs it will service all slots. diff --git a/ports/rp2/pendsv.h b/ports/rp2/pendsv.h index a5d944021..6abe950df 100644 --- a/ports/rp2/pendsv.h +++ b/ports/rp2/pendsv.h @@ -51,5 +51,6 @@ void pendsv_init(void); void pendsv_suspend(void); void pendsv_resume(void); void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f); +bool pendsv_is_pending(size_t slot); #endif // MICROPY_INCLUDED_RP2_PENDSV_H |
