diff options
| author | hathach <[email protected]> | 2013-09-13 23:32:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-09-13 23:32:07 +0700 |
| commit | 0d279facbbb326b07e5dd84c3baabfa841d132f9 (patch) | |
| tree | 1c20fd9a1cd834b8bcd530a7eca3d72d01c63f33 | |
| parent | 67453b89f03e43408bf165f610aa62a63c000f1c (diff) | |
fix cmsis rtx tick configuration
everything should work
TODO: remove static for variable error in control xfer subtask
| -rw-r--r-- | demos/bsp/boards/board.c | 2 | ||||
| -rw-r--r-- | demos/bsp/boards/embedded_artists/board_ea4357.c | 4 | ||||
| -rw-r--r-- | demos/bsp/boards/hitex/board_hitex4350.c | 1 | ||||
| -rw-r--r-- | demos/bsp/boards/keil/board_mcb4300.c | 1 | ||||
| -rw-r--r-- | demos/bsp/boards/microbuilder/board_lpc4357usb.c | 1 | ||||
| -rw-r--r-- | demos/bsp/boards/ngx/board_ngx4330.c | 41 | ||||
| -rw-r--r-- | tinyusb/host/usbh.c | 12 | ||||
| -rw-r--r-- | tinyusb/osal/osal_common.h | 1 | ||||
| -rw-r--r-- | vendor/cmsis_rtos_rtx/RTX_Conf_CM.c | 2 |
9 files changed, 32 insertions, 33 deletions
diff --git a/demos/bsp/boards/board.c b/demos/bsp/boards/board.c index e3c336cde..31186c35a 100644 --- a/demos/bsp/boards/board.c +++ b/demos/bsp/boards/board.c @@ -38,7 +38,7 @@ #include "board.h" -#if TUSB_CFG_OS == TUSB_OS_NONE +#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c volatile uint32_t system_ticks = 0; void SysTick_Handler (void) diff --git a/demos/bsp/boards/embedded_artists/board_ea4357.c b/demos/bsp/boards/embedded_artists/board_ea4357.c index f2835bd6a..a415c793c 100644 --- a/demos/bsp/boards/embedded_artists/board_ea4357.c +++ b/demos/bsp/boards/embedded_artists/board_ea4357.c @@ -48,9 +48,11 @@ void board_init(void) { - SystemInit(); CGU_Init(); + +//#if TUSB_CFG_OS != TUSB_OS_CMSIS_RTX // TODO may move to main.c SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer +//#endif // USB0 Power: EA4357 channel B U20 GPIO26 active low (base board), P2_3 on LPC4357 scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus Power diff --git a/demos/bsp/boards/hitex/board_hitex4350.c b/demos/bsp/boards/hitex/board_hitex4350.c index 2ba54e46c..5422fad4c 100644 --- a/demos/bsp/boards/hitex/board_hitex4350.c +++ b/demos/bsp/boards/hitex/board_hitex4350.c @@ -53,7 +53,6 @@ //--------------------------------------------------------------------+ void board_init(void) { - SystemInit(); CGU_Init(); SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer diff --git a/demos/bsp/boards/keil/board_mcb4300.c b/demos/bsp/boards/keil/board_mcb4300.c index 57ce2591c..773dab4c5 100644 --- a/demos/bsp/boards/keil/board_mcb4300.c +++ b/demos/bsp/boards/keil/board_mcb4300.c @@ -72,7 +72,6 @@ const static struct { //--------------------------------------------------------------------+ void board_init(void) { - SystemInit(); CGU_Init(); SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer diff --git a/demos/bsp/boards/microbuilder/board_lpc4357usb.c b/demos/bsp/boards/microbuilder/board_lpc4357usb.c index 83f9c8b16..c8bcab8ef 100644 --- a/demos/bsp/boards/microbuilder/board_lpc4357usb.c +++ b/demos/bsp/boards/microbuilder/board_lpc4357usb.c @@ -53,7 +53,6 @@ void board_init(void) { - SystemInit(); CGU_Init(); /* Setup the systick time for 1ms ticks */ diff --git a/demos/bsp/boards/ngx/board_ngx4330.c b/demos/bsp/boards/ngx/board_ngx4330.c index 620393d21..a09cc10fb 100644 --- a/demos/bsp/boards/ngx/board_ngx4330.c +++ b/demos/bsp/boards/ngx/board_ngx4330.c @@ -48,36 +48,35 @@ const static struct { void board_init(void) { - SystemInit(); CGU_Init(); - SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/CFG_TICKS_PER_SECOND ); /* 1 ms Timer */ + SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/CFG_TICKS_PER_SECOND ); /* 1 ms Timer */ - //------------- USB Bus power HOST ONLY-------------// - scu_pinmux(0x1, 7, MD_PUP | MD_EZI, FUNC4); // P1_7 USB0_PWR_EN, USB0 VBus function Xplorer + //------------- USB Bus power HOST ONLY-------------// + scu_pinmux(0x1, 7, MD_PUP | MD_EZI, FUNC4); // P1_7 USB0_PWR_EN, USB0 VBus function Xplorer - scu_pinmux(0x2, 6, MD_PUP | MD_EZI, FUNC4); // P2_6 is configured as GPIO5[6] for USB1_PWR_EN - GPIO_SetDir (5, BIT_(6), 1); // GPIO5[6] is output - GPIO_SetValue (5, BIT_(6)); // GPIO5[6] output high + scu_pinmux(0x2, 6, MD_PUP | MD_EZI, FUNC4); // P2_6 is configured as GPIO5[6] for USB1_PWR_EN + GPIO_SetDir (5, BIT_(6), 1); // GPIO5[6] is output + GPIO_SetValue (5, BIT_(6)); // GPIO5[6] output high - // Leds Init - for (uint8_t i=0; i<BOARD_MAX_LEDS; i++) - { - scu_pinmux(leds[i].port, leds[i].pin, MD_PUP|MD_EZI|MD_ZI, FUNC0); - GPIO_SetDir(leds[i].port, BIT_(leds[i].pin), 1); // output - } + // Leds Init + for (uint8_t i=0; i<BOARD_MAX_LEDS; i++) + { + scu_pinmux(leds[i].port, leds[i].pin, MD_PUP|MD_EZI|MD_ZI, FUNC0); + GPIO_SetDir(leds[i].port, BIT_(leds[i].pin), 1); // output + } #if CFG_UART_ENABLE - //------------- UART init -------------// - UART_CFG_Type UARTConfigStruct; + //------------- UART init -------------// + UART_CFG_Type UARTConfigStruct; - scu_pinmux(0x6 ,4, MD_PDN|MD_EZI, FUNC2); // UART0_TXD - scu_pinmux(0x6 ,5, MD_PDN|MD_EZI, FUNC2); // UART0_RXD + scu_pinmux(0x6 ,4, MD_PDN|MD_EZI, FUNC2); // UART0_TXD + scu_pinmux(0x6 ,5, MD_PDN|MD_EZI, FUNC2); // UART0_RXD - UART_ConfigStructInit(&UARTConfigStruct); // default: baud = 9600, 8 bit data, 1 stop bit, no parity - UARTConfigStruct.Baud_rate = CFG_UART_BAUDRATE; // Re-configure baudrate + UART_ConfigStructInit(&UARTConfigStruct); // default: baud = 9600, 8 bit data, 1 stop bit, no parity + UARTConfigStruct.Baud_rate = CFG_UART_BAUDRATE; // Re-configure baudrate - UART_Init((LPC_USARTn_Type*) LPC_USART0, &UARTConfigStruct); // Initialize UART port - UART_TxCmd((LPC_USARTn_Type*) LPC_USART0, ENABLE); // Enable UART + UART_Init((LPC_USARTn_Type*) LPC_USART0, &UARTConfigStruct); // Initialize UART port + UART_TxCmd((LPC_USARTn_Type*) LPC_USART0, ENABLE); // Enable UART #endif } diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index a4cbabb9d..99072bc7f 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -108,7 +108,7 @@ static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAPPED_INDEX_END] usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1] TUSB_CFG_ATTR_USBRAM; // including zero-address //------------- Enumeration Task Data -------------// -OSAL_TASK_DEF(enum_task_def, "tinyusb host", usbh_enumeration_task, 150, TUSB_CFG_OS_TASK_PRIO); +OSAL_TASK_DEF(usbh_enumeration_task, 150, TUSB_CFG_OS_TASK_PRIO); OSAL_QUEUE_DEF(enum_queue_def, ENUM_QUEUE_DEPTH, uint32_t); osal_queue_handle_t enum_queue_hdl; STATIC_ uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM; @@ -136,7 +136,7 @@ static inline uint8_t std_class_code_to_index(uint8_t std_class_code) tusb_device_state_t tusbh_device_get_state (uint8_t const dev_addr) { ASSERT_INT_WITHIN(1, TUSB_CFG_HOST_DEVICE_MAX, dev_addr, TUSB_DEVICE_STATE_INVALID_PARAMETER); - return usbh_devices[dev_addr].state; + return (tusb_device_state_t) usbh_devices[dev_addr].state; } uint32_t tusbh_device_get_mounted_class_flag(uint8_t dev_addr) @@ -154,9 +154,9 @@ tusb_error_t usbh_init(void) ASSERT_STATUS( hcd_init() ); //------------- Enumeration & Reporter Task init -------------// - ASSERT_STATUS( osal_task_create(&enum_task_def) ); - enum_queue_hdl = osal_queue_create(&enum_queue_def); + enum_queue_hdl = osal_queue_create( OSAL_QUEUE_REF(enum_queue_def) ); ASSERT_PTR(enum_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED); + ASSERT_STATUS( osal_task_create( OSAL_TASK_REF(usbh_enumeration_task) )); //------------- Semaphore, Mutex for Control Pipe -------------// for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) // including address zero @@ -166,7 +166,7 @@ tusb_error_t usbh_init(void) p_device->control.sem_hdl = osal_semaphore_create( OSAL_SEM_REF(p_device->control.semaphore) ); ASSERT_PTR(p_device->control.sem_hdl, TUSB_ERROR_OSAL_SEMAPHORE_FAILED); - p_device->control.mutex_hdl = osal_mutex_create ( OSAL_SEM_REF(p_device->control.mutex) ); + p_device->control.mutex_hdl = osal_mutex_create ( OSAL_MUTEX_REF(p_device->control.mutex) ); ASSERT_PTR(p_device->control.mutex_hdl, TUSB_ERROR_OSAL_MUTEX_FAILED); } @@ -187,7 +187,7 @@ tusb_error_t usbh_init(void) tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength, uint8_t* data) { - tusb_error_t error; + static tusb_error_t error; // FIXME cmsis-rtx use svc for OS API, error value changed after mutex release at the end of function OSAL_SUBTASK_BEGIN diff --git a/tinyusb/osal/osal_common.h b/tinyusb/osal/osal_common.h index a70242e70..b97e68af4 100644 --- a/tinyusb/osal/osal_common.h +++ b/tinyusb/osal/osal_common.h @@ -65,6 +65,7 @@ enum OSAL_TIMEOUT_WAIT_FOREVER = 0x0EEEEEEE }; +// TODO refractor/remove this function and/or TUSB_CFG_OS_TICKS_PER_SECOND if using an RTOS static inline uint32_t osal_tick_from_msec(uint32_t msec) ATTR_CONST ATTR_ALWAYS_INLINE; static inline uint32_t osal_tick_from_msec(uint32_t msec) { diff --git a/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c b/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c index 2250b5142..011df7cbc 100644 --- a/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c +++ b/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c @@ -115,7 +115,7 @@ // <i> Defines the timer tick value. // <i> Default: 1000 (1ms) #ifndef OS_TICK - #define OS_TICK 10000 + #define OS_TICK 1000 #endif // </h> |
