summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-04-13 16:10:42 +0700
committerhathach <[email protected]>2018-04-13 16:10:42 +0700
commite7d7cb222a32f768b47e6e39d92d12ed187a7055 (patch)
tree8d22cd31c42065cbd00598142fd5b26837b6b705 /tinyusb
parenta24615bffcba2272af9d0d75bdefb6a8a6180e89 (diff)
rename CFG_TUSB_OS_TASK_PRIO to CFG_TUD_TASK_PRIO, TUC_DEVICE_STACKSIZE to CFG_TUD_TASK_STACKSIZE
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/device/usbd.c48
-rw-r--r--tinyusb/host/usbh.c6
-rw-r--r--tinyusb/tusb_option.h4
3 files changed, 19 insertions, 39 deletions
diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c
index cb2b1916a..8e7c05222 100644
--- a/tinyusb/device/usbd.c
+++ b/tinyusb/device/usbd.c
@@ -55,7 +55,6 @@ typedef struct {
tusb_error_t (* open)(uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length);
tusb_error_t (* control_request_st) (uint8_t rhport, tusb_control_request_t const *);
tusb_error_t (* xfer_cb) (uint8_t rhport, uint8_t ep_addr, tusb_event_t, uint32_t);
-// void (* routine)(void);
void (* sof)(uint8_t rhport);
void (* close) (uint8_t);
} usbd_class_driver_t;
@@ -87,7 +86,6 @@ static usbd_class_driver_t const usbd_class_drivers[] =
.open = hidd_open,
.control_request_st = hidd_control_request_st,
.xfer_cb = hidd_xfer_cb,
-// .routine = NULL,
.sof = NULL,
.close = hidd_close
},
@@ -100,7 +98,6 @@ static usbd_class_driver_t const usbd_class_drivers[] =
.open = mscd_open,
.control_request_st = mscd_control_request_st,
.xfer_cb = mscd_xfer_cb,
-// .routine = NULL,
.sof = NULL,
.close = mscd_close
},
@@ -113,7 +110,6 @@ static usbd_class_driver_t const usbd_class_drivers[] =
.open = cdcd_open,
.control_request_st = cdcd_control_request_st,
.xfer_cb = cdcd_xfer_cb,
-// .routine = NULL,
.sof = cdcd_sof,
.close = cdcd_close
},
@@ -180,12 +176,12 @@ typedef struct ATTR_ALIGNED(4)
VERIFY_STATIC(sizeof(usbd_task_event_t) <= 12, "size is not correct");
-#ifndef TUC_DEVICE_STACKSIZE
-#define TUC_DEVICE_STACKSIZE 150
+#ifndef CFG_TUD_TASK_STACKSIZE
+#define CFG_TUD_TASK_STACKSIZE 150
#endif
-#ifndef CFG_TUSB_OS_TASK_PRIO
-#define CFG_TUSB_OS_TASK_PRIO 0
+#ifndef CFG_TUD_TASK_PRIO
+#define CFG_TUD_TASK_PRIO 0
#endif
@@ -215,7 +211,7 @@ tusb_error_t usbd_init (void)
_usbd_ctrl_sem = osal_semaphore_create(1, 0);
VERIFY(_usbd_q, TUSB_ERROR_OSAL_SEMAPHORE_FAILED);
- osal_task_create(usbd_task, "usbd", TUC_DEVICE_STACKSIZE, NULL, CFG_TUSB_OS_TASK_PRIO);
+ osal_task_create(usbd_task, "usbd", CFG_TUD_TASK_STACKSIZE, NULL, CFG_TUD_TASK_PRIO);
//------------- Descriptor Check -------------//
TU_ASSERT(tusbd_descriptor_pointers.p_device != NULL && tusbd_descriptor_pointers.p_configuration != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
@@ -250,37 +246,20 @@ static tusb_error_t usbd_main_st(void)
OSAL_SUBTASK_BEGIN
- tusb_error_t error;
- error = TUSB_ERROR_NONE;
+ tusb_error_t err;
+ err = TUSB_ERROR_NONE;
memclr_(&event, sizeof(usbd_task_event_t));
-#if 1
- osal_queue_receive(_usbd_q, &event, OSAL_TIMEOUT_WAIT_FOREVER, &error);
- STASK_ASSERT_ERR(error);
-#else
- enum { ROUTINE_INTERVAL_MS = 10 };
- osal_queue_receive(_usbd_q, &event, ROUTINE_INTERVAL_MS, &error);
- if ( error != TUSB_ERROR_NONE )
- {
- // time out, run class routine then
- if ( error == TUSB_ERROR_OSAL_TIMEOUT)
- {
- for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
- {
- if ( usbd_class_drivers[class_code].routine ) usbd_class_drivers[class_code].routine();
- }
- }
-
- STASK_RETURN(error);
- }
-#endif
+ osal_queue_receive(_usbd_q, &event, OSAL_TIMEOUT_WAIT_FOREVER, &err);
if ( USBD_EVENTID_SETUP_RECEIVED == event.event_id )
{
- STASK_INVOKE( proc_control_request_st(event.rhport, &event.setup_received), error );
- }else if (USBD_EVENTID_XFER_DONE == event.event_id)
+ STASK_INVOKE( proc_control_request_st(event.rhport, &event.setup_received), err );
+ }
+ else if (USBD_EVENTID_XFER_DONE == event.event_id)
{
+ // TODO only call respective interface callback
// Call class handling function. Those doest not own the endpoint should check and return
for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
{
@@ -289,7 +268,8 @@ static tusb_error_t usbd_main_st(void)
usbd_class_drivers[class_code].xfer_cb( event.rhport, event.xfer_done.ep_addr, (tusb_event_t) event.sub_event_id, event.xfer_done.xferred_byte);
}
}
- }else if (USBD_EVENTID_SOF == event.event_id)
+ }
+ else if (USBD_EVENTID_SOF == event.event_id)
{
for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
{
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 73e6835ec..506135b49 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -42,8 +42,8 @@
#define _TINY_USB_SOURCE_FILE_
-#ifndef CFG_TUSB_OS_TASK_PRIO
-#define CFG_TUSB_OS_TASK_PRIO 0
+#ifndef CFG_TUD_TASK_PRIO
+#define CFG_TUD_TASK_PRIO 0
#endif
//--------------------------------------------------------------------+
@@ -150,7 +150,7 @@ tusb_error_t usbh_init(void)
enum_queue_hdl = osal_queue_create( ENUM_QUEUE_DEPTH, sizeof(uint32_t) );
TU_ASSERT(enum_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
- osal_task_create(usbh_enumeration_task, "usbh", 200, NULL, CFG_TUSB_OS_TASK_PRIO);
+ osal_task_create(usbh_enumeration_task, "usbh", 200, NULL, CFG_TUD_TASK_PRIO);
//------------- Semaphore, Mutex for Control Pipe -------------//
for(uint8_t i=0; i<CFG_TUSB_HOST_DEVICE_MAX+1; i++) // including address zero
diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h
index 2777dfbb3..93fd173bb 100644
--- a/tinyusb/tusb_option.h
+++ b/tinyusb/tusb_option.h
@@ -134,8 +134,8 @@
#define CFG_TUSB_OS OPT_OS_NONE
#endif
-#if (CFG_TUSB_OS != OPT_OS_NONE) && !defined (CFG_TUSB_OS_TASK_PRIO)
- #error CFG_TUSB_OS_TASK_PRIO need to be defined (hint: use the highest if possible)
+#if (CFG_TUSB_OS != OPT_OS_NONE) && !defined (CFG_TUD_TASK_PRIO)
+ #error CFG_TUD_TASK_PRIO need to be defined (hint: use the highest if possible)
#endif
//#ifndef CFG_TUSB_CONFIGURATION_MAX