mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 19:20:22 +00:00
fix cmsis rtx tick configuration
everything should work TODO: remove static for variable error in control xfer subtask
This commit is contained in:
parent
67453b89f0
commit
0d279facbb
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -53,7 +53,6 @@
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
SystemInit();
|
||||
CGU_Init();
|
||||
|
||||
/* Setup the systick time for 1ms ticks */
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
2
vendor/cmsis_rtos_rtx/RTX_Conf_CM.c
vendored
2
vendor/cmsis_rtos_rtx/RTX_Conf_CM.c
vendored
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user