diff options
| author | hathach <[email protected]> | 2018-02-28 14:21:31 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-02-28 14:21:43 +0700 |
| commit | 9b7cd608aa4addf40cbe2135b38a78378e6f428f (patch) | |
| tree | 5233a0c8244bd1d477471ccd8cb69528c8b40660 /tinyusb | |
| parent | 5efad7412ffef0bb7eb08beea29b3b06b04cfb6e (diff) | |
osal clean up
- task create, task def macros
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/common/common.h | 1 | ||||
| -rw-r--r-- | tinyusb/common/tusb_errors.h | 1 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 17 | ||||
| -rw-r--r-- | tinyusb/device/usbd.h | 2 | ||||
| -rw-r--r-- | tinyusb/osal/osal.h | 6 | ||||
| -rw-r--r-- | tinyusb/osal/osal_freeRTOS.h | 13 | ||||
| -rw-r--r-- | tinyusb/osal/osal_none.h | 11 |
7 files changed, 31 insertions, 20 deletions
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index 4007d6083..6481b33ad 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -64,6 +64,7 @@ //------------- General Header -------------//
#include "compiler/compiler.h"
#include "assertion.h"
+#include "verify.h"
#include "binary.h"
#include "tusb_errors.h"
diff --git a/tinyusb/common/tusb_errors.h b/tinyusb/common/tusb_errors.h index 98abe0aa6..3b33d4a9f 100644 --- a/tinyusb/common/tusb_errors.h +++ b/tinyusb/common/tusb_errors.h @@ -67,7 +67,6 @@ ENTRY(TUSB_ERROR_OSAL_TIMEOUT )\
ENTRY(TUSB_ERROR_OSAL_WAITING ) /* only used by OSAL_NONE in the subtask */ \
ENTRY(TUSB_ERROR_OSAL_TASK_FAILED )\
- ENTRY(TUSB_ERROR_OSAL_TASK_CREATE_FAILED )\
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED )\
ENTRY(TUSB_ERROR_OSAL_SEMAPHORE_FAILED )\
ENTRY(TUSB_ERROR_OSAL_MUTEX_FAILED )\
diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index 4c304a2f8..23b178513 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -139,7 +139,14 @@ typedef struct ATTR_ALIGNED(4) STATIC_ASSERT(sizeof(usbd_task_event_t) <= 12, "size is not correct");
-OSAL_TASK_DEF(usbd_task, 150, TUSB_CFG_OS_TASK_PRIO);
+#ifndef TUC_DEVICE_STACKSIZE
+#define TUC_DEVICE_STACKSIZE 150
+#endif
+
+#ifndef TUSB_CFG_OS_TASK_PRIO
+#define TUSB_CFG_OS_TASK_PRIO 0
+#endif
+
OSAL_QUEUE_DEF(usbd_queue_def, USBD_TASK_QUEUE_DEPTH, usbd_task_event_t);
OSAL_SEM_DEF(usbd_control_xfer_semaphore_def);
@@ -163,7 +170,9 @@ tusb_error_t usbd_init (void) usbd_control_xfer_sem_hdl = osal_semaphore_create( OSAL_SEM_REF(usbd_control_xfer_semaphore_def) );
ASSERT_PTR(usbd_queue_hdl, TUSB_ERROR_OSAL_SEMAPHORE_FAILED);
- ASSERT_STATUS( osal_task_create( OSAL_TASK_REF(usbd_task) ));
+ osal_task_t usbd_hdl;
+ osal_task_create(usbd_task, "usbd", TUC_DEVICE_STACKSIZE, NULL, TUSB_CFG_OS_TASK_PRIO, &usbd_hdl);
+
//------------- Descriptor Check -------------//
ASSERT(tusbd_descriptor_pointers.p_device != NULL && tusbd_descriptor_pointers.p_configuration != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
@@ -183,9 +192,9 @@ tusb_error_t usbd_init (void) // To enable the TASK_ASSERT style (quick return on false condition) in a real RTOS, a task must act as a wrapper
// and is used mainly to call subtasks. Within a subtask return statement can be called freely, the task with
// forever loop cannot have any return at all.
-OSAL_TASK_FUNCTION(usbd_task, p_task_para)
+void usbd_task( void* param)
{
- (void) p_task_para; // suppress compiler warnings
+ (void) param;
OSAL_TASK_LOOP_BEGIN
usbd_body_subtask();
diff --git a/tinyusb/device/usbd.h b/tinyusb/device/usbd.h index 4f79788f0..c2c5c702b 100644 --- a/tinyusb/device/usbd.h +++ b/tinyusb/device/usbd.h @@ -102,7 +102,7 @@ bool tusbd_is_configured(uint8_t coreid) ATTR_WARN_UNUSED_RESULT; extern osal_semaphore_handle_t usbd_control_xfer_sem_hdl;
tusb_error_t usbd_init(void);
-OSAL_TASK_FUNCTION (usbd_task, p_task_para);
+void usbd_task( void* param);
#endif
diff --git a/tinyusb/osal/osal.h b/tinyusb/osal/osal.h index fbc798213..9c136d4d9 100644 --- a/tinyusb/osal/osal.h +++ b/tinyusb/osal/osal.h @@ -56,9 +56,15 @@ /** @} */
#include "tusb_option.h"
+#include "common/common.h"
#ifndef _TEST_
+typedef void (*osal_func_t)(void *param);
+typedef void* osal_task_t;
+
+static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl);
+
#if TUSB_CFG_OS == TUSB_OS_NONE
#include "osal_none.h"
diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h index 26e7743be..a8d6a9a46 100644 --- a/tinyusb/osal/osal_freeRTOS.h +++ b/tinyusb/osal/osal_freeRTOS.h @@ -66,13 +66,6 @@ extern "C" { //--------------------------------------------------------------------+ #define OSAL_TASK_FUNCTION portTASK_FUNCTION -typedef struct { - char const * name; - pdTASK_CODE code; - unsigned portSHORT stack_depth; - unsigned portBASE_TYPE prio; -} osal_task_t; - #define OSAL_TASK_DEF(task_code, task_stack_depth, task_prio) \ osal_task_t osal_task_def_##task_code = {\ .name = #task_code , \ @@ -83,11 +76,9 @@ typedef struct { #define OSAL_TASK_REF(name) (&osal_task_def_##name) -static inline tusb_error_t osal_task_create(osal_task_t *task) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; -static inline tusb_error_t osal_task_create(osal_task_t *task) +static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl) { - return pdPASS == xTaskCreate(task->code, (signed portCHAR const *) task->name, task->stack_depth, NULL, task->prio, NULL) ? - TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TASK_CREATE_FAILED; + return xTaskCreate(code, (const signed char*) name, stack_size, param, prio, task_hdl); } static inline void osal_task_delay(uint32_t msec) ATTR_ALWAYS_INLINE; diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index f927f1707..5701797cc 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -70,8 +70,13 @@ uint32_t tusb_tick_get(void); // }
//--------------------------------------------------------------------+
#define OSAL_TASK_DEF(code, stack_depth, prio)
-#define OSAL_TASK_REF
-#define osal_task_create(x) TUSB_ERROR_NONE
+
+
+static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl)
+{
+ (void) code; (void) name; (void) stack_size; (void) param; (void) prio; (void) task_hdl;
+ return true;
+}
#define OSAL_TASK_FUNCTION(task_func, p_para) tusb_error_t task_func(void * p_para)
@@ -89,7 +94,7 @@ uint32_t tusb_tick_get(void); default:\
TASK_RESTART;\
}}\
- return TUSB_ERROR_NONE;
+ return /*TUSB_ERROR_NONE*/;
#define osal_task_delay(msec) \
|
