diff options
| author | hathach <[email protected]> | 2014-04-18 14:45:21 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2014-04-18 14:45:21 +0700 |
| commit | 4091ddc4fc31da1b0c33538145e59df4ea9b6d51 (patch) | |
| tree | 1bd2d5a227120021c810829723daaaa3ceac05cd /tinyusb/osal/osal_none.c | |
| parent | 6aecb62be2af8889d82f2cd3cee0fd794c353338 (diff) | |
move osal_queue_send of osal_none to osal_none.c
Diffstat (limited to 'tinyusb/osal/osal_none.c')
| -rw-r--r-- | tinyusb/osal/osal_none.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/tinyusb/osal/osal_none.c b/tinyusb/osal/osal_none.c index e9eaa842a..263a90822 100644 --- a/tinyusb/osal/osal_none.c +++ b/tinyusb/osal/osal_none.c @@ -37,7 +37,7 @@ /**************************************************************************/
#include "tusb_option.h"
-#include "osal.h" // TODO refractor
+#include "osal.h"
#if TUSB_CFG_OS == TUSB_OS_NONE
@@ -51,11 +51,31 @@ //--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-//volatile uint32_t osal_tick_current = 0;
//--------------------------------------------------------------------+
-// IMPLEMENTATION
+// QUEUE API
//--------------------------------------------------------------------+
+// when queue is full, it will overwrite the oldest data in the queue
+tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data)
+{
+ //TODO mutex lock hal_interrupt_disable
+ memcpy( queue_hdl->buffer + (queue_hdl->wr_idx * queue_hdl->item_size),
+ data,
+ queue_hdl->item_size);
+ queue_hdl->wr_idx = (queue_hdl->wr_idx + 1) % queue_hdl->depth;
+
+ if (queue_hdl->depth == queue_hdl->count) // queue is full, 1st rd is overwritten
+ {
+ queue_hdl->rd_idx = queue_hdl->wr_idx; // keep full state
+ }else
+ {
+ queue_hdl->count++;
+ }
+
+ //TODO mutex unlock hal_interrupt_enable
+
+ return TUSB_ERROR_NONE;
+}
#endif
|
