mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-14 04:18:56 +00:00
rename tusb_hal_tick_get to tusb_hal_millis
rename TUSB_CFG_TICKS_HZ to BOARD_TICKS_HZ
This commit is contained in:
parent
43bf760f81
commit
e2f9744369
@ -70,7 +70,6 @@
|
||||
|
||||
//#define TUSB_CFG_OS TUSB_OS_NONE // be passed from IDE/command line for easy project switching
|
||||
//#define TUSB_CFG_OS_TASK_PRIO 0 // be passed from IDE/command line for easy project switching
|
||||
#define TUSB_CFG_TICKS_HZ 1000
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB RAM PLACEMENT
|
||||
|
@ -71,8 +71,6 @@
|
||||
//#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build
|
||||
//#define TUSB_CFG_OS_TASK_PRIO 0 // defined using eclipse build
|
||||
|
||||
#define TUSB_CFG_TICKS_HZ 1000
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB RAM PLACEMENT
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -121,6 +121,8 @@
|
||||
//--------------------------------------------------------------------+
|
||||
#define CFG_UART_BAUDRATE 115200 ///< Baudrate for UART
|
||||
|
||||
#define BOARD_TICKS_HZ 1000
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board Common API
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -65,12 +65,34 @@ enum {
|
||||
BOARD_BUTTON_COUNT = sizeof(buttons) / sizeof(buttons[0])
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* TUSB HAL MILLISECOND
|
||||
*------------------------------------------------------------------*/
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE
|
||||
|
||||
volatile uint32_t system_ticks = 0;
|
||||
|
||||
void SysTick_Handler (void)
|
||||
{
|
||||
system_ticks++;
|
||||
}
|
||||
|
||||
uint32_t tusb_hal_millis(void)
|
||||
{
|
||||
return (system_ticks*1000) / BOARD_TICKS_HZ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BOARD API
|
||||
*------------------------------------------------------------------*/
|
||||
void board_init(void)
|
||||
{
|
||||
CGU_Init();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#endif
|
||||
|
||||
//------------- USB -------------//
|
||||
|
@ -54,7 +54,7 @@
|
||||
void board_init(void)
|
||||
{
|
||||
CGU_Init();
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
|
||||
//------------- USB Bus power HOST ONLY-------------//
|
||||
// Hitex VBUS0 is P2_3
|
||||
|
@ -75,7 +75,7 @@ void board_init(void)
|
||||
CGU_Init();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#endif
|
||||
|
||||
//------------- USB Bus power HOST ONLY-------------//
|
||||
|
@ -57,7 +57,7 @@ void board_init(void)
|
||||
CGU_Init();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#endif
|
||||
|
||||
//------------- USB -------------//
|
||||
|
@ -68,7 +68,7 @@ void board_init(void)
|
||||
SystemInit();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(SystemCoreClock / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#endif
|
||||
|
||||
GPIOInit();
|
||||
|
@ -59,7 +59,7 @@ void board_init(void)
|
||||
SystemInit();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(SystemCoreClock / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#endif
|
||||
|
||||
GPIOInit();
|
||||
|
@ -69,7 +69,7 @@ void board_init(void)
|
||||
SystemInit();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(SystemCoreClock / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#endif
|
||||
|
||||
GPIOInit();
|
||||
|
@ -68,7 +68,7 @@ void board_init(void)
|
||||
SystemInit();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(SystemCoreClock / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
|
||||
SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#endif
|
||||
|
||||
//------------- LED -------------//
|
||||
|
@ -71,7 +71,7 @@ void board_init(void)
|
||||
CGU_Init();
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/TUSB_CFG_TICKS_HZ ); /* 1 ms Timer */
|
||||
SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/BOARD_TICKS_HZ ); /* 1 ms Timer */
|
||||
#endif
|
||||
|
||||
//------------- USB Bus power HOST ONLY-------------//
|
||||
|
@ -55,17 +55,15 @@ typedef struct {
|
||||
uint32_t interval;
|
||||
}timeout_timer_t;
|
||||
|
||||
static inline void timeout_set(timeout_timer_t* tt, uint32_t msec) ATTR_ALWAYS_INLINE;
|
||||
static inline void timeout_set(timeout_timer_t* tt, uint32_t msec)
|
||||
{
|
||||
tt->interval = osal_tick_from_msec(msec);
|
||||
tt->start = osal_tick_get();
|
||||
tt->interval = msec;
|
||||
tt->start = osal_millis();
|
||||
}
|
||||
|
||||
static inline bool timeout_expired(timeout_timer_t* tt) ATTR_ALWAYS_INLINE;
|
||||
static inline bool timeout_expired(timeout_timer_t* tt)
|
||||
{
|
||||
return ( osal_tick_get() - tt->start ) >= tt->interval;
|
||||
return ( osal_millis() - tt->start ) >= tt->interval;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -55,12 +55,6 @@ enum
|
||||
OSAL_TIMEOUT_WAIT_FOREVER = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
return (msec * TUSB_CFG_TICKS_HZ)/1000;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -59,7 +59,7 @@ extern "C" {
|
||||
//--------------------------------------------------------------------+
|
||||
// TICK API
|
||||
//--------------------------------------------------------------------+
|
||||
#define osal_tick_get xTaskGetTickCount
|
||||
#define osal_millis xTaskGetTickCount
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TASK API
|
||||
@ -76,7 +76,7 @@ static inline osal_task_t osal_task_create(osal_func_t code, const char* name, u
|
||||
|
||||
static inline void osal_task_delay(uint32_t msec)
|
||||
{
|
||||
vTaskDelay( (TUSB_CFG_TICKS_HZ * msec) / 1000 );
|
||||
vTaskDelay( pdMS_TO_TICKS(msec) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -91,7 +91,7 @@ static inline osal_queue_t osal_queue_create(uint32_t depth, uint32_t item_size)
|
||||
|
||||
static inline void osal_queue_receive (osal_queue_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : osal_tick_from_msec(msec);
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec);
|
||||
|
||||
portBASE_TYPE result = (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) ? xQueueReceiveFromISR(queue_hdl, p_data, NULL) : xQueueReceive(queue_hdl, p_data, ticks);
|
||||
(*p_error) = ( result == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
@ -137,7 +137,7 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl)
|
||||
|
||||
static inline void osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : osal_tick_from_msec(msec);
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec);
|
||||
|
||||
BaseType_t result;
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// TICK API
|
||||
//--------------------------------------------------------------------+
|
||||
#define osal_tick_get tusb_hal_tick_get
|
||||
#define osal_millis tusb_hal_millis
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TASK API
|
||||
@ -97,9 +97,9 @@ static inline osal_task_t osal_task_create(osal_func_t code, const char* name, u
|
||||
|
||||
#define osal_task_delay(msec) \
|
||||
do {\
|
||||
_timeout = osal_tick_get();\
|
||||
_timeout = osal_millis();\
|
||||
_state = __LINE__; case __LINE__:\
|
||||
if ( _timeout + osal_tick_from_msec(msec) > osal_tick_get() ) \
|
||||
if ( _timeout + msec > osal_millis() ) \
|
||||
return TUSB_ERROR_OSAL_WAITING;\
|
||||
}while(0)
|
||||
|
||||
@ -164,10 +164,10 @@ static inline void osal_queue_flush(osal_queue_t const queue_hdl)
|
||||
|
||||
#define osal_queue_receive(queue_hdl, p_data, msec, p_error) \
|
||||
do {\
|
||||
_timeout = osal_tick_get();\
|
||||
_timeout = osal_millis();\
|
||||
_state = __LINE__; case __LINE__:\
|
||||
if( queue_hdl->count == 0 ) {\
|
||||
if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && ( _timeout + osal_tick_from_msec(msec) <= osal_tick_get() )) /* time out */ \
|
||||
if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && ( _timeout + msec <= osal_millis()) ) /* time out */ \
|
||||
*(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\
|
||||
else\
|
||||
return TUSB_ERROR_OSAL_WAITING;\
|
||||
@ -218,10 +218,10 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl)
|
||||
|
||||
#define osal_semaphore_wait(sem_hdl, msec, p_error) \
|
||||
do {\
|
||||
_timeout = osal_tick_get();\
|
||||
_timeout = osal_millis();\
|
||||
_state = __LINE__; case __LINE__:\
|
||||
if( sem_hdl->count == 0 ) {\
|
||||
if ( ( ((uint32_t) (msec)) != OSAL_TIMEOUT_WAIT_FOREVER) && (_timeout + osal_tick_from_msec(msec) <= osal_tick_get()) ) /* time out */ \
|
||||
if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && (_timeout + msec <= osal_millis()) ) /* time out */ \
|
||||
*(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\
|
||||
else\
|
||||
return TUSB_ERROR_OSAL_WAITING;\
|
||||
|
@ -81,7 +81,7 @@ void tusb_hal_int_disable(uint8_t rhport)
|
||||
NVIC_DisableIRQ(USBD_IRQn);
|
||||
}
|
||||
|
||||
uint32_t tusb_hal_tick_get(void)
|
||||
uint32_t tusb_hal_millis(void)
|
||||
{
|
||||
//#define tick2ms(tck) ( ( ((uint64_t)(tck)) * 1000) / configTICK_RATE_HZ )
|
||||
//return tick2ms( app_timer_cnt_get() );
|
||||
|
@ -53,22 +53,6 @@ enum {
|
||||
LPC43XX_USBMODE_VBUS_HIGH = 1
|
||||
};
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE
|
||||
|
||||
volatile uint32_t system_ticks = 0;
|
||||
|
||||
void SysTick_Handler (void)
|
||||
{
|
||||
system_ticks++;
|
||||
}
|
||||
|
||||
uint32_t tusb_hal_tick_get(void)
|
||||
{
|
||||
return system_ticks;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void tusb_hal_int_enable(uint8_t rhport)
|
||||
{
|
||||
NVIC_EnableIRQ(rhport ? USB1_IRQn : USB0_IRQn);
|
||||
|
@ -75,7 +75,7 @@ void tusb_hal_int_enable(uint8_t rhport);
|
||||
*/
|
||||
void tusb_hal_int_disable(uint8_t rhport);
|
||||
|
||||
uint32_t tusb_hal_tick_get(void);
|
||||
uint32_t tusb_hal_millis(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user