Skip to content

Commit 96e1d5b

Browse files
authored
Merge pull request #3221 from andreaslarssonublox/ublox_odin_w2_drivers_update
u-blox odin w2 drivers update
2 parents 79abaab + 31a7cd0 commit 96e1d5b

File tree

8 files changed

+37
-4
lines changed

8 files changed

+37
-4
lines changed

features/FEATURE_LWIP/lwip-interface/emac_stack_lwip.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem)
4747
pbuf_free((struct pbuf*)mem);
4848
}
4949

50+
void emac_stack_mem_copy(emac_stack_t* stack, emac_stack_mem_t *to, emac_stack_mem_t *from)
51+
{
52+
pbuf_copy((struct pbuf*)to, (struct pbuf*)from);
53+
}
54+
5055
void *emac_stack_mem_ptr(emac_stack_t* stack, emac_stack_mem_t *mem)
5156
{
5257
return ((struct pbuf*)mem)->payload;

features/netsocket/emac_stack_mem.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ emac_stack_mem_t *emac_stack_mem_alloc(emac_stack_t* stack, uint32_t size, uint3
4949
*/
5050
void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem);
5151

52+
/**
53+
* Copy memory
54+
*
55+
* @param stack Emac stack context
56+
* @param to Memory to copy to
57+
* @param from Memory to copy from
58+
*/
59+
void emac_stack_mem_copy(emac_stack_t* stack, emac_stack_mem_t *to, emac_stack_mem_t *from);
60+
5261
/**
5362
* Return pointer to the payload
5463
*

targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/ublox-odin-w2-drivers/OdinWiFiInterface.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "mbed_events.h"
2323

2424
#include "rtos.h"
25+
#include "cmsis_os.h"
2526
#include "emac_api.h"
2627
#include "nsapi_types.h"
2728
#include "lwip/netif.h"
@@ -211,8 +212,9 @@ class OdinWiFiInterface : public WiFiInterface
211212
int32_t target_id;
212213
// Event queue for sending start up and connection events from driver to this class
213214
MsgQueue _event_queue;
214-
// Event queue for sending scan events from driver to this class
215-
MsgQueue _scan_event_queue;
215+
// Message queue for sending scan events from driver to this class
216+
osMessageQId _scan_msg_queue_id;
217+
osMessageQDef_t _queue_def;
216218
};
217219

218220
#endif

targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/ublox-odin-w2-drivers/cb_main.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ extern void cbMAIN_startOS(void);
110110
/**
111111
* Get event queue. Used for running a function in the same thread context as the driver.
112112
* Can not be called before cbMAIN_initOS/cbMAIN_initBt/cbMAIN_initWlan.
113+
* Use cbMAIN_dispatchEventQueue to trigger the driver to call the queued up functions.
113114
* @return EventQueue Pointer to the event queue where function calls can be enqueued.
114115
*/
115116
extern EventQueue* cbMAIN_getEventQueue(void);
@@ -128,4 +129,11 @@ extern void cbMAIN_driverLock(void);
128129
*/
129130
extern void cbMAIN_driverUnlock(void);
130131

132+
/**
133+
* Dispatch event queue. Should be called to trigger calls that have been queued up in the driver context
134+
*
135+
* @return void
136+
*/
137+
extern void cbMAIN_dispatchEventQueue(void);
138+
131139
#endif /*_CB_MAIN_H_*/

targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,17 @@ static bool wifi_link_out(emac_interface_t *emac, emac_stack_mem_t *buf)
266266
{
267267
(void)emac;
268268
// Break call chain to avoid the driver affecting stack usage for the IP stack thread too much
269-
emac_stack_mem_ref(emac,buf);
270-
cbMAIN_getEventQueue()->call(send_packet,emac,buf);
269+
emac_stack_mem_t *new_buf = emac_stack_mem_alloc(emac, emac_stack_mem_chain_len(emac,buf),0);
270+
if (new_buf != NULL) {
271+
emac_stack_mem_copy(emac, new_buf, buf);
272+
int id = cbMAIN_getEventQueue()->call(send_packet, emac, new_buf);
273+
if (id != 0) {
274+
cbMAIN_dispatchEventQueue();
275+
}
276+
else {
277+
emac_stack_mem_free(emac, new_buf);
278+
}
279+
}
271280
return true;
272281
}
273282

0 commit comments

Comments
 (0)