Просмотр исходного кода

make freertos source unmodified to ease the upgrade process later
use CGU_GetPCLKFrequency as configCPU_CLOCK_HZ for lpc43xx using with freeRTOS
move portmarco.h include to FreeRTOSConfig.h to have untouched version of freertos
add a readme.md to vendor/freertos
refractor usbh.c, increase POWER_STABLE_DELAY = 500, RESET_DELAY = 200
fix bug with hub, only handle 1 port at a time when reading hub status change endpoint --> other port will be handled in the next cycle

hathach 12 лет назад
Родитель
Сommit
05c767313d

+ 2 - 2
demos/device/device_cmsis_rtx/device_cmsis_rtx.uvopt

@@ -895,7 +895,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>0</ColumnNumber>
       <ColumnNumber>0</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>88</TopLine>
+      <TopLine>90</TopLine>
       <CurrentLine>93</CurrentLine>
       <CurrentLine>93</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\src\main.c</PathWithFileName>
       <PathWithFileName>..\src\main.c</PathWithFileName>
@@ -1951,7 +1951,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>0</ColumnNumber>
       <ColumnNumber>0</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>147</TopLine>
+      <TopLine>149</TopLine>
       <CurrentLine>151</CurrentLine>
       <CurrentLine>151</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>

+ 7 - 7
demos/device/device_freertos/device_freertos.uvopt

@@ -73,7 +73,7 @@
       <OPTFL>
       <OPTFL>
         <tvExp>1</tvExp>
         <tvExp>1</tvExp>
         <tvExpOptDlg>0</tvExpOptDlg>
         <tvExpOptDlg>0</tvExpOptDlg>
-        <IsCurrentTarget>0</IsCurrentTarget>
+        <IsCurrentTarget>1</IsCurrentTarget>
       </OPTFL>
       </OPTFL>
       <CpuCode>8</CpuCode>
       <CpuCode>8</CpuCode>
       <DllOpt>
       <DllOpt>
@@ -679,7 +679,7 @@
       <OPTFL>
       <OPTFL>
         <tvExp>1</tvExp>
         <tvExp>1</tvExp>
         <tvExpOptDlg>0</tvExpOptDlg>
         <tvExpOptDlg>0</tvExpOptDlg>
-        <IsCurrentTarget>1</IsCurrentTarget>
+        <IsCurrentTarget>0</IsCurrentTarget>
       </OPTFL>
       </OPTFL>
       <CpuCode>8</CpuCode>
       <CpuCode>8</CpuCode>
       <DllOpt>
       <DllOpt>
@@ -937,7 +937,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>15</ColumnNumber>
       <ColumnNumber>15</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>69</TopLine>
+      <TopLine>77</TopLine>
       <CurrentLine>86</CurrentLine>
       <CurrentLine>86</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\src\main.c</PathWithFileName>
       <PathWithFileName>..\src\main.c</PathWithFileName>
@@ -1449,7 +1449,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>27</ColumnNumber>
       <ColumnNumber>27</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>58</TopLine>
+      <TopLine>61</TopLine>
       <CurrentLine>64</CurrentLine>
       <CurrentLine>64</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\boards\board.c</PathWithFileName>
       <PathWithFileName>..\..\..\boards\board.c</PathWithFileName>
@@ -1993,7 +1993,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>0</ColumnNumber>
       <ColumnNumber>0</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>139</TopLine>
+      <TopLine>147</TopLine>
       <CurrentLine>156</CurrentLine>
       <CurrentLine>156</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>
@@ -2063,10 +2063,10 @@
       <FileType>1</FileType>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExp>0</tvExp>
       <Focus>0</Focus>
       <Focus>0</Focus>
-      <ColumnNumber>0</ColumnNumber>
+      <ColumnNumber>45</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
       <TopLine>1654</TopLine>
       <TopLine>1654</TopLine>
-      <CurrentLine>1665</CurrentLine>
+      <CurrentLine>1662</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\vendor\freertos\freertos\Source\tasks.c</PathWithFileName>
       <PathWithFileName>..\..\..\vendor\freertos\freertos\Source\tasks.c</PathWithFileName>
       <FilenameWithoutPath>tasks.c</FilenameWithoutPath>
       <FilenameWithoutPath>tasks.c</FilenameWithoutPath>

+ 3 - 3
demos/device/device_os_none/device_os_none.uvopt

@@ -1004,7 +1004,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>1</ColumnNumber>
       <ColumnNumber>1</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>105</TopLine>
+      <TopLine>106</TopLine>
       <CurrentLine>112</CurrentLine>
       <CurrentLine>112</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\src\keyboard_device_app.c</PathWithFileName>
       <PathWithFileName>..\src\keyboard_device_app.c</PathWithFileName>
@@ -1092,7 +1092,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>6</ColumnNumber>
       <ColumnNumber>6</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>56</TopLine>
+      <TopLine>57</TopLine>
       <CurrentLine>61</CurrentLine>
       <CurrentLine>61</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\tinyusb\tusb.c</PathWithFileName>
       <PathWithFileName>..\..\..\tinyusb\tusb.c</PathWithFileName>
@@ -1396,7 +1396,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>47</ColumnNumber>
       <ColumnNumber>47</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>417</TopLine>
+      <TopLine>420</TopLine>
       <CurrentLine>427</CurrentLine>
       <CurrentLine>427</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\tinyusb\device\usbd.c</PathWithFileName>
       <PathWithFileName>..\..\..\tinyusb\device\usbd.c</PathWithFileName>

+ 3 - 3
demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt

@@ -638,10 +638,10 @@
       <FileType>1</FileType>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExp>0</tvExp>
       <Focus>0</Focus>
       <Focus>0</Focus>
-      <ColumnNumber>27</ColumnNumber>
+      <ColumnNumber>0</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
       <TopLine>97</TopLine>
       <TopLine>97</TopLine>
-      <CurrentLine>98</CurrentLine>
+      <CurrentLine>102</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\src\main.c</PathWithFileName>
       <PathWithFileName>..\src\main.c</PathWithFileName>
       <FilenameWithoutPath>main.c</FilenameWithoutPath>
       <FilenameWithoutPath>main.c</FilenameWithoutPath>
@@ -1528,7 +1528,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>0</ColumnNumber>
       <ColumnNumber>0</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>147</TopLine>
+      <TopLine>149</TopLine>
       <CurrentLine>151</CurrentLine>
       <CurrentLine>151</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>

+ 7 - 7
demos/host/host_freertos/host_freertos.uvopt

@@ -71,9 +71,9 @@
         <LExpSel>0</LExpSel>
         <LExpSel>0</LExpSel>
       </OPTXL>
       </OPTXL>
       <OPTFL>
       <OPTFL>
-        <tvExp>0</tvExp>
+        <tvExp>1</tvExp>
         <tvExpOptDlg>0</tvExpOptDlg>
         <tvExpOptDlg>0</tvExpOptDlg>
-        <IsCurrentTarget>0</IsCurrentTarget>
+        <IsCurrentTarget>1</IsCurrentTarget>
       </OPTFL>
       </OPTFL>
       <CpuCode>8</CpuCode>
       <CpuCode>8</CpuCode>
       <DllOpt>
       <DllOpt>
@@ -506,7 +506,7 @@
       <OPTFL>
       <OPTFL>
         <tvExp>1</tvExp>
         <tvExp>1</tvExp>
         <tvExpOptDlg>0</tvExpOptDlg>
         <tvExpOptDlg>0</tvExpOptDlg>
-        <IsCurrentTarget>1</IsCurrentTarget>
+        <IsCurrentTarget>0</IsCurrentTarget>
       </OPTFL>
       </OPTFL>
       <CpuCode>8</CpuCode>
       <CpuCode>8</CpuCode>
       <DllOpt>
       <DllOpt>
@@ -606,10 +606,10 @@
       <FileType>1</FileType>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExp>0</tvExp>
       <Focus>0</Focus>
       <Focus>0</Focus>
-      <ColumnNumber>0</ColumnNumber>
+      <ColumnNumber>18</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>97</TopLine>
-      <CurrentLine>102</CurrentLine>
+      <TopLine>101</TopLine>
+      <CurrentLine>118</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\src\main.c</PathWithFileName>
       <PathWithFileName>..\src\main.c</PathWithFileName>
       <FilenameWithoutPath>main.c</FilenameWithoutPath>
       <FilenameWithoutPath>main.c</FilenameWithoutPath>
@@ -1416,7 +1416,7 @@
       <Focus>0</Focus>
       <Focus>0</Focus>
       <ColumnNumber>0</ColumnNumber>
       <ColumnNumber>0</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>152</TopLine>
+      <TopLine>153</TopLine>
       <CurrentLine>154</CurrentLine>
       <CurrentLine>154</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>

+ 34 - 12
demos/host/host_os_none/host_os_none.uvopt

@@ -120,6 +120,21 @@
         <pMon>Segger\JL2CM3.dll</pMon>
         <pMon>Segger\JL2CM3.dll</pMon>
       </DebugOpt>
       </DebugOpt>
       <TargetDriverDllRegistry>
       <TargetDriverDllRegistry>
+        <SetRegEntry>
+          <Number>0</Number>
+          <Key>DLGTARM</Key>
+          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)</Name>
+        </SetRegEntry>
+        <SetRegEntry>
+          <Number>0</Number>
+          <Key>ARMDBGFLAGS</Key>
+          <Name></Name>
+        </SetRegEntry>
+        <SetRegEntry>
+          <Number>0</Number>
+          <Key>DLGUARM</Key>
+          <Name></Name>
+        </SetRegEntry>
         <SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
           <Number>0</Number>
           <Key>JL2CM3</Key>
           <Key>JL2CM3</Key>
@@ -127,15 +142,22 @@
         </SetRegEntry>
         </SetRegEntry>
       </TargetDriverDllRegistry>
       </TargetDriverDllRegistry>
       <Breakpoint/>
       <Breakpoint/>
+      <WatchWindow1>
+        <Ww>
+          <count>0</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>usbh_devices</ItemText>
+        </Ww>
+      </WatchWindow1>
       <DebugFlag>
       <DebugFlag>
         <trace>0</trace>
         <trace>0</trace>
         <periodic>0</periodic>
         <periodic>0</periodic>
-        <aLwin>0</aLwin>
+        <aLwin>1</aLwin>
         <aCover>0</aCover>
         <aCover>0</aCover>
         <aSer1>0</aSer1>
         <aSer1>0</aSer1>
         <aSer2>0</aSer2>
         <aSer2>0</aSer2>
         <aPa>0</aPa>
         <aPa>0</aPa>
-        <viewmode>0</viewmode>
+        <viewmode>1</viewmode>
         <vrSel>0</vrSel>
         <vrSel>0</vrSel>
         <aSym>0</aSym>
         <aSym>0</aSym>
         <aTbox>0</aTbox>
         <aTbox>0</aTbox>
@@ -147,7 +169,7 @@
         <aLa>0</aLa>
         <aLa>0</aLa>
         <aPa1>0</aPa1>
         <aPa1>0</aPa1>
         <AscS4>0</AscS4>
         <AscS4>0</AscS4>
-        <aSer4>0</aSer4>
+        <aSer4>1</aSer4>
         <StkLoc>0</StkLoc>
         <StkLoc>0</StkLoc>
         <TrcWin>0</TrcWin>
         <TrcWin>0</TrcWin>
         <newCpu>0</newCpu>
         <newCpu>0</newCpu>
@@ -678,7 +700,7 @@
       <ColumnNumber>0</ColumnNumber>
       <ColumnNumber>0</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
       <TopLine>151</TopLine>
       <TopLine>151</TopLine>
-      <CurrentLine>159</CurrentLine>
+      <CurrentLine>152</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\src\msc_host_app.c</PathWithFileName>
       <PathWithFileName>..\src\msc_host_app.c</PathWithFileName>
       <FilenameWithoutPath>msc_host_app.c</FilenameWithoutPath>
       <FilenameWithoutPath>msc_host_app.c</FilenameWithoutPath>
@@ -779,10 +801,10 @@
       <FileType>1</FileType>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExp>0</tvExp>
       <Focus>0</Focus>
       <Focus>0</Focus>
-      <ColumnNumber>0</ColumnNumber>
+      <ColumnNumber>18</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>1</TopLine>
-      <CurrentLine>1</CurrentLine>
+      <TopLine>202</TopLine>
+      <CurrentLine>214</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
       <PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
       <FilenameWithoutPath>usbh.c</FilenameWithoutPath>
       <FilenameWithoutPath>usbh.c</FilenameWithoutPath>
@@ -1139,9 +1161,9 @@
       <FileType>1</FileType>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExp>0</tvExp>
       <Focus>0</Focus>
       <Focus>0</Focus>
-      <ColumnNumber>38</ColumnNumber>
+      <ColumnNumber>63</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>1690</TopLine>
+      <TopLine>1703</TopLine>
       <CurrentLine>1709</CurrentLine>
       <CurrentLine>1709</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\vendor\fatfs\ff.c</PathWithFileName>
       <PathWithFileName>..\..\..\vendor\fatfs\ff.c</PathWithFileName>
@@ -1347,10 +1369,10 @@
       <FileType>2</FileType>
       <FileType>2</FileType>
       <tvExp>0</tvExp>
       <tvExp>0</tvExp>
       <Focus>0</Focus>
       <Focus>0</Focus>
-      <ColumnNumber>0</ColumnNumber>
+      <ColumnNumber>20</ColumnNumber>
       <tvExpOptDlg>0</tvExpOptDlg>
       <tvExpOptDlg>0</tvExpOptDlg>
-      <TopLine>148</TopLine>
-      <CurrentLine>151</CurrentLine>
+      <TopLine>145</TopLine>
+      <CurrentLine>162</CurrentLine>
       <bDave2>0</bDave2>
       <bDave2>0</bDave2>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>
       <PathWithFileName>..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s</PathWithFileName>
       <FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>
       <FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>

+ 2 - 2
tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c

@@ -67,8 +67,8 @@ void semaphore_wait_success_stub(osal_semaphore_handle_t const sem_hdl, uint32_t
 tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_control_request_t * const p_request, uint8_t data[], int num_call);
 tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_control_request_t * const p_request, uint8_t data[], int num_call);
 
 
 enum {
 enum {
-  POWER_STABLE_DELAY = 300,
-  RESET_DELAY = 100 // NXP's EHCI require more than 50ms to work properly although the USB specs say only 50ms
+  POWER_STABLE_DELAY = 500,
+  RESET_DELAY = 200 // USB specs say only 50ms though many devices requires a longer time
 };
 };
 
 
 void setUp(void)
 void setUp(void)

+ 1 - 0
tinyusb/hal/hal_lpc43xx.h

@@ -40,6 +40,7 @@
 #define _TUSB_HAL_LPC43XX_H_
 #define _TUSB_HAL_LPC43XX_H_
 
 
 #include "LPC43xx.h"
 #include "LPC43xx.h"
+#include "lpc43xx_cgu.h"
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
  extern "C" {
  extern "C" {

+ 3 - 1
tinyusb/host/hub.c

@@ -105,6 +105,7 @@ tusb_error_t hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port,
 
 
 tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port)
 tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port)
 {
 {
+  enum { RESET_DELAY = 200 }; // USB specs say only 50ms but many devices require much longer
   tusb_error_t error;
   tusb_error_t error;
 
 
   OSAL_SUBTASK_BEGIN
   OSAL_SUBTASK_BEGIN
@@ -118,7 +119,7 @@ tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port)
   );
   );
   SUBTASK_ASSERT_STATUS( error );
   SUBTASK_ASSERT_STATUS( error );
 
 
-  osal_task_delay(50); // TODO Hub wait for Status Endpoint on Reset Change
+  osal_task_delay(RESET_DELAY); // TODO Hub wait for Status Endpoint on Reset Change
 
 
   //------------- Get Port Status to check if port is enabled, powered and reset_change -------------//
   //------------- Get Port Status to check if port is enabled, powered and reset_change -------------//
   OSAL_SUBTASK_INVOKED_AND_WAIT(
   OSAL_SUBTASK_INVOKED_AND_WAIT(
@@ -221,6 +222,7 @@ void hub_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes)
       if ( BIT_TEST_(p_hub->status_change, port) )
       if ( BIT_TEST_(p_hub->status_change, port) )
       {
       {
         usbh_hub_port_plugged_isr(pipe_hdl.dev_addr, port);
         usbh_hub_port_plugged_isr(pipe_hdl.dev_addr, port);
+        break; // handle one port at a time, next port if any will be handled in the next cycle
       }
       }
     }
     }
     // NOTE: next status transfer is queued by usbh.c after handling this request
     // NOTE: next status transfer is queued by usbh.c after handling this request

+ 6 - 9
tinyusb/host/usbh.c

@@ -199,14 +199,11 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType,
   usbh_devices[dev_addr].control.pipe_status = TUSB_EVENT_XFER_COMPLETE; // in Test project, mark as complete immediately
   usbh_devices[dev_addr].control.pipe_status = TUSB_EVENT_XFER_COMPLETE; // in Test project, mark as complete immediately
 #endif
 #endif
 
 
-  SUBTASK_ASSERT_STATUS_WITH_HANDLER( hcd_pipe_control_xfer(dev_addr, &usbh_devices[dev_addr].control.request, data),
-                                      osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl) );
-
-  osal_semaphore_wait(usbh_devices[dev_addr].control.sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
+  error = hcd_pipe_control_xfer(dev_addr, &usbh_devices[dev_addr].control.request, data);
+  if ( TUSB_ERROR_NONE == error ) osal_semaphore_wait(usbh_devices[dev_addr].control.sem_hdl, OSAL_TIMEOUT_NORMAL, &error);
   osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl);
   osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl);
 
 
-  // TODO make handler for this function general purpose
-  if (TUSB_ERROR_NONE != error)   SUBTASK_EXIT(error);
+  SUBTASK_ASSERT_STATUS(error);
   if (TUSB_EVENT_XFER_STALLED == usbh_devices[dev_addr].control.pipe_status) SUBTASK_EXIT(TUSB_ERROR_USBH_XFER_STALLED);
   if (TUSB_EVENT_XFER_STALLED == usbh_devices[dev_addr].control.pipe_status) SUBTASK_EXIT(TUSB_ERROR_USBH_XFER_STALLED);
   if (TUSB_EVENT_XFER_ERROR   == usbh_devices[dev_addr].control.pipe_status) SUBTASK_EXIT(TUSB_ERROR_USBH_XFER_FAILED);
   if (TUSB_EVENT_XFER_ERROR   == usbh_devices[dev_addr].control.pipe_status) SUBTASK_EXIT(TUSB_ERROR_USBH_XFER_FAILED);
 
 
@@ -259,7 +256,7 @@ void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t even
     usbh_class_drivers[class_index].isr(pipe_hdl, event, xferred_bytes);
     usbh_class_drivers[class_index].isr(pipe_hdl, event, xferred_bytes);
   }else
   }else
   {
   {
-    ASSERT(false, VOID_RETURN); // something wrong, no one claims the isr's source
+    ASSERT_FAILED(VOID_RETURN); // something wrong, no one claims the isr's source
   }
   }
 }
 }
 
 
@@ -361,8 +358,8 @@ OSAL_TASK_FUNCTION(usbh_enumeration_task, p_task_para)
 tusb_error_t enumeration_body_subtask(void)
 tusb_error_t enumeration_body_subtask(void)
 {
 {
   enum {
   enum {
-    POWER_STABLE_DELAY = 300,
-    RESET_DELAY = 100 // NXP's EHCI require more than 50ms to work properly although the USB specs say only 50ms
+    POWER_STABLE_DELAY = 500,
+    RESET_DELAY        = 200 // USB specs say only 50ms but many devices require much longer
   };
   };
 
 
   tusb_error_t error;
   tusb_error_t error;

+ 24 - 7
vendor/freertos/FreeRTOSConfig.h

@@ -10,9 +10,13 @@
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 // See http://www.freertos.org/a00110.html.
 // See http://www.freertos.org/a00110.html.
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
+#if TUSB_CFG_MCU == MCU_LPC43XX
+  #define configCPU_CLOCK_HZ                   CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)
+#else
+  #define configCPU_CLOCK_HZ                   SystemCoreClock
+#endif
+
 #define configUSE_PREEMPTION                   1
 #define configUSE_PREEMPTION                   1
-#define configCPU_CLOCK_HZ                     ( SystemCoreClock )
-//#define configCPU_CLOCK_HZ                   ( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE))
 #define configTICK_RATE_HZ                     ( ( portTickType ) 1000 )
 #define configTICK_RATE_HZ                     ( ( portTickType ) 1000 )
 #define configMAX_PRIORITIES                   ( ( unsigned portBASE_TYPE ) 8 )
 #define configMAX_PRIORITIES                   ( ( unsigned portBASE_TYPE ) 8 )
 #define configMINIMAL_STACK_SIZE               ( ( unsigned short ) 128 )
 #define configMINIMAL_STACK_SIZE               ( ( unsigned short ) 128 )
@@ -100,16 +104,29 @@ to all Cortex-M ports, and do not rely on any particular library functions. */
 See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 #define configMAX_SYSCALL_INTERRUPT_PRIORITY 	        ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
 #define configMAX_SYSCALL_INTERRUPT_PRIORITY 	        ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
 
 
-#if 0
-#if __CORTEX_M == 4
+//--------------------------------------------------------------------+
+// portmacro.h include path
+//--------------------------------------------------------------------+
+#if defined __CC_ARM
+  #define TOOL_DIR  RVDS
+#elif defined __GNUC__
+  #define TOOL_DIR  GCC
+#elif defined __ICCARM__
+  #define TOOL_DIR  IAR
+#else
+  #error "not yet supported toolchain"
+#endif
 
 
+#if __CORTEX_M == 4
+  #define ARCH_DIR  ARM_CM4F
 #elif __CORTEX_M == 3
 #elif __CORTEX_M == 3
-
+  #define ARCH_DIR  ARM_CM3
 #elif __CORTEX_M == 0
 #elif __CORTEX_M == 0
-
+  #define ARCH_DIR  ARM_CM0
 #else
 #else
 	#error "not yet supported MCU"
 	#error "not yet supported MCU"
 #endif
 #endif
-#endif
+
+#include XSTRING_(freertos/Source/portable/TOOL_DIR/ARCH_DIR/portmacro.h)
 
 
 #endif /* __FREERTOS_CONFIG__H */
 #endif /* __FREERTOS_CONFIG__H */

+ 0 - 38
vendor/freertos/freertos/Source/include/portable.h

@@ -70,44 +70,6 @@
 #ifndef PORTABLE_H
 #ifndef PORTABLE_H
 #define PORTABLE_H
 #define PORTABLE_H
 
 
-//--------------------------------------------------------------------+
-// TinyUSB modification
-//--------------------------------------------------------------------+
-#if defined __CC_ARM
-  #if __CORTEX_M == 4 // TODO M0 M4
-    #define PORTMACRO_PATH "../portable/RVDS/ARM_CM4F/portmacro.h"
-  #elif __CORTEX_M == 3
-    #define PORTMACRO_PATH "../portable/RVDS/ARM_CM3/portmacro.h"
-  #elif __CORTEX_M == 0
-    #define PORTMACRO_PATH "../portable/RVDS/ARM_CM0/portmacro.h"
-  #endif
-
-#elif defined __GNUC__
-  #if __CORTEX_M == 4
-    #define PORTMACRO_PATH "../portable/GCC/ARM_CM4F/portmacro.h"
-  #elif __CORTEX_M == 3
-    #define PORTMACRO_PATH "../portable/GCC/ARM_CM3/portmacro.h"
-  #elif __CORTEX_M == 0
-    #define PORTMACRO_PATH "../portable/GCC/ARM_CM0/portmacro.h"
-  #endif
-
-#elif defined __ICCARM__
-  #if __CORTEX_M == 4
-    #define PORTMACRO_PATH "../portable/IAR/ARM_CM4F/portmacro.h"
-  #elif __CORTEX_M == 3
-    #define PORTMACRO_PATH "../portable/IAR/ARM_CM3/portmacro.h"
-  #elif __CORTEX_M == 0
-    #define PORTMACRO_PATH "../portable/IAR/ARM_CM0/portmacro.h"
-  #endif
-
-#endif
-
-#ifndef PORTMACRO_PATH
-  #error portmacro.h path is not defined for this toolchain and/or MCU
-#endif
-
-#include PORTMACRO_PATH
-
 /* Include the macro file relevant to the port being used. */
 /* Include the macro file relevant to the port being used. */
 
 
 #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT
 #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT

+ 4 - 0
vendor/freertos/readme.md

@@ -0,0 +1,4 @@
+This folder contains 
+- **FreeRTOSConfig.h** configuration file for freeRTOS
+- **freertos_hook.c** implemenation of freeRTOS to application hooks
+- **freertos** an *unmodified copy* of the popular open source FreeRTOS. This will help to ease the upgrade to later version. However, due to Keil unable to have duplicated filenames, I have to change the name of port.c in freertos/Source/portable/RVDS for example ARM_CM3/port.c to ARM_CM3/port_cm3.c to have ability to support/switch among different mcu in one project.