Skip to content

Commit 90d543e

Browse files
Don't his the lwip_callback data structure
No need to add obscure __align__ if we don't pretend it's an array of bytes
1 parent 002d9c0 commit 90d543e

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

cores/rp2040/lwip_wrap.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -825,13 +825,12 @@ extern "C" {
825825
return __real_ethernet_input(p, netif);
826826
}
827827

828-
void lwip_callback(void (*cb)(void *), void *cbData, void *buffer) {
828+
void lwip_callback(void (*cb)(void *), void *cbData, __callback_req *buffer) {
829829
#ifdef __FREERTOS
830830
if (buffer) {
831-
__callback_req *req = (__callback_req *)buffer;
832-
req->cb = cb;
833-
req->cbData = cbData;
834-
__lwip(__callback, req, true);
831+
buffer->cb = cb;
832+
buffer->cbData = cbData;
833+
__lwip(__callback, buffer, true);
835834
return;
836835
} else if (!__isLWIPThread()) {
837836
__callback_req req = { cb, cbData };

cores/rp2040/lwip_wrap.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,12 @@ typedef struct {
569569
} __ethernet_input_req;
570570

571571
// Run a callback in the LWIP thread (i.e. for Ethernet device polling and packet reception)
572-
// When in an interrupt, need to pass in a heap-allocated buffer (i.e. class variable) of
573-
// size LWIP_CALLBACK_BUFFER_SIZE that will be used to store the request.
574-
extern void lwip_callback(void (*cb)(void *), void *cbData, void *buffer = nullptr);
572+
// When in an interrupt, need to pass in a heap-allocated buffer
575573
typedef struct {
576574
void (*cb)(void *);
577575
void *cbData;
578576
} __callback_req;
579-
#define LWIP_CALLBACK_BUFFER_SIZE sizeof(__callback_req)
577+
extern void lwip_callback(void (*cb)(void *), void *cbData, __callback_req *buffer = nullptr);
580578

581579
#ifdef __cplusplus
582580
};

libraries/lwIP_Ethernet/src/LwipIntfDev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ class LwipIntfDev: public LwipIntf, public RawDev {
194194
err_t handlePackets();
195195
#ifdef __FREERTOS
196196
SemaphoreHandle_t _hwMutex;
197+
__callback_req _irqBuffer;
197198
#endif
198-
uint8_t _irqBuffer[LWIP_CALLBACK_BUFFER_SIZE] __attribute__ ((aligned (4)));;
199199
protected:
200200
// members
201201
SPIClass& _spiUnit;
@@ -490,7 +490,7 @@ template<class RawDev>
490490
void LwipIntfDev<RawDev>::_irq(void *param) {
491491
LwipIntfDev *d = static_cast<LwipIntfDev*>(param);
492492
ethernet_arch_lwip_gpio_mask(); // Disable other IRQs until we're done processing this one
493-
lwip_callback(_lwipCallback, param, (void *)d->_irqBuffer);
493+
lwip_callback(_lwipCallback, param, &d->_irqBuffer);
494494
//ethernet_arch_lwip_begin();
495495
// d->handlePackets();
496496
// sys_check_timeouts();

0 commit comments

Comments
 (0)