diff options
| author | hathach <[email protected]> | 2018-12-13 15:28:04 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-12-13 15:28:04 +0700 |
| commit | 27208ad2fdbd7af5080531eafd9a1a20515cedc1 (patch) | |
| tree | 6869937edf3afe3182665c329343e6a55b99ba59 /src/device | |
| parent | b562fa741b5a8bb47d4e32c0a0f2600b72993b9a (diff) | |
| parent | edf885ca465e16d74833a4866951ca9aa7d4326c (diff) | |
Merge pull request #25 from hathach/devlocal
remove OSAL_TASK_DEF, osal_task_create
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/usbd.c | 60 | ||||
| -rw-r--r-- | src/device/usbd.h | 1 | ||||
| -rw-r--r-- | src/device/usbd_pvt.h | 2 |
3 files changed, 23 insertions, 40 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 8c685d5b3..a3fbfdff9 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -36,8 +36,6 @@ */
/**************************************************************************/
-// This top level class manages the bus state and delegates events to class-specific drivers.
-
#include "tusb_option.h"
#if TUSB_OPT_DEVICE_ENABLED
@@ -52,15 +50,6 @@ #define CFG_TUD_TASK_QUEUE_SZ 16
#endif
-#ifndef CFG_TUD_TASK_STACK_SZ
-#define CFG_TUD_TASK_STACK_SZ 150
-#endif
-
-#ifndef CFG_TUD_TASK_PRIO
-#define CFG_TUD_TASK_PRIO 0
-#endif
-
-
//--------------------------------------------------------------------+
// Device Data
//--------------------------------------------------------------------+
@@ -153,16 +142,14 @@ static usbd_class_driver_t const usbd_class_drivers[] = #endif
};
-enum { USBD_CLASS_DRIVER_COUNT = sizeof(usbd_class_drivers) / sizeof(usbd_class_driver_t) };
-
+enum { USBD_CLASS_DRIVER_COUNT = TU_ARRAY_SZIE(usbd_class_drivers) };
//--------------------------------------------------------------------+
// DCD Event
//--------------------------------------------------------------------+
-OSAL_TASK_DEF(_usbd_task_def, "usbd", usbd_task, CFG_TUD_TASK_PRIO, CFG_TUD_TASK_STACK_SZ);
// Event queue
-// role device/host is used by OS NONE for mutex (disable usb isr) only
+// OPT_MODE_DEVICE is used by OS NONE for mutex (disable usb isr)
OSAL_QUEUE_DEF(OPT_MODE_DEVICE, _usbd_qdef, CFG_TUD_TASK_QUEUE_SZ, dcd_event_t);
static osal_queue_t _usbd_q;
@@ -195,8 +182,6 @@ bool usbd_init (void) _usbd_q = osal_queue_create(&_usbd_qdef);
TU_ASSERT(_usbd_q != NULL);
- osal_task_create(&_usbd_task_def);
-
// Init class drivers
for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++) usbd_class_drivers[i].init();
@@ -221,8 +206,26 @@ static void usbd_reset(uint8_t rhport) }
}
-// Main device task implementation
-static void usbd_task_body(void)
+/* USB Device Driver task
+ * This top level thread manages all device controller event and delegates events to class-specific drivers.
+ * This should be called periodically within the mainloop or rtos thread.
+ *
+ @code
+ int main(void)
+ {
+ application_init();
+ tusb_init();
+
+ while(1) // the mainloop
+ {
+ application_code();
+
+ tud_task(); // tinyusb device task
+ }
+ }
+ @endcode
+ */
+void tud_task (void)
{
// Loop until there is no more events in the queue
while (1)
@@ -297,25 +300,6 @@ static void usbd_task_body(void) }
}
-/* USB device task
- * Thread that handles all device events. With an real RTOS, the task must be a forever loop and never return.
- * For coding convenience with no RTOS, we use wrapped sub-function for processing to easily return at any time.
- */
-void usbd_task( void* param)
-{
- (void) param;
-
-#if CFG_TUSB_OS != OPT_OS_NONE
- while (1) {
-#endif
-
- usbd_task_body();
-
-#if CFG_TUSB_OS != OPT_OS_NONE
- }
-#endif
-}
-
//--------------------------------------------------------------------+
// Control Request Parser & Handling
//--------------------------------------------------------------------+
diff --git a/src/device/usbd.h b/src/device/usbd.h index f9e0d8f4d..f9e7368ce 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -81,6 +81,7 @@ extern tud_desc_set_t tud_desc_set; // APPLICATION API
//--------------------------------------------------------------------+
bool tud_mounted(void);
+void tud_task (void);
//--------------------------------------------------------------------+
// APPLICATION CALLBACK (WEAK is optional)
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index 798a871b1..06951673f 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -52,8 +52,6 @@ extern tud_desc_set_t const* usbd_desc_set; // INTERNAL API for stack management //--------------------------------------------------------------------+ bool usbd_init (void); -void usbd_task (void* param); - // Carry out Data and Status stage of control transfer // - If len = 0, it is equivalent to sending status only |
