diff --git a/demos/device/device_cmsis_rtx/device_cmsis_rtx.uvopt b/demos/device/device_cmsis_rtx/device_cmsis_rtx.uvopt
index fc0d0fa7..d5a45052 100644
--- a/demos/device/device_cmsis_rtx/device_cmsis_rtx.uvopt
+++ b/demos/device/device_cmsis_rtx/device_cmsis_rtx.uvopt
@@ -895,7 +895,7 @@
0
0
0
- 88
+ 90
93
0
..\src\main.c
@@ -1951,7 +1951,7 @@
0
0
0
- 147
+ 149
151
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
diff --git a/demos/device/device_freertos/device_freertos.uvopt b/demos/device/device_freertos/device_freertos.uvopt
index 4e4bffc6..8a2e4991 100644
--- a/demos/device/device_freertos/device_freertos.uvopt
+++ b/demos/device/device_freertos/device_freertos.uvopt
@@ -73,7 +73,7 @@
1
0
- 0
+ 1
8
@@ -679,7 +679,7 @@
1
0
- 1
+ 0
8
@@ -937,7 +937,7 @@
0
15
0
- 69
+ 77
86
0
..\src\main.c
@@ -1449,7 +1449,7 @@
0
27
0
- 58
+ 61
64
0
..\..\..\boards\board.c
@@ -1993,7 +1993,7 @@
0
0
0
- 139
+ 147
156
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
@@ -2063,10 +2063,10 @@
1
0
0
- 0
+ 45
0
1654
- 1665
+ 1662
0
..\..\..\vendor\freertos\freertos\Source\tasks.c
tasks.c
diff --git a/demos/device/device_os_none/device_os_none.uvopt b/demos/device/device_os_none/device_os_none.uvopt
index a6987626..d33f2605 100644
--- a/demos/device/device_os_none/device_os_none.uvopt
+++ b/demos/device/device_os_none/device_os_none.uvopt
@@ -1004,7 +1004,7 @@
0
1
0
- 105
+ 106
112
0
..\src\keyboard_device_app.c
@@ -1092,7 +1092,7 @@
0
6
0
- 56
+ 57
61
0
..\..\..\tinyusb\tusb.c
@@ -1396,7 +1396,7 @@
0
47
0
- 417
+ 420
427
0
..\..\..\tinyusb\device\usbd.c
diff --git a/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt b/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
index f6e54ac5..a22f7906 100644
--- a/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
+++ b/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
@@ -638,10 +638,10 @@
1
0
0
- 27
+ 0
0
97
- 98
+ 102
0
..\src\main.c
main.c
@@ -1528,7 +1528,7 @@
0
0
0
- 147
+ 149
151
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
diff --git a/demos/host/host_freertos/host_freertos.uvopt b/demos/host/host_freertos/host_freertos.uvopt
index 828de825..1f80f8ae 100644
--- a/demos/host/host_freertos/host_freertos.uvopt
+++ b/demos/host/host_freertos/host_freertos.uvopt
@@ -71,9 +71,9 @@
0
- 0
+ 1
0
- 0
+ 1
8
@@ -506,7 +506,7 @@
1
0
- 1
+ 0
8
@@ -606,10 +606,10 @@
1
0
0
- 0
+ 18
0
- 97
- 102
+ 101
+ 118
0
..\src\main.c
main.c
@@ -1416,7 +1416,7 @@
0
0
0
- 152
+ 153
154
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
diff --git a/demos/host/host_os_none/host_os_none.uvopt b/demos/host/host_os_none/host_os_none.uvopt
index ea3148b9..1d4db6bc 100644
--- a/demos/host/host_os_none/host_os_none.uvopt
+++ b/demos/host/host_os_none/host_os_none.uvopt
@@ -120,6 +120,21 @@
Segger\JL2CM3.dll
+
+ 0
+ DLGTARM
+ (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)
+
+
+ 0
+ ARMDBGFLAGS
+
+
+
+ 0
+ DLGUARM
+
+
0
JL2CM3
@@ -127,15 +142,22 @@
+
+
+ 0
+ 1
+ usbh_devices
+
+
0
0
- 0
+ 1
0
0
0
0
- 0
+ 1
0
0
0
@@ -147,7 +169,7 @@
0
0
0
- 0
+ 1
0
0
0
@@ -678,7 +700,7 @@
0
0
151
- 159
+ 152
0
..\src\msc_host_app.c
msc_host_app.c
@@ -779,10 +801,10 @@
1
0
0
- 0
+ 18
0
- 1
- 1
+ 202
+ 214
0
..\..\..\tinyusb\host\usbh.c
usbh.c
@@ -1139,9 +1161,9 @@
1
0
0
- 38
+ 63
0
- 1690
+ 1703
1709
0
..\..\..\vendor\fatfs\ff.c
@@ -1347,10 +1369,10 @@
2
0
0
- 0
+ 20
0
- 148
- 151
+ 145
+ 162
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
startup_LPC43xx.s
diff --git a/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c b/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c
index c11a8ede..6b548577 100644
--- a/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c
+++ b/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);
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)
diff --git a/tinyusb/hal/hal_lpc43xx.h b/tinyusb/hal/hal_lpc43xx.h
index 6360384e..899f1444 100644
--- a/tinyusb/hal/hal_lpc43xx.h
+++ b/tinyusb/hal/hal_lpc43xx.h
@@ -40,6 +40,7 @@
#define _TUSB_HAL_LPC43XX_H_
#include "LPC43xx.h"
+#include "lpc43xx_cgu.h"
#ifdef __cplusplus
extern "C" {
diff --git a/tinyusb/host/hub.c b/tinyusb/host/hub.c
index 3259732e..e9608f95 100644
--- a/tinyusb/host/hub.c
+++ b/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)
{
+ enum { RESET_DELAY = 200 }; // USB specs say only 50ms but many devices require much longer
tusb_error_t error;
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 );
- 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 -------------//
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) )
{
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
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 5504e960..e694ef06 100644
--- a/tinyusb/host/usbh.c
+++ b/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
#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);
- // 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_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);
}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)
{
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;
diff --git a/vendor/freertos/FreeRTOSConfig.h b/vendor/freertos/FreeRTOSConfig.h
index e2378234..36246e85 100644
--- a/vendor/freertos/FreeRTOSConfig.h
+++ b/vendor/freertos/FreeRTOSConfig.h
@@ -10,9 +10,13 @@
//--------------------------------------------------------------------+
// 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 configCPU_CLOCK_HZ ( SystemCoreClock )
-//#define configCPU_CLOCK_HZ ( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE))
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 8 )
#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. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
-#if 0
+//--------------------------------------------------------------------+
+// 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
-
+ #define ARCH_DIR ARM_CM3
#elif __CORTEX_M == 0
-
+ #define ARCH_DIR ARM_CM0
#else
#error "not yet supported MCU"
#endif
-#endif
+
+#include XSTRING_(freertos/Source/portable/TOOL_DIR/ARCH_DIR/portmacro.h)
#endif /* __FREERTOS_CONFIG__H */
diff --git a/vendor/freertos/freertos/Source/include/portable.h b/vendor/freertos/freertos/Source/include/portable.h
index 235cab0d..cb3bacba 100644
--- a/vendor/freertos/freertos/Source/include/portable.h
+++ b/vendor/freertos/freertos/Source/include/portable.h
@@ -70,44 +70,6 @@
#ifndef 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. */
#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT
diff --git a/vendor/freertos/readme.md b/vendor/freertos/readme.md
new file mode 100644
index 00000000..b751754c
--- /dev/null
+++ b/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.
\ No newline at end of file