diff --git a/demos/device/device_freertos/device_freertos.ewp b/demos/device/device_freertos/device_freertos.ewp
new file mode 100644
index 000000000..ba635a44b
--- /dev/null
+++ b/demos/device/device_freertos/device_freertos.ewp
@@ -0,0 +1,5856 @@
+
+
+
+ 2
+
+ Board EA4357
+
+ ARM
+
+ 1
+
+ General
+ 3
+
+ 21
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ICCARM
+ 2
+
+ 28
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AARM
+ 2
+
+ 8
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OBJCOPY
+ 0
+
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+
+ CUSTOM
+ 3
+
+
+
+
+
+
+ BICOMP
+ 0
+
+
+
+ BUILDACTION
+ 1
+
+
+
+
+
+
+ ILINK
+ 0
+
+ 15
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IARCHIVE
+ 0
+
+ 0
+ 1
+ 1
+
+
+
+
+
+
+ BILINK
+ 0
+
+
+
+
+ Board LPCXpresso1769
+
+ ARM
+
+ 1
+
+ General
+ 3
+
+ 21
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ICCARM
+ 2
+
+ 28
+ 1
+ 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
+
+ AARM
+ 2
+
+ 8
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OBJCOPY
+ 0
+
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+
+ CUSTOM
+ 3
+
+
+
+
+
+
+ BICOMP
+ 0
+
+
+
+ BUILDACTION
+ 1
+
+
+
+
+
+
+ ILINK
+ 0
+
+ 15
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IARCHIVE
+ 0
+
+ 0
+ 1
+ 1
+
+
+
+
+
+
+ BILINK
+ 0
+
+
+
+
+ app
+
+ $PROJ_DIR$\..\src\cdc_device_app.c
+
+
+ $PROJ_DIR$\..\src\keyboard_device_app.c
+
+
+ $PROJ_DIR$\..\src\main.c
+
+
+ $PROJ_DIR$\..\src\mouse_device_app.c
+
+
+ $PROJ_DIR$\..\src\msc_device_app.c
+
+
+ $PROJ_DIR$\..\src\msc_device_ramdisk.c
+
+
+ $PROJ_DIR$\..\src\msc_device_romdisk.c
+
+
+ $PROJ_DIR$\..\src\tusb_descriptors.c
+
+
+
+ boards
+
+ $PROJ_DIR$\..\..\..\boards\board.c
+
+
+ $PROJ_DIR$\..\..\..\boards\embedded_artists\ea4357\board_ea4357.c
+
+
+ $PROJ_DIR$\..\..\..\boards\microbuilder\board_lpc4357usb.c
+
+
+ $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso11u14.c
+
+
+ $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso1347.c
+
+
+ $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso1769.c
+
+
+ $PROJ_DIR$\..\..\..\boards\ngx\board_ngx4330.c
+
+
+ $PROJ_DIR$\..\..\..\boards\microbuilder\board_rf1ghznode.c
+
+
+ $PROJ_DIR$\..\..\..\boards\embedded_artists\oem_base_board\pca9532.c
+
+
+ $PROJ_DIR$\..\..\..\boards\printf_retarget.c
+
+
+
+ freertos
+
+ CM0
+
+ Board EA4357
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\portable\IAR\ARM_CM0\port.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\portable\IAR\ARM_CM0\portasm.s
+
+
+
+ CM3
+
+ Board EA4357
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\portable\IAR\ARM_CM3\port.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\portable\IAR\ARM_CM3\portasm.s
+
+
+
+ CM4F
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\portable\IAR\ARM_CM4F\port.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\portable\IAR\ARM_CM4F\portasm.s
+
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\croutine.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertoslpc\FreeRTOSCommonHooks.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\portable\MemMang\heap_4.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\list.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\queue.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\tasks.c
+
+
+ $PROJ_DIR$\..\..\..\vendor\freertos\freertos\Source\timers.c
+
+
+
+ mcu
+
+ lpc11uxx
+
+ Board EA4357
+ Board LPCXpresso1769
+ Board NGX4330
+ Board LPCXpresso1347
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc11uxx\LPC11Uxx_DriverLib\lpc11uxx_gpio.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc11uxx\LPC11Uxx_DriverLib\lpc11uxx_uart.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc11uxx\iar\startup_lpc11xx.s
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc11uxx\CMSIS_CORE_LPC11Uxx\src\system_LPC11Uxx.c
+
+
+
+ lpc13uxx
+
+ Board EA4357
+ Board LPCXpresso1769
+ Board NGX4330
+ Board rf1ghznode
+ Board LPCXpresso11u14
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc13uxx\LPC13Uxx_DriverLib\src\gpio.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc13uxx\iar\startup_lpc13xx.s
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc13uxx\CMSIS_CORE_LPC13Uxx\src\system_LPC13Uxx.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc13uxx\LPC13Uxx_DriverLib\src\uart.c
+
+
+
+ lpc175x_6x
+
+ Board EA4357
+ Board NGX4330
+ Board rf1ghznode
+ Board LPCXpresso1347
+ Board LPCXpresso11u14
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc175x_6x\LPC17xx_DriverLib\source\lpc17xx_clkpwr.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc175x_6x\LPC17xx_DriverLib\source\lpc17xx_gpio.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc175x_6x\LPC17xx_DriverLib\source\lpc17xx_pinsel.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc175x_6x\LPC17xx_DriverLib\source\lpc17xx_uart.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc175x_6x\iar\startup_LPC17xx.s
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc175x_6x\CMSIS_CORE_LPC17xx\src\system_LPC17xx.c
+
+
+
+ lpc43xx
+
+ Board LPCXpresso1769
+ Board rf1ghznode
+ Board LPCXpresso1347
+ Board LPCXpresso11u14
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_cgu.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_gpio.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_i2c.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_scu.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_uart.c
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc43xx\iar\startup_LPC43xx.s
+
+
+ $PROJ_DIR$\..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\system_LPC43xx.c
+
+
+
+
+ tinyusb
+
+ class
+
+ $PROJ_DIR$\..\..\..\tinyusb\class\cdc_device.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\class\cdc_host.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\class\hid_device.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\class\hid_host.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\class\msc_device.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\class\msc_host.c
+
+
+
+ common
+
+ $PROJ_DIR$\..\..\..\tinyusb\common\fifo.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\common\tusb_errors.c
+
+
+
+ device
+
+ $PROJ_DIR$\..\..\..\tinyusb\device\dcd.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\device\dcd_lpc175x_6x.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\device\dcd_lpc43xx.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\device\dcd_lpc_11uxx_13uxx.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\device\usbd.c
+
+
+
+ hal
+
+ $PROJ_DIR$\..\..\..\tinyusb\hal\hal_lpc11uxx.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\hal\hal_lpc13uxx.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\hal\hal_lpc175x_6x.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\hal\hal_lpc43xx.c
+
+
+
+ host
+
+ $PROJ_DIR$\..\..\..\tinyusb\host\ehci\ehci.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\host\hcd.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\host\hub.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\host\ohci\ohci.c
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\host\usbh.c
+
+
+
+ osal
+
+ $PROJ_DIR$\..\..\..\tinyusb\osal\osal_none.c
+
+
+
+ $PROJ_DIR$\..\..\..\tinyusb\tusb.c
+
+
+
+
+
diff --git a/demos/device/device_freertos/device_freertos.eww b/demos/device/device_freertos/device_freertos.eww
new file mode 100644
index 000000000..3256c3aaf
--- /dev/null
+++ b/demos/device/device_freertos/device_freertos.eww
@@ -0,0 +1,34 @@
+
+
+
+
+ $WS_DIR$\device_freertos.ewp
+
+
+
+ all
+
+ device_freertos
+ Board EA4357
+
+
+ device_freertos
+ Board LPCXpresso1347
+
+
+ device_freertos
+ Board LPCXpresso1769
+
+
+ device_freertos
+ Board NGX4330
+
+
+ device_freertos
+ Board rf1ghznode
+
+
+
+
+
+
diff --git a/demos/device/device_os_none/device_os_none.ewp b/demos/device/device_os_none/device_os_none.ewp
index e4ec10417..1055abe0a 100644
--- a/demos/device/device_os_none/device_os_none.ewp
+++ b/demos/device/device_os_none/device_os_none.ewp
@@ -5562,37 +5562,40 @@
- bsp
-
- boards
-
- $PROJ_DIR$\..\..\..\boards\board.c
-
-
- $PROJ_DIR$\..\..\..\boards\embedded_artists\ea4357\board_ea4357.c
-
-
- $PROJ_DIR$\..\..\..\boards\microbuilder\board_lpc4357usb.c
-
-
- $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso11u14.c
-
-
- $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso1347.c
-
-
- $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso1769.c
-
-
- $PROJ_DIR$\..\..\..\boards\ngx\board_ngx4330.c
-
-
- $PROJ_DIR$\..\..\..\boards\embedded_artists\oem_base_board\pca9532.c
-
-
- $PROJ_DIR$\..\..\..\boards\printf_retarget.c
-
-
+ boards
+
+ $PROJ_DIR$\..\..\..\boards\board.c
+
+
+ $PROJ_DIR$\..\..\..\boards\embedded_artists\ea4357\board_ea4357.c
+
+
+ $PROJ_DIR$\..\..\..\boards\microbuilder\board_lpc4357usb.c
+
+
+ $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso11u14.c
+
+
+ $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso1347.c
+
+
+ $PROJ_DIR$\..\..\..\boards\lpcxpresso\board_lpcxpresso1769.c
+
+
+ $PROJ_DIR$\..\..\..\boards\ngx\board_ngx4330.c
+
+
+ $PROJ_DIR$\..\..\..\boards\microbuilder\board_rf1ghznode.c
+
+
+ $PROJ_DIR$\..\..\..\boards\embedded_artists\oem_base_board\pca9532.c
+
+
+ $PROJ_DIR$\..\..\..\boards\printf_retarget.c
+
+
+
+ mcu
lpc11uxx
@@ -5694,9 +5697,6 @@
$PROJ_DIR$\..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\system_LPC43xx.c
-
- $PROJ_DIR$\..\..\..\boards\microbuilder\board_rf1ghznode.c
-
tinyusb
diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c
index 47c6691b2..ac6a95fad 100644
--- a/tinyusb/device/usbd.c
+++ b/tinyusb/device/usbd.c
@@ -145,6 +145,87 @@ OSAL_SEM_DEF(usbd_control_xfer_semaphore_def);
static osal_queue_handle_t usbd_queue_hdl;
/*static*/ osal_semaphore_handle_t usbd_control_xfer_sem_hdl; // TODO may need to change to static with wrapper function
+//--------------------------------------------------------------------+
+// IMPLEMENTATION
+//--------------------------------------------------------------------+
+tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t const * const p_request);
+static tusb_error_t usbd_body_subtask(void);
+
+tusb_error_t usbd_init (void)
+{
+ ASSERT_STATUS ( dcd_init() );
+
+ //------------- Task init -------------//
+ usbd_queue_hdl = osal_queue_create( OSAL_QUEUE_REF(usbd_queue_def) );
+ ASSERT_PTR(usbd_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
+
+ 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) ));
+
+ //------------- Descriptor Check -------------//
+ ASSERT(tusbd_descriptor_pointers.p_device != NULL && tusbd_descriptor_pointers.p_configuration != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
+
+ //------------- class init -------------//
+ for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
+ {
+ if ( usbd_class_drivers[class_code].init )
+ {
+ usbd_class_drivers[class_code].init();
+ }
+ }
+
+ return TUSB_ERROR_NONE;
+}
+
+// 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) p_task_para; // suppress compiler warnings
+
+ OSAL_TASK_LOOP_BEGIN
+ usbd_body_subtask();
+ OSAL_TASK_LOOP_END
+}
+
+static tusb_error_t usbd_body_subtask(void)
+{
+ OSAL_VAR usbd_task_event_t event;
+
+ OSAL_SUBTASK_BEGIN
+
+ tusb_error_t error;
+ error = TUSB_ERROR_NONE;
+
+ osal_queue_receive(usbd_queue_hdl, &event, OSAL_TIMEOUT_WAIT_FOREVER, &error);
+ SUBTASK_ASSERT_STATUS(error);
+
+ if ( USBD_EVENTID_SETUP_RECEIVED == event.event_id )
+ {
+ OSAL_SUBTASK_INVOKED_AND_WAIT( usbd_control_request_subtask(event.coreid, &event.setup_received), error );
+ }else
+ {
+ uint8_t class_index;
+ class_index = std_class_code_to_index( event.xfer_done.edpt_hdl.class_code );
+
+ if (usbd_class_drivers[class_index].xfer_cb)
+ {
+ usbd_class_drivers[class_index].xfer_cb( event.xfer_done.edpt_hdl, (tusb_event_t) event.sub_event_id, event.xfer_done.xferred_byte);
+ }else
+ {
+ hal_debugger_breakpoint(); // something wrong, no one claims the isr's source
+ }
+ }
+
+ OSAL_SUBTASK_END
+}
+
+//--------------------------------------------------------------------+
+// CONTROL REQUEST
+//--------------------------------------------------------------------+
tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t const * const p_request)
{
OSAL_SUBTASK_BEGIN
@@ -223,71 +304,6 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
OSAL_SUBTASK_END
}
-// 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)
-{
- OSAL_TASK_LOOP_BEGIN
-
- OSAL_VAR usbd_task_event_t event;
- tusb_error_t error;
- error = TUSB_ERROR_NONE;
-
- osal_queue_receive(usbd_queue_hdl, &event, OSAL_TIMEOUT_WAIT_FOREVER, &error);
- SUBTASK_ASSERT_STATUS(error);
-
- if ( USBD_EVENTID_SETUP_RECEIVED == event.event_id )
- {
- OSAL_SUBTASK_INVOKED_AND_WAIT( usbd_control_request_subtask(event.coreid, &event.setup_received), error );
- }else
- {
- uint8_t class_index;
- class_index = std_class_code_to_index( event.xfer_done.edpt_hdl.class_code );
-
- if (usbd_class_drivers[class_index].xfer_cb)
- {
- usbd_class_drivers[class_index].xfer_cb( event.xfer_done.edpt_hdl, (tusb_event_t) event.sub_event_id, event.xfer_done.xferred_byte);
- }else
- {
- hal_debugger_breakpoint(); // something wrong, no one claims the isr's source
- }
- }
-
- OSAL_TASK_LOOP_END
-}
-
-tusb_error_t usbd_init (void)
-{
- ASSERT_STATUS ( dcd_init() );
-
- //------------- Task init -------------//
- usbd_queue_hdl = osal_queue_create( OSAL_QUEUE_REF(usbd_queue_def) );
- ASSERT_PTR(usbd_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
-
- 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) ));
-
- //------------- Descriptor Check -------------//
- ASSERT(tusbd_descriptor_pointers.p_device != NULL && tusbd_descriptor_pointers.p_configuration != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
-
- //------------- class init -------------//
- for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
- {
- if ( usbd_class_drivers[class_code].init )
- {
- usbd_class_drivers[class_code].init();
- }
- }
-
- return TUSB_ERROR_NONE;
-}
-
-//--------------------------------------------------------------------+
-// CONTROL REQUEST
-//--------------------------------------------------------------------+
// TODO Host (windows) can get HID report descriptor before set configured
// may need to open interface before set configured
static tusb_error_t usbd_set_configure_received(uint8_t coreid, uint8_t config_number)