فهرست منبع

clean up osal task and subtask

hathach 7 سال پیش
والد
کامیت
4ef01d721a
3فایلهای تغییر یافته به همراه18 افزوده شده و 20 حذف شده
  1. 6 3
      src/device/usbd.c
  2. 3 1
      src/osal/osal.h
  3. 9 16
      src/osal/osal_none.h

+ 6 - 3
src/device/usbd.c

@@ -107,7 +107,7 @@ static usbd_class_driver_t const usbd_class_drivers[] =
         .open           = cdcd_open,
         .control_req_st = cdcd_control_request_st,
         .xfer_cb        = cdcd_xfer_cb,
-        .sof            = cdcd_sof,
+        .sof            = NULL,
         .reset          = cdcd_reset
     },
   #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
 // 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.
+
+// 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) param;
@@ -306,7 +309,7 @@ static tusb_error_t usbd_main_st(void)
     }
     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:
     {
-      #if CFG_TUD_CDC_FLUSH_ON_SOF
+      #if 0
       usbd_task_event_t task_event =
       {
           .rhport          = rhport,

+ 3 - 1
src/osal/osal.h

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

+ 9 - 16
src/osal/osal_none.h

@@ -79,18 +79,6 @@ static inline osal_task_t osal_task_create(osal_task_def_t* taskdef)
 #define TASK_RESTART                             \
   _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)                    \
   do {                                           \
     _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
 //--------------------------------------------------------------------+
-#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                                                        \
-  default: TASK_RESTART; break;                                                 \
-  }}                                                                            \
+#define OSAL_SUBTASK_END                         \
+  default: TASK_RESTART; break;                  \
+  }}                                             \
   return TUSB_ERROR_NONE;
 
 #define STASK_INVOKE(_subtask, _status)                                         \