Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of d7a_1x by
Diff: src/d7a_sys.cpp
- Revision:
- 77:8c792719a1fc
- Parent:
- 76:fda2e34ff19d
- Child:
- 78:f1c0affd99e7
--- a/src/d7a_sys.cpp Tue Dec 20 09:30:14 2016 +0000 +++ b/src/d7a_sys.cpp Wed Dec 21 10:47:29 2016 +0000 @@ -7,26 +7,18 @@ #include "d7a_sys.h" #include "d7a.h" - -typedef struct { - Thread* thread; - Queue<d7a_com_rx_msg_t, 16> pkt_queue; - Queue<bool, 1> wait_pong; -} d7a_sys_ctx_t; - -d7a_sys_ctx_t g_sys_ctx; +static Thread g_sys_thread(osPriorityHigh, DEFAULT_STACK_SIZE, NULL); +static Queue<d7a_com_rx_msg_t, 8> g_sys_pkt_queue; +static Queue<bool, 1> g_sys_wait_pong; void d7a_sys_thread(); d7a_errors_t d7a_sys_open(void) { FPRINT("\r\n"); - - g_sys_ctx.thread = new Thread(osPriorityHigh, DEFAULT_STACK_SIZE*2, NULL); - osStatus err = g_sys_ctx.thread->start(d7a_sys_thread); + osStatus err = g_sys_thread.start(d7a_sys_thread); ASSERT(err == osOK, "Failed to start d7a_sys_thread (err: %d)\r\n", err); - return D7A_ERR_NONE; } @@ -35,7 +27,7 @@ { FPRINT("\r\n"); - g_sys_ctx.thread->terminate(); + g_sys_thread.terminate(); return D7A_ERR_NONE; } @@ -43,13 +35,13 @@ void d7a_sys_new_pkt(d7a_com_rx_msg_t* pkt) { FPRINT("\r\n"); - ASSERT(g_sys_ctx.pkt_queue.put(pkt) == osOK, "SYS queue full!\r\n"); + ASSERT(g_sys_pkt_queue.put(pkt) == osOK, "SYS queue full!\r\n"); } d7a_com_rx_msg_t* d7a_sys_wait_pkt( uint32_t millisec ) { FPRINT("\r\n"); - osEvent evt = g_sys_ctx.pkt_queue.get(millisec); + osEvent evt = g_sys_pkt_queue.get(millisec); return (evt.status == osEventMessage)? (d7a_com_rx_msg_t*)evt.value.p : NULL; } @@ -72,7 +64,7 @@ d7a_com_dump(buf, 4, KAL_COM_FLOW_SYS_PING); - osEvent evt = g_sys_ctx.wait_pong.get(millisec); + osEvent evt = g_sys_wait_pong.get(millisec); return (evt.status == osEventMessage)? true: false; } @@ -132,7 +124,7 @@ break; case KAL_COM_FLOW_SYS_PONG: //IPRINT("KAL_COM_FLOW_SYS_PONG\r\n"); - g_sys_ctx.wait_pong.put(NULL); + g_sys_wait_pong.put(NULL); break; case KAL_COM_FLOW_SYS_CFG: IPRINT("KAL_COM_FLOW_SYS_CFG\r\n");