From 4091ddc4fc31da1b0c33538145e59df4ea9b6d51 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 18 Apr 2014 14:45:21 +0700 Subject: move osal_queue_send of osal_none to osal_none.c --- tinyusb/class/hid_host.c | 2 +- tinyusb/device/usbd_dcd.h | 4 ++++ tinyusb/host/ehci/ehci.c | 1 - tinyusb/host/ehci/ehci.h | 2 +- tinyusb/host/usbh.c | 2 +- tinyusb/osal/osal_none.c | 26 +++++++++++++++++++++++--- tinyusb/osal/osal_none.h | 43 +++++-------------------------------------- 7 files changed, 35 insertions(+), 45 deletions(-) (limited to 'tinyusb') diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c index 28a8a202a..a13a268b5 100644 --- a/tinyusb/class/hid_host.c +++ b/tinyusb/class/hid_host.c @@ -207,7 +207,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con 0, NULL ), error ); - (void) error; // skip it set idle is failed + (void) error; // skip if set idle is failed #if 0 //------------- Get Report Descriptor TODO HID parser -------------// diff --git a/tinyusb/device/usbd_dcd.h b/tinyusb/device/usbd_dcd.h index cf422ac6a..5c99c3c1e 100644 --- a/tinyusb/device/usbd_dcd.h +++ b/tinyusb/device/usbd_dcd.h @@ -47,6 +47,10 @@ //--------------------------------------------------------------------+ #include "common/common.h" +#ifdef _TEST_ +#include "dcd.h" +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index cd50c64f5..2e2ce1001 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -549,7 +549,6 @@ static void port_connect_status_change_isr(uint8_t hostid) }else // device unplugged { usbh_hcd_rhport_unplugged_isr(hostid); -// regs->usb_cmd_bit.advacne_async = 1; // Async doorbell check EHCI 4.8.2 for operational details } } diff --git a/tinyusb/host/ehci/ehci.h b/tinyusb/host/ehci/ehci.h index 5c60dd8de..0c37fba97 100644 --- a/tinyusb/host/ehci/ehci.h +++ b/tinyusb/host/ehci/ehci.h @@ -153,7 +153,7 @@ typedef struct { STATIC_ASSERT( sizeof(ehci_qtd_t) == 32, "size is not correct" ); /// Queue Head (section 3.6) -typedef struct { +typedef struct ATTR_ALIGNED(32) { /// Word 0: Queue Head Horizontal Link Pointer ehci_link_t next; diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 1e61cbf18..542f6d5bf 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -112,7 +112,7 @@ enum { ENUM_QUEUE_DEPTH = 8 }; OSAL_TASK_DEF(usbh_enumeration_task, 200, TUSB_CFG_OS_TASK_PRIO); OSAL_QUEUE_DEF(enum_queue_def, ENUM_QUEUE_DEPTH, uint32_t); -static osal_queue_handle_t enum_queue_hdl; +STATIC_VAR osal_queue_handle_t enum_queue_hdl; TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4) STATIC_VAR uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE]; //------------- Reporter Task Data -------------// 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 diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index 3ca9a925a..f927f1707 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -148,11 +148,8 @@ uint32_t tusb_tick_get(void); typedef volatile uint8_t osal_semaphore_t; typedef osal_semaphore_t * osal_semaphore_handle_t; -#define OSAL_SEM_DEF(name)\ - osal_semaphore_t name - -#define OSAL_SEM_REF(name)\ - &name +#define OSAL_SEM_DEF(name) osal_semaphore_t name +#define OSAL_SEM_REF(name) &name static inline osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem) @@ -165,7 +162,6 @@ static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t sem_hdl) static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t sem_hdl) { (*sem_hdl)++; - return TUSB_ERROR_NONE; } @@ -196,11 +192,8 @@ static inline void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl) typedef osal_semaphore_t osal_mutex_t; typedef osal_semaphore_handle_t osal_mutex_handle_t; -#define OSAL_MUTEX_DEF(name)\ - osal_mutex_t name - -#define OSAL_MUTEX_REF(name)\ - &name +#define OSAL_MUTEX_DEF(name) osal_mutex_t name +#define OSAL_MUTEX_REF(name) &name static inline osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex) @@ -257,33 +250,7 @@ static inline osal_queue_handle_t osal_queue_create(osal_queue_t * const p_queue p_queue->count = p_queue->wr_idx = p_queue->rd_idx = 0; return (osal_queue_handle_t) p_queue; } - -// TODO move to osal_none.c -// when queue is full, it will overwrite the oldest data in the queue -static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data) ATTR_ALWAYS_INLINE; -static inline 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; -} - +tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data); static inline void osal_queue_flush(osal_queue_handle_t const queue_hdl) ATTR_ALWAYS_INLINE; static inline void osal_queue_flush(osal_queue_handle_t const queue_hdl) { -- cgit v1.3.1