From 2c4a2e5b9e36436280b30cc12529b4027b589fbd Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 18 Mar 2014 16:10:25 +0700 Subject: rename TUSB_CFG_OS_TICKS_PER_SECOND to TUSB_CFG_TICKS_HZ remove CFG_TICKS_PER_SECOND --- tinyusb/osal/osal_common.h | 3 +-- tinyusb/osal/osal_freeRTOS.h | 2 +- tinyusb/tusb.c | 1 - tinyusb/tusb.h | 27 +++++++++++++++++++++++++++ tinyusb/tusb_option.h | 11 +++-------- 5 files changed, 32 insertions(+), 12 deletions(-) (limited to 'tinyusb') diff --git a/tinyusb/osal/osal_common.h b/tinyusb/osal/osal_common.h index 6347abaea..0cf712e25 100644 --- a/tinyusb/osal/osal_common.h +++ b/tinyusb/osal/osal_common.h @@ -59,11 +59,10 @@ 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) { - return (msec * TUSB_CFG_OS_TICKS_PER_SECOND)/1000; + return (msec * TUSB_CFG_TICKS_HZ)/1000; } #ifdef __cplusplus diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h index 942a0ea5b..5a904736f 100644 --- a/tinyusb/osal/osal_freeRTOS.h +++ b/tinyusb/osal/osal_freeRTOS.h @@ -91,7 +91,7 @@ static inline tusb_error_t osal_task_create(osal_task_t *task) static inline void osal_task_delay(uint32_t msec) ATTR_ALWAYS_INLINE; static inline void osal_task_delay(uint32_t msec) { - vTaskDelay( (TUSB_CFG_OS_TICKS_PER_SECOND * msec) / 1000 ); + vTaskDelay( (TUSB_CFG_TICKS_HZ * msec) / 1000 ); } //--------------------------------------------------------------------+ diff --git a/tinyusb/tusb.c b/tinyusb/tusb.c index 980e19402..8a0d1be59 100644 --- a/tinyusb/tusb.c +++ b/tinyusb/tusb.c @@ -77,7 +77,6 @@ void tusb_isr(uint8_t controller_id) } #if TUSB_CFG_OS == TUSB_OS_NONE -// periodically/continuously called in the main loop void tusb_task_runner(void) { #if MODE_HOST_SUPPORTED diff --git a/tinyusb/tusb.h b/tinyusb/tusb.h index 38c021751..2d40c1fec 100644 --- a/tinyusb/tusb.h +++ b/tinyusb/tusb.h @@ -93,12 +93,39 @@ //--------------------------------------------------------------------+ // APPLICATION API //--------------------------------------------------------------------+ +/** \defgroup application_setup Application Setup + * @{ */ + +/** \brief Initialize the usb stack + * \return Error Code of the \ref TUSB_ERROR enum + * \note Function will initialize the stack according to configuration in the configure file (tusb_config.h) + */ tusb_error_t tusb_init(void); #if TUSB_CFG_OS == TUSB_OS_NONE +/** \brief Run all tinyusb's internal tasks (e.g host task, device task). + * \note This function is only required when using no RTOS (\ref TUSB_CFG_OS == TUSB_OS_NONE). All the stack functions + * & callback are invoked within this function, so it should be called periodically within the mainloop + * + @code + int main(void) + { + // some init code + tusb_init(); + while(1) // the mainloop + { + tusb_task_runner(); + // other code + } + } + @endcode + * + */ void tusb_task_runner(void); #endif +/** @} */ + #ifdef __cplusplus } #endif diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h index 39ab00ded..a7c525105 100644 --- a/tinyusb/tusb_option.h +++ b/tinyusb/tusb_option.h @@ -121,14 +121,9 @@ #error TUSB_CFG_ATTR_USBRAM is not defined, please help me know how to place data in accessible RAM for usb controller #endif -#if TUSB_CFG_OS == TUSB_OS_NONE - #ifndef TUSB_CFG_OS_TICKS_PER_SECOND - #error TUSB_CFG_OS_TICKS_PER_SECOND is required to use with OS_NONE - #endif -#else - #ifndef TUSB_CFG_OS_TASK_PRIO - #error TUSB_CFG_OS_TASK_PRIO need to be defined (hint: use the highest if possible) - #endif + +#if (TUSB_CFG_OS != TUSB_OS_NONE) && !defined (TUSB_CFG_OS_TASK_PRIO) + #error TUSB_CFG_OS_TASK_PRIO need to be defined (hint: use the highest if possible) #endif //#ifndef TUSB_CFG_CONFIGURATION_MAX -- cgit v1.3.1