Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u-blox odin w2 drivers update #3221

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions features/FEATURE_LWIP/lwip-interface/emac_stack_lwip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem)
pbuf_free((struct pbuf*)mem);
}

void emac_stack_mem_copy(emac_stack_t* stack, emac_stack_mem_t *to, emac_stack_mem_t *from)
{
pbuf_copy((struct pbuf*)to, (struct pbuf*)from);
}

void *emac_stack_mem_ptr(emac_stack_t* stack, emac_stack_mem_t *mem)
{
return ((struct pbuf*)mem)->payload;
Expand Down
9 changes: 9 additions & 0 deletions features/netsocket/emac_stack_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ emac_stack_mem_t *emac_stack_mem_alloc(emac_stack_t* stack, uint32_t size, uint3
*/
void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem);

/**
* Copy memory
*
* @param stack Emac stack context
* @param to Memory to copy to
* @param from Memory to copy from
*/
void emac_stack_mem_copy(emac_stack_t* stack, emac_stack_mem_t *to, emac_stack_mem_t *from);

/**
* Return pointer to the payload
*
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "mbed_events.h"

#include "rtos.h"
#include "cmsis_os.h"
#include "emac_api.h"
#include "nsapi_types.h"
#include "lwip/netif.h"
Expand Down Expand Up @@ -211,8 +212,9 @@ class OdinWiFiInterface : public WiFiInterface
int32_t target_id;
// Event queue for sending start up and connection events from driver to this class
MsgQueue _event_queue;
// Event queue for sending scan events from driver to this class
MsgQueue _scan_event_queue;
// Message queue for sending scan events from driver to this class
osMessageQId _scan_msg_queue_id;
osMessageQDef_t _queue_def;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ extern void cbMAIN_startOS(void);
/**
* Get event queue. Used for running a function in the same thread context as the driver.
* Can not be called before cbMAIN_initOS/cbMAIN_initBt/cbMAIN_initWlan.
* Use cbMAIN_dispatchEventQueue to trigger the driver to call the queued up functions.
* @return EventQueue Pointer to the event queue where function calls can be enqueued.
*/
extern EventQueue* cbMAIN_getEventQueue(void);
Expand All @@ -128,4 +129,11 @@ extern void cbMAIN_driverLock(void);
*/
extern void cbMAIN_driverUnlock(void);

/**
* Dispatch event queue. Should be called to trigger calls that have been queued up in the driver context
*
* @return void
*/
extern void cbMAIN_dispatchEventQueue(void);

#endif /*_CB_MAIN_H_*/
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,17 @@ static bool wifi_link_out(emac_interface_t *emac, emac_stack_mem_t *buf)
{
(void)emac;
// Break call chain to avoid the driver affecting stack usage for the IP stack thread too much
emac_stack_mem_ref(emac,buf);
cbMAIN_getEventQueue()->call(send_packet,emac,buf);
emac_stack_mem_t *new_buf = emac_stack_mem_alloc(emac, emac_stack_mem_chain_len(emac,buf),0);
if (new_buf != NULL) {
emac_stack_mem_copy(emac, new_buf, buf);
int id = cbMAIN_getEventQueue()->call(send_packet, emac, new_buf);
if (id != 0) {
cbMAIN_dispatchEventQueue();
}
else {
emac_stack_mem_free(emac, new_buf);
}
}
return true;
}

Expand Down