clean up osal task and subtask

This commit is contained in:
hathach 2018-08-30 15:21:15 +07:00
parent 61e4a8c3d3
commit 4ef01d721a
3 changed files with 18 additions and 20 deletions

View File

@ -107,7 +107,7 @@ static usbd_class_driver_t const usbd_class_drivers[] =
.open = cdcd_open, .open = cdcd_open,
.control_req_st = cdcd_control_request_st, .control_req_st = cdcd_control_request_st,
.xfer_cb = cdcd_xfer_cb, .xfer_cb = cdcd_xfer_cb,
.sof = cdcd_sof, .sof = NULL,
.reset = cdcd_reset .reset = cdcd_reset
}, },
#endif #endif
@ -250,6 +250,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 // 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 // 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. // forever loop cannot have any return at all.
// Within tinyusb stack, all task's code must be placed in subtask to be able to support multiple RTOS
// including none.
void usbd_task( void* param) void usbd_task( void* param)
{ {
(void) param; (void) param;
@ -306,7 +309,7 @@ static tusb_error_t usbd_main_st(void)
} }
else else
{ {
STASK_ASSERT(false); verify_breakpoint();
} }
} }
@ -577,7 +580,7 @@ void dcd_bus_event(uint8_t rhport, usbd_bus_event_type_t bus_event)
case USBD_BUS_EVENT_SOF: case USBD_BUS_EVENT_SOF:
{ {
#if CFG_TUD_CDC_FLUSH_ON_SOF #if 0
usbd_task_event_t task_event = usbd_task_event_t task_event =
{ {
.rhport = rhport, .rhport = rhport,

View File

@ -61,8 +61,10 @@ enum
typedef void (*osal_task_func_t)( void * ); typedef void (*osal_task_func_t)( void * );
#if CFG_TUSB_OS == OPT_OS_NONE #if CFG_TUSB_OS == OPT_OS_NONE
#include "osal_none.h" #define OSAL_TASK_BEGIN
#define OSAL_TASK_END
#include "osal_none.h"
#else #else
#if CFG_TUSB_OS == OPT_OS_FREERTOS #if CFG_TUSB_OS == OPT_OS_FREERTOS
#include "osal_freeRTOS.h" #include "osal_freeRTOS.h"

View File

@ -79,18 +79,6 @@ static inline osal_task_t osal_task_create(osal_task_def_t* taskdef)
#define TASK_RESTART \ #define TASK_RESTART \
_state = 0 _state = 0
#define OSAL_TASK_BEGIN \
static uint16_t _state = 0; \
ATTR_UNUSED static uint32_t _timeout = 0; \
(void) _timeout; \
switch(_state) { \
case 0: {
#define OSAL_TASK_END \
default: TASK_RESTART; break; \
}} \
return;
#define osal_task_delay(msec) \ #define osal_task_delay(msec) \
do { \ do { \
_timeout = tusb_hal_millis(); \ _timeout = tusb_hal_millis(); \
@ -102,11 +90,16 @@ static inline osal_task_t osal_task_create(osal_task_def_t* taskdef)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// SUBTASK (a sub function that uses OS blocking services & called by a task // SUBTASK (a sub function that uses OS blocking services & called by a task
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define OSAL_SUBTASK_BEGIN OSAL_TASK_BEGIN #define OSAL_SUBTASK_BEGIN \
static uint16_t _state = 0; \
ATTR_UNUSED static uint32_t _timeout = 0; \
(void) _timeout; \
switch(_state) { \
case 0: {
#define OSAL_SUBTASK_END \ #define OSAL_SUBTASK_END \
default: TASK_RESTART; break; \ default: TASK_RESTART; break; \
}} \ }} \
return TUSB_ERROR_NONE; return TUSB_ERROR_NONE;
#define STASK_INVOKE(_subtask, _status) \ #define STASK_INVOKE(_subtask, _status) \