summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2014-03-18 16:10:25 +0700
committerhathach <[email protected]>2014-03-18 16:10:25 +0700
commit2c4a2e5b9e36436280b30cc12529b4027b589fbd (patch)
tree2f678e307c408399e7ffed9dd2fdd2cf4e51caf5
parentfe1b39e539adcee6be4b9b8637a13debc3f6811c (diff)
rename TUSB_CFG_OS_TICKS_PER_SECOND to TUSB_CFG_TICKS_HZ
remove CFG_TICKS_PER_SECOND
-rw-r--r--boards/board.h1
-rw-r--r--boards/embedded_artists/ea4357/board_ea4357.c2
-rw-r--r--boards/hitex/board_hitex4350.c2
-rw-r--r--boards/keil/board_mcb4300.c2
-rw-r--r--boards/lpcxpresso/board_lpclink2.c2
-rw-r--r--boards/lpcxpresso/board_lpcxpresso1347.c2
-rw-r--r--boards/lpcxpresso/board_lpcxpresso1769.c2
-rw-r--r--boards/microbuilder/board_lpc4357usb.c2
-rw-r--r--boards/microbuilder/board_rf1ghznode.c2
-rw-r--r--boards/ngx/board_ngx4330.c2
-rw-r--r--demos/device/src/main.c2
-rw-r--r--demos/device/src/tusb_config.h2
-rw-r--r--demos/host/src/main.c2
-rw-r--r--demos/host/src/tusb_config.h2
-rw-r--r--tinyusb/osal/osal_common.h3
-rw-r--r--tinyusb/osal/osal_freeRTOS.h2
-rw-r--r--tinyusb/tusb.c1
-rw-r--r--tinyusb/tusb.h27
-rw-r--r--tinyusb/tusb_option.h11
19 files changed, 45 insertions, 26 deletions
diff --git a/boards/board.h b/boards/board.h
index 5ac586a1c..9c7facacb 100644
--- a/boards/board.h
+++ b/boards/board.h
@@ -106,7 +106,6 @@
//--------------------------------------------------------------------+
// Common Configuration
//--------------------------------------------------------------------+
-#define CFG_TICKS_PER_SECOND 1000
#define CFG_UART_BAUDRATE 115200
//--------------------------------------------------------------------+
diff --git a/boards/embedded_artists/ea4357/board_ea4357.c b/boards/embedded_artists/ea4357/board_ea4357.c
index ce38a6921..95252ee04 100644
--- a/boards/embedded_artists/ea4357/board_ea4357.c
+++ b/boards/embedded_artists/ea4357/board_ea4357.c
@@ -70,7 +70,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) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
+ SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
#endif
//------------- USB -------------//
diff --git a/boards/hitex/board_hitex4350.c b/boards/hitex/board_hitex4350.c
index 5422fad4c..4811f02f0 100644
--- a/boards/hitex/board_hitex4350.c
+++ b/boards/hitex/board_hitex4350.c
@@ -54,7 +54,7 @@
void board_init(void)
{
CGU_Init();
- SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
+ SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
//------------- USB Bus power HOST ONLY-------------//
// Hitex VBUS0 is P2_3
diff --git a/boards/keil/board_mcb4300.c b/boards/keil/board_mcb4300.c
index 773dab4c5..0a00c8e58 100644
--- a/boards/keil/board_mcb4300.c
+++ b/boards/keil/board_mcb4300.c
@@ -73,7 +73,7 @@ const static struct {
void board_init(void)
{
CGU_Init();
- SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
+ SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
//------------- USB Bus power HOST ONLY-------------//
// Keil VBUS0 is P6_3
diff --git a/boards/lpcxpresso/board_lpclink2.c b/boards/lpcxpresso/board_lpclink2.c
index 8792ee933..2e4ae2488 100644
--- a/boards/lpcxpresso/board_lpclink2.c
+++ b/boards/lpcxpresso/board_lpclink2.c
@@ -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) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
+ SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
#endif
//------------- USB -------------//
diff --git a/boards/lpcxpresso/board_lpcxpresso1347.c b/boards/lpcxpresso/board_lpcxpresso1347.c
index 816e1c951..0a45830c8 100644
--- a/boards/lpcxpresso/board_lpcxpresso1347.c
+++ b/boards/lpcxpresso/board_lpcxpresso1347.c
@@ -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 / CFG_TICKS_PER_SECOND); // 1 msec tick timer
+ SysTick_Config(SystemCoreClock / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
#endif
GPIOInit();
diff --git a/boards/lpcxpresso/board_lpcxpresso1769.c b/boards/lpcxpresso/board_lpcxpresso1769.c
index 238559d8e..13a08cfc4 100644
--- a/boards/lpcxpresso/board_lpcxpresso1769.c
+++ b/boards/lpcxpresso/board_lpcxpresso1769.c
@@ -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 / CFG_TICKS_PER_SECOND); // 1 msec tick timer
+ SysTick_Config(SystemCoreClock / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
#endif
//------------- LED -------------//
diff --git a/boards/microbuilder/board_lpc4357usb.c b/boards/microbuilder/board_lpc4357usb.c
index 35d800956..6e96f2760 100644
--- a/boards/microbuilder/board_lpc4357usb.c
+++ b/boards/microbuilder/board_lpc4357usb.c
@@ -56,7 +56,7 @@ void board_init(void)
CGU_Init();
/* Setup the systick time for 1ms ticks */
- SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND);
+ SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / TUSB_CFG_TICKS_HZ);
/* Configure LED0 as GPIO */
scu_pinmux(BOARD_LED0_PORT, BOARD_LED0_PIN, MD_PDN, BOARD_LED0_FUNCTION);
diff --git a/boards/microbuilder/board_rf1ghznode.c b/boards/microbuilder/board_rf1ghznode.c
index 9560472cb..9d902282c 100644
--- a/boards/microbuilder/board_rf1ghznode.c
+++ b/boards/microbuilder/board_rf1ghznode.c
@@ -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 / CFG_TICKS_PER_SECOND); // 1 msec tick timer
+ SysTick_Config(SystemCoreClock / TUSB_CFG_TICKS_HZ); // 1 msec tick timer
#endif
GPIOInit();
diff --git a/boards/ngx/board_ngx4330.c b/boards/ngx/board_ngx4330.c
index 0709db2f9..02e6d3ff0 100644
--- a/boards/ngx/board_ngx4330.c
+++ b/boards/ngx/board_ngx4330.c
@@ -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)/CFG_TICKS_PER_SECOND ); /* 1 ms Timer */
+ SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/TUSB_CFG_TICKS_HZ ); /* 1 ms Timer */
#endif
//------------- USB Bus power HOST ONLY-------------//
diff --git a/demos/device/src/main.c b/demos/device/src/main.c
index c15d92e4d..f5c05bece 100644
--- a/demos/device/src/main.c
+++ b/demos/device/src/main.c
@@ -155,7 +155,7 @@ void print_greeting(void)
--------------------------------------------------------------------\n\n"
);
- puts("This demo supports the following classes");
+ puts("This demo supports the following classes for DEVICE");
if (TUSB_CFG_DEVICE_HID_MOUSE ) puts(" - HID Mouse");
if (TUSB_CFG_DEVICE_HID_KEYBOARD ) puts(" - HID Keyboard");
if (TUSB_CFG_DEVICE_MSC ) puts(" - Mass Storage");
diff --git a/demos/device/src/tusb_config.h b/demos/device/src/tusb_config.h
index 94261c39b..d0b897807 100644
--- a/demos/device/src/tusb_config.h
+++ b/demos/device/src/tusb_config.h
@@ -72,7 +72,7 @@
//#define TUSB_CFG_OS TUSB_OS_NONE // be passed from IDE/command line for easy project switching
//#define TUSB_CFG_OS_TASK_PRIO // be passed from IDE/command line for easy project switching
-#define TUSB_CFG_OS_TICKS_PER_SECOND 1000
+#define TUSB_CFG_TICKS_HZ 1000
//--------------------------------------------------------------------+
// USB RAM PLACEMENT
diff --git a/demos/host/src/main.c b/demos/host/src/main.c
index 7a6a2d22d..b85004052 100644
--- a/demos/host/src/main.c
+++ b/demos/host/src/main.c
@@ -152,7 +152,7 @@ void print_greeting(void)
--------------------------------------------------------------------\n"
);
- puts("This demo supports the following classes");
+ puts("This demo supports the following classes for HOST");
if (TUSB_CFG_HOST_HUB ) puts(" - Hub (1 level only)");
if (TUSB_CFG_HOST_HID_MOUSE ) puts(" - HID Mouse");
if (TUSB_CFG_HOST_HID_KEYBOARD ) puts(" - HID Keyboard");
diff --git a/demos/host/src/tusb_config.h b/demos/host/src/tusb_config.h
index d1b717a23..077935f38 100644
--- a/demos/host/src/tusb_config.h
+++ b/demos/host/src/tusb_config.h
@@ -72,7 +72,7 @@
//#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build
//#define TUSB_CFG_OS_TASK_PRIO // defined using eclipse build
-#define TUSB_CFG_OS_TICKS_PER_SECOND 1000
+#define TUSB_CFG_TICKS_HZ 1000
//--------------------------------------------------------------------+
// USB RAM PLACEMENT
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