Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
fc94399f
Commit
fc94399f
authored
Nov 14, 2023
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rp2/mpnetworkport: Rework lwIP polling to use soft_timer.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
633c6047
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
24 deletions
+19
-24
ports/rp2/cyw43_configport.h
ports/rp2/cyw43_configport.h
+1
-3
ports/rp2/mpnetworkport.c
ports/rp2/mpnetworkport.c
+18
-18
ports/rp2/pendsv.h
ports/rp2/pendsv.h
+0
-3
No files found.
ports/rp2/cyw43_configport.h
View file @
fc94399f
...
...
@@ -104,11 +104,9 @@ void cyw43_post_poll_hook(void);
extern
volatile
int
cyw43_has_pending
;
static
inline
void
cyw43_yield
(
void
)
{
uint32_t
my_interrupts
=
save_and_disable_interrupts
();
if
(
!
cyw43_has_pending
)
{
__WFI
(
);
best_effort_wfe_or_timeout
(
make_timeout_time_ms
(
1
)
);
}
restore_interrupts
(
my_interrupts
);
}
static
inline
void
cyw43_delay_us
(
uint32_t
us
)
{
...
...
ports/rp2/mpnetworkport.c
View file @
fc94399f
...
...
@@ -30,13 +30,14 @@
#if MICROPY_PY_LWIP
#include "shared/runtime/softtimer.h"
#include "lwip/timeouts.h"
#include "pico/time.h"
// Poll lwIP every 64ms by default
#define LWIP_TICK_RATE_MS 64
static
alarm_id_t
lwip_alarm_id
=
-
1
;
// Soft timer for running lwIP in the background.
static
soft_timer_entry_t
mp_network_soft_timer
;
#if MICROPY_PY_NETWORK_CYW43
#include "lib/cyw43-driver/src/cyw43.h"
...
...
@@ -56,6 +57,7 @@ static void gpio_irq_handler(void) {
// CYW43_POST_POLL_HOOK which is called at the end of cyw43_poll_func.
gpio_set_irq_enabled
(
CYW43_PIN_WL_HOST_WAKE
,
CYW43_IRQ_LEVEL
,
false
);
cyw43_has_pending
=
1
;
__SEV
();
pendsv_schedule_dispatch
(
PENDSV_DISPATCH_CYW43
,
cyw43_poll
);
CYW43_STAT_INC
(
IRQ_COUNT
);
}
...
...
@@ -88,11 +90,6 @@ u32_t sys_now(void) {
return
mp_hal_ticks_ms
();
}
STATIC
void
lwip_poll
(
void
)
{
// Run the lwIP internal updates
sys_check_timeouts
();
}
void
lwip_lock_acquire
(
void
)
{
// Prevent PendSV from running.
pendsv_suspend
();
...
...
@@ -103,22 +100,25 @@ void lwip_lock_release(void) {
pendsv_resume
();
}
STATIC
int64_t
alarm_callback
(
alarm_id_t
id
,
void
*
user_data
)
{
pendsv_schedule_dispatch
(
PENDSV_DISPATCH_LWIP
,
lwip_poll
);
// This is called by soft_timer and executes at PendSV level.
static
void
mp_network_soft_timer_callback
(
soft_timer_entry_t
*
self
)
{
// Run the lwIP internal updates.
sys_check_timeouts
();
#if MICROPY_PY_NETWORK_WIZNET5K
pendsv_schedule_dispatch
(
PENDSV_DISPATCH_WIZNET
,
wiznet5k_poll
);
wiznet5k_poll
(
);
#endif
return
LWIP_TICK_RATE_MS
*
1000
;
}
void
mod_network_lwip_init
(
void
)
{
#if MICROPY_PY_NETWORK_WIZNET5K
wiznet5k_deinit
();
#endif
if
(
lwip_alarm_id
!=
-
1
)
{
cancel_alarm
(
lwip_alarm_id
);
}
lwip_alarm_id
=
add_alarm_in_us
(
LWIP_TICK_RATE_MS
*
1000
,
alarm_callback
,
mp_const_true
,
true
);
soft_timer_static_init
(
&
mp_network_soft_timer
,
SOFT_TIMER_MODE_PERIODIC
,
LWIP_TICK_RATE_MS
,
mp_network_soft_timer_callback
);
soft_timer_reinsert
(
&
mp_network_soft_timer
,
LWIP_TICK_RATE_MS
);
}
#endif // MICROPY_PY_LWIP
ports/rp2/pendsv.h
View file @
fc94399f
...
...
@@ -30,9 +30,6 @@
enum
{
PENDSV_DISPATCH_SOFT_TIMER
,
#if MICROPY_PY_LWIP
PENDSV_DISPATCH_LWIP
,
#endif
#if MICROPY_PY_NETWORK_CYW43
PENDSV_DISPATCH_CYW43
,
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment