diff options
| author | hathach <[email protected]> | 2018-03-29 18:03:04 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-03-29 18:03:04 +0700 |
| commit | e2f97443694c5f8ffd4657055a4caaffab153f2c (patch) | |
| tree | 3b70162f96d3829e2c5584f8ce948e4d2a0b71a9 /tinyusb | |
| parent | 43bf760f814f55fac50794e3eb8e6ecb5d692705 (diff) | |
rename tusb_hal_tick_get to tusb_hal_millis
rename TUSB_CFG_TICKS_HZ to BOARD_TICKS_HZ
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/common/timeout_timer.h | 8 | ||||
| -rw-r--r-- | tinyusb/osal/osal_common.h | 6 | ||||
| -rw-r--r-- | tinyusb/osal/osal_freeRTOS.h | 8 | ||||
| -rw-r--r-- | tinyusb/osal/osal_none.h | 14 | ||||
| -rw-r--r-- | tinyusb/portable/nordic/nrf5x/hal_nrf5x.c | 2 | ||||
| -rw-r--r-- | tinyusb/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c | 16 | ||||
| -rw-r--r-- | tinyusb/tusb_hal.h | 2 |
7 files changed, 16 insertions, 40 deletions
diff --git a/tinyusb/common/timeout_timer.h b/tinyusb/common/timeout_timer.h index 2de71ded3..f504cc91f 100644 --- a/tinyusb/common/timeout_timer.h +++ b/tinyusb/common/timeout_timer.h @@ -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
diff --git a/tinyusb/osal/osal_common.h b/tinyusb/osal/osal_common.h index 2d35e74b4..42ed6e77b 100644 --- a/tinyusb/osal/osal_common.h +++ b/tinyusb/osal/osal_common.h @@ -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
diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h index befad3fd0..f2fe668ae 100644 --- a/tinyusb/osal/osal_freeRTOS.h +++ b/tinyusb/osal/osal_freeRTOS.h @@ -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; diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index f150d5c34..0b73de4e9 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -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;\
diff --git a/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c b/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c index 073f4ac36..4cb7f076e 100644 --- a/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c +++ b/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c @@ -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() ); diff --git a/tinyusb/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c b/tinyusb/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c index ff7d32a3f..31481b742 100644 --- a/tinyusb/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c +++ b/tinyusb/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c @@ -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);
diff --git a/tinyusb/tusb_hal.h b/tinyusb/tusb_hal.h index 98ec79f97..0025bf844 100644 --- a/tinyusb/tusb_hal.h +++ b/tinyusb/tusb_hal.h @@ -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
}
|
