From 4091ddc4fc31da1b0c33538145e59df4ea9b6d51 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 18 Apr 2014 14:45:21 +0700 Subject: [PATCH] move osal_queue_send of osal_none to osal_none.c --- demos/device/device_freertos/.cproject | 46 +++++++++++-------- .../device_freertos/device_freertos.uvopt | 14 +++--- demos/device/src/tusb_config.h | 2 +- .../host/host_cmsis_rtx/host_cmsis_rtx.uvopt | 8 ++-- demos/host/host_os_none/host_os_none.uvopt | 26 +++++------ 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 ++--------------- 12 files changed, 87 insertions(+), 89 deletions(-) diff --git a/demos/device/device_freertos/.cproject b/demos/device/device_freertos/.cproject index 26052c70..c170dd47 100644 --- a/demos/device/device_freertos/.cproject +++ b/demos/device/device_freertos/.cproject @@ -1,23 +1,25 @@ - + + + - + + + - - @@ -93,24 +95,25 @@ + - + + + - - @@ -186,24 +189,25 @@ + - + + + - - @@ -284,24 +288,25 @@ + - + + + - - @@ -378,24 +383,25 @@ + - + + + - - @@ -475,24 +481,25 @@ + - + + + - - @@ -568,6 +575,7 @@ + diff --git a/demos/device/device_freertos/device_freertos.uvopt b/demos/device/device_freertos/device_freertos.uvopt index 9b9e341b..5a6b38f5 100644 --- a/demos/device/device_freertos/device_freertos.uvopt +++ b/demos/device/device_freertos/device_freertos.uvopt @@ -73,7 +73,7 @@ 1 0 - 0 + 1 8 @@ -793,7 +793,7 @@ 1 0 - 1 + 0 8 @@ -895,7 +895,7 @@ 0 24 0 - 86 + 87 94 0 ..\src\main.c @@ -1333,10 +1333,10 @@ 1 0 0 - 19 + 52 0 - 13 - 14 + 1 + 13 0 ..\..\..\tinyusb\device\usbd.c usbd.c @@ -1951,7 +1951,7 @@ 0 0 0 - 146 + 147 151 0 ..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s diff --git a/demos/device/src/tusb_config.h b/demos/device/src/tusb_config.h index f653b85f..1cb8aef2 100644 --- a/demos/device/src/tusb_config.h +++ b/demos/device/src/tusb_config.h @@ -57,7 +57,7 @@ //------------- CLASS -------------// #define TUSB_CFG_DEVICE_HID_KEYBOARD 1 -#define TUSB_CFG_DEVICE_HID_MOUSE 0 +#define TUSB_CFG_DEVICE_HID_MOUSE 1 #define TUSB_CFG_DEVICE_HID_GENERIC 0 // not supported yet #define TUSB_CFG_DEVICE_MSC 1 #define TUSB_CFG_DEVICE_CDC 1 diff --git a/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt b/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt index 3625cf85..37550088 100644 --- a/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt +++ b/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt @@ -638,10 +638,10 @@ 1 0 0 - 29 + 27 0 - 95 - 101 + 96 + 98 0 ..\src\main.c main.c @@ -1528,7 +1528,7 @@ 0 0 0 - 145 + 146 151 0 ..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s diff --git a/demos/host/host_os_none/host_os_none.uvopt b/demos/host/host_os_none/host_os_none.uvopt index b065d206..ea3148b9 100644 --- a/demos/host/host_os_none/host_os_none.uvopt +++ b/demos/host/host_os_none/host_os_none.uvopt @@ -613,7 +613,7 @@ 0 9 0 - 88 + 89 90 0 ..\src\main.c @@ -645,8 +645,8 @@ 0 0 0 - 116 - 117 + 1 + 1 0 ..\src\keyboard_host_app.c keyboard_host_app.c @@ -661,8 +661,8 @@ 0 0 0 - 132 - 133 + 1 + 1 0 ..\src\mouse_host_app.c mouse_host_app.c @@ -677,7 +677,7 @@ 0 0 0 - 150 + 151 159 0 ..\src\msc_host_app.c @@ -705,7 +705,7 @@ tinyusb - 1 + 0 0 0 0 @@ -781,8 +781,8 @@ 0 0 0 - 353 - 354 + 1 + 1 0 ..\..\..\tinyusb\host\usbh.c usbh.c @@ -1139,10 +1139,10 @@ 1 0 0 - 0 + 38 0 - 0 - 0 + 1690 + 1709 0 ..\..\..\vendor\fatfs\ff.c ff.c @@ -1349,7 +1349,7 @@ 0 0 0 - 147 + 148 151 0 ..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c index 28a8a202..a13a268b 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 cf422ac6..5c99c3c1 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 cd50c64f..2e2ce100 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 5c60dd8d..0c37fba9 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 1e61cbf1..542f6d5b 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 e9eaa842..263a9082 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 3ca9a925..f927f170 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) {