Skip to content

Commit 623c2df

Browse files
lwip_callback can take a cbData
1 parent 452abcb commit 623c2df

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

cores/rp2040/freertos/variantHooks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ static void lwipThread(void *params) {
932932
case __callback:
933933
{
934934
__callback_req *r = (__callback_req *)w.req;
935-
r->cb();
935+
r->cb(r->cbData);
936936
break;
937937
}
938938
default:

cores/rp2040/lwip_wrap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,15 @@ extern "C" {
829829
return __real_ethernet_input(p, netif);
830830
}
831831

832-
void lwip_callback(void (*cb)()) {
832+
void lwip_callback(void (*cb)(void *), void *cbData) {
833833
#ifdef __FREERTOS
834834
if (!__isLWIPThread()) {
835-
__callback_req req = { cb };
835+
__callback_req req = { cb, cbData };
836836
__lwip(__callback, &req);
837837
return;
838838
}
839839
#endif
840-
cb();
840+
cb(cbData);
841841
return;
842842
}
843843

include/lwipopts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extern void __setSystemTime(unsigned long long sec, unsigned long us);
8383
#define SNTP_SERVER_DNS 1
8484

8585
#ifndef LWIP_DEBUG
86-
#define LWIP_DEBUG 1
86+
#define LWIP_DEBUG 0
8787
#endif
8888
#define ETHARP_DEBUG (LWIP_DEBUG ? LWIP_DBG_ON : LWIP_DBG_OFF)
8989
#define NETIF_DEBUG (LWIP_DEBUG ? LWIP_DBG_ON : LWIP_DBG_OFF)

libraries/lwIP_Ethernet/src/LwipEthernet.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,18 @@ static void update_next_timeout(async_context_t *context, async_when_pending_wor
233233
// and polls all Ethernet interfaces
234234
static TaskHandle_t _ethernetTask;;
235235

236-
static void stage2() {
237-
// Scan the installed Ethernet drivers
238-
for (auto handlePacket : _handlePacketList) {
239-
// Note that each NIC needs to use its own mutex to ensure LWIP isn't doing something with it at the time we want to poll
240-
handlePacket.second();
241-
}
242-
// Do LWIP stuff as needed
243-
sys_check_timeouts();
236+
static void stage2(void *cbData) {
237+
(void) cbData;
238+
// Scan the installed Ethernet drivers
239+
for (auto handlePacket : _handlePacketList) {
240+
// Note that each NIC needs to use its own mutex to ensure LWIP isn't doing something with it at the time we want to poll
241+
handlePacket.second();
242+
}
243+
// Do LWIP stuff as needed
244+
sys_check_timeouts();
244245
}
245-
extern "C" void lwip_callback(void (*cb)());
246+
247+
extern "C" void lwip_callback(void (*cb)(void *), void *cbData);
246248
static void ethernetTask(void *param) {
247249
(void) param;
248250
while (true) {
@@ -251,7 +253,7 @@ static void ethernetTask(void *param) {
251253
sleep_ms = _pollingPeriod;
252254
}
253255
vTaskDelay(sleep_ms / portTICK_PERIOD_MS);
254-
lwip_callback(stage2);
256+
lwip_callback(stage2, nullptr);
255257
#if 0
256258
// Scan the installed Ethernet drivers
257259
for (auto handlePacket : _handlePacketList) {

0 commit comments

Comments
 (0)