Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23fb171

Browse files
projectgusdpgeorge
authored andcommitted
rp2/mpnetworkport: Refactor out cyw43_has_pending global variable.
A better indication of whether a cyw43 event is pending is the actual flagin the PendSV handler table. (If this fails, could also use the GPIOinterrupt enabled register bit).This commit was needed of a previous version of the fix in the parentcommit, but it turned out not strictly necessary for the current version.However, it's still a good clean up.This work was funded through GitHub Sponsors.Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent6fa498c commit23fb171

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

‎ports/rp2/cyw43_configport.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ uint cyw43_get_pin_wl(cyw43_pin_index_t pin_id);
140140
#endif
141141

142142
voidcyw43_post_poll_hook(void);
143-
externvolatileintcyw43_has_pending;
143+
staticinlineboolcyw43_poll_is_pending(void) {
144+
returnpendsv_is_pending(PENDSV_DISPATCH_CYW43);
145+
}
144146

145147
staticinlinevoidcyw43_yield(void) {
146-
if (!cyw43_has_pending) {
148+
if (!cyw43_poll_is_pending()) {
147149
best_effort_wfe_or_timeout(make_timeout_time_ms(1));
148150
}
149151
}

‎ports/rp2/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
145145

146146
uint32_tmy_interrupts=MICROPY_BEGIN_ATOMIC_SECTION();
147147
#ifMICROPY_PY_NETWORK_CYW43
148-
if (cyw43_has_pending&&cyw43_poll!=NULL) {
148+
if (cyw43_poll_is_pending()) {
149149
MICROPY_END_ATOMIC_SECTION(my_interrupts);
150150
return;
151151
}

‎ports/rp2/mpnetworkport.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ static soft_timer_entry_t mp_network_soft_timer;
5757
#defineCYW43_IRQ_LEVEL GPIO_IRQ_LEVEL_HIGH
5858
#defineCYW43_SHARED_IRQ_HANDLER_PRIORITY PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY
5959

60-
volatileintcyw43_has_pending=0;
6160

6261
// The Pico SDK only lets us set GPIO wake on the current running CPU, but the
6362
// hardware doesn't have this limit. We need to always enable/disable the pin
@@ -89,9 +88,8 @@ static void gpio_irq_handler(void) {
8988
// cyw43_poll(). It is re-enabled in cyw43_post_poll_hook(), implemented
9089
// below.
9190
gpio_set_cpu0_host_wake_irq_enabled(false);
92-
cyw43_has_pending=1;
93-
__sev();
9491
pendsv_schedule_dispatch(PENDSV_DISPATCH_CYW43,cyw43_poll);
92+
__sev();
9593
CYW43_STAT_INC(IRQ_COUNT);
9694
}
9795
}
@@ -106,7 +104,6 @@ void cyw43_irq_init(void) {
106104

107105
// This hook will run on whichever CPU serviced the PendSV interrupt
108106
voidcyw43_post_poll_hook(void) {
109-
cyw43_has_pending=0;
110107
gpio_set_cpu0_host_wake_irq_enabled(true);
111108
}
112109

‎ports/rp2/pendsv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ static inline int pendsv_suspend_count(void) {
9999

100100
#endif
101101

102+
boolpendsv_is_pending(size_tslot) {
103+
returnpendsv_dispatch_table[slot]!=NULL;
104+
}
105+
102106
staticinlinevoidpendsv_resume_run_dispatch(void) {
103107
// Run pendsv if needed. Find an entry with a dispatch and call pendsv dispatch
104108
// with it. If pendsv runs it will service all slots.

‎ports/rp2/pendsv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ void pendsv_init(void);
5151
voidpendsv_suspend(void);
5252
voidpendsv_resume(void);
5353
voidpendsv_schedule_dispatch(size_tslot,pendsv_dispatch_tf);
54+
boolpendsv_is_pending(size_tslot);
5455

5556
#endif// MICROPY_INCLUDED_RP2_PENDSV_H

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp