Skip to content

Commit b0e272e

Browse files
LWIP task calls lwip_init and sys_check_timeouts
The LWIP processor thread should initialize LWIP since it's the only person actually calling it directly. LWIP thread can also handle the sys_check_timeout calls for all drivers, no need for Ethernet loop to worry about that.
1 parent 9e92724 commit b0e272e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

cores/rp2040/freertos/variantHooks.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,14 @@ static void lwipThread(void *params) {
590590
(void) params;
591591
LWIPWork w;
592592
assert(__isLWIPThread());
593+
unsigned int scd = 100 / portTICK_PERIOD_MS;
594+
595+
lwip_init(); // Will call our wrapper and set up the RNG
593596

594597
while (true) {
595-
if (xQueueReceive(__lwipQueue, &w, portMAX_DELAY)) {
598+
auto ret = xQueueReceive(__lwipQueue, &w, scd);
599+
if (ret)
600+
{
596601
switch (w.op)
597602
{
598603
case __lwip_init:
@@ -955,6 +960,15 @@ static void lwipThread(void *params) {
955960
if (w.wakeup) {
956961
xTaskNotifyGiveIndexed(w.wakeup, TASK_NOTIFY_LWIP_WAKEUP);
957962
}
963+
} else
964+
{
965+
// No work received, do periodic processing
966+
__real_sys_check_timeouts();
967+
// When should we wake up next to redo timeouts?
968+
scd = sys_timeouts_sleeptime();
969+
if (scd == SYS_TIMEOUTS_SLEEPTIME_INFINITE) {
970+
scd = portMAX_DELAY / portTICK_PERIOD_MS;
971+
}
958972
}
959973
}
960974
}

libraries/lwIP_Ethernet/src/LwipEthernet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ static void ethernet_timeout_reached(__unused async_context_t *context, __unused
211211
ethernet_arch_lwip_gpio_mask(); // Ensure non-polled devices won't interrupt us
212212
for (auto handlePacket : _handlePacketList) {
213213
handlePacket.second();
214+
sys_check_timeouts();
214215
}
215216
//#if defined(PICO_CYW43_SUPPORTED)
216217
// if (!rp2040.isPicoW()) {
217218
// sys_check_timeouts();
218219
// }
219220
//#else
220-
sys_check_timeouts();
221221
//#endif
222222
ethernet_arch_lwip_gpio_unmask();
223223
}

0 commit comments

Comments
 (0)