Merge pull request #3221 from andreaslarssonublox/ublox_odin_w2_drivers_update

u-blox odin w2 drivers update
pull/3230/head
Martin Kojtal 2016-11-08 10:24:53 +00:00 committed by GitHub
commit 96e1d5bd73
8 changed files with 37 additions and 4 deletions

View File

@ -47,6 +47,11 @@ void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem)
pbuf_free((struct pbuf*)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) void *emac_stack_mem_ptr(emac_stack_t* stack, emac_stack_mem_t *mem)
{ {
return ((struct pbuf*)mem)->payload; return ((struct pbuf*)mem)->payload;

View File

@ -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); 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 * Return pointer to the payload
* *

View File

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

View File

@ -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. * 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. * 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. * @return EventQueue Pointer to the event queue where function calls can be enqueued.
*/ */
extern EventQueue* cbMAIN_getEventQueue(void); extern EventQueue* cbMAIN_getEventQueue(void);
@ -128,4 +129,11 @@ extern void cbMAIN_driverLock(void);
*/ */
extern void cbMAIN_driverUnlock(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_*/ #endif /*_CB_MAIN_H_*/

View File

@ -266,8 +266,17 @@ static bool wifi_link_out(emac_interface_t *emac, emac_stack_mem_t *buf)
{ {
(void)emac; (void)emac;
// Break call chain to avoid the driver affecting stack usage for the IP stack thread too much // Break call chain to avoid the driver affecting stack usage for the IP stack thread too much
emac_stack_mem_ref(emac,buf); emac_stack_mem_t *new_buf = emac_stack_mem_alloc(emac, emac_stack_mem_chain_len(emac,buf),0);
cbMAIN_getEventQueue()->call(send_packet,emac,buf); 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; return true;
} }