diff --git a/demos/host/host_freertos/host_freertos.uvopt b/demos/host/host_freertos/host_freertos.uvopt
index 84494433a..07beecf2e 100644
--- a/demos/host/host_freertos/host_freertos.uvopt
+++ b/demos/host/host_freertos/host_freertos.uvopt
@@ -73,7 +73,7 @@
0
0
- 0
+ 1
8
@@ -355,7 +355,7 @@
0
0
- 1
+ 0
8
@@ -608,7 +608,7 @@
0
27
0
- 96
+ 97
98
0
..\src\main.c
@@ -1248,7 +1248,7 @@
0
0
0
- 81
+ 95
103
0
..\..\..\boards\board.c
@@ -1416,7 +1416,7 @@
0
0
0
- 148
+ 149
154
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
diff --git a/demos/host/host_os_none/host_os_none.uvopt b/demos/host/host_os_none/host_os_none.uvopt
index 6554d0078..9258661d2 100644
--- a/demos/host/host_os_none/host_os_none.uvopt
+++ b/demos/host/host_os_none/host_os_none.uvopt
@@ -73,7 +73,7 @@
1
0
- 0
+ 1
8
@@ -212,7 +212,7 @@
0
- 0
+ 1
0
0
@@ -355,7 +355,7 @@
1
0
- 1
+ 0
8
@@ -613,7 +613,7 @@
0
9
0
- 85
+ 86
90
0
..\src\main.c
@@ -645,7 +645,7 @@
0
0
0
- 113
+ 114
117
0
..\src\keyboard_host_app.c
@@ -659,10 +659,10 @@
1
0
0
- 0
+ 9
0
- 122
- 126
+ 120
+ 135
0
..\src\mouse_host_app.c
mouse_host_app.c
@@ -677,7 +677,7 @@
0
0
0
- 155
+ 142
159
0
..\src\msc_host_app.c
@@ -781,7 +781,7 @@
0
0
0
- 350
+ 351
354
0
..\..\..\tinyusb\host\usbh.c
@@ -1349,7 +1349,7 @@
0
0
0
- 144
+ 145
151
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h
index fa061a983..4cbbd8aa8 100644
--- a/tinyusb/common/assertion.h
+++ b/tinyusb/common/assertion.h
@@ -69,9 +69,9 @@ extern "C"
#define STATIC_ASSERT(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
#endif
- //#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
-#if TUSB_CFG_DEBUG == 3
- #define _PRINTF(...) printf(__VA_ARGS__) // PRINTF
+//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
+#if TUSB_CFG_DEBUG
+ #define _PRINTF(...) printf(__VA_ARGS__)
#else
#define _PRINTF(...)
#endif
@@ -80,11 +80,9 @@ extern "C"
// Assert Helper
//--------------------------------------------------------------------+
#ifndef _TEST_
- #define ASSERT_MESSAGE(format, ...)\
- _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __func__ , __LINE__, __VA_ARGS__)
-#else
- #define ASSERT_MESSAGE(format, ...)\
- _PRINTF("%d:note: Assert " format "\n", __LINE__, __VA_ARGS__)
+ #define ASSERT_MESSAGE(format, ...) _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __func__ , __LINE__, __VA_ARGS__)
+#else // TODO remove this
+ #define ASSERT_MESSAGE(format, ...) _PRINTF("%d:note: Assert " format "\n", __LINE__, __VA_ARGS__)
#endif
#ifndef _TEST_ASSERT_
@@ -97,11 +95,8 @@ extern "C"
do{\
setup_statement;\
if (!(condition)) {\
- if (hal_debugger_is_attached()){\
- hal_debugger_breakpoint();\
- }else{\
- ASSERT_MESSAGE(format, __VA_ARGS__);\
- }\
+ hal_debugger_breakpoint();\
+ ASSERT_MESSAGE(format, __VA_ARGS__);\
error_handler(error, handler_para);\
}\
}while(0)
@@ -129,9 +124,9 @@ extern "C"
//--------------------------------------------------------------------+
// Pointer Assert
//--------------------------------------------------------------------+
-#define ASSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__)
+#define ASSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__)
#define ASSERT_PTR_NOT_NULL(pointer, error) ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL")
-#define ASSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is not NULL")
+#define ASSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is not NULL")
//--------------------------------------------------------------------+
// Integral Assert
@@ -165,7 +160,7 @@ extern "C"
#define ASSERT_HEX_WITHIN(...) ASSERT_XXX_WITHIN("0x%x", __VA_ARGS__)
//--------------------------------------------------------------------+
-// TODO Bin Assert
+// Bin Assert
//--------------------------------------------------------------------+
#define BIN8_PRINTF_PATTERN "%d%d%d%d%d%d%d%d"
#define BIN8_PRINTF_CONVERT(byte) \
diff --git a/tinyusb/common/compiler/compiler.h b/tinyusb/common/compiler/compiler.h
index 98aa924ad..e628ce7c1 100644
--- a/tinyusb/common/compiler/compiler.h
+++ b/tinyusb/common/compiler/compiler.h
@@ -39,26 +39,30 @@
/** \ingroup Group_Common
* \defgroup Group_Compiler Compiler
* \brief Group_Compiler brief
- *
- * @{
- */
+ * @{ */
#ifndef _TUSB_COMPILER_H_
#define _TUSB_COMPILER_H_
#ifndef _TEST_
+ // TODO move some to tusb_option.h
#define STATIC_ static
#define INLINE_ inline
#define ATTR_TEST_WEAK
- #if TUSB_CFG_DEBUG == 3
- #define ATTR_ALWAYS_INLINE // no inline for debug = 3
+ // allow debugger to watch any module-wide variables anywhere
+ #if TUSB_CFG_DEBUG
#define STATIC_VAR
#else
#define STATIC_VAR static
#endif
-#else
+ // function will not be inline for easy step by step debugging
+ #if TUSB_CFG_DEBUG >= 2
+ #define ATTR_ALWAYS_INLINE
+ #endif
+
+#else // TODO remove this, try to pass using compiler command option
#define ATTR_ALWAYS_INLINE
#define STATIC_
#define STATIC_VAR
@@ -73,4 +77,5 @@
#endif
#endif /* _TUSB_COMPILER_H_ */
+
/// @}
diff --git a/tinyusb/common/tusb_errors.c b/tinyusb/common/tusb_errors.c
index e0848a961..170cb31d4 100644
--- a/tinyusb/common/tusb_errors.c
+++ b/tinyusb/common/tusb_errors.c
@@ -38,7 +38,7 @@
#include "tusb_errors.h"
-#if TUSB_CFG_DEBUG == 3
+#if TUSB_CFG_DEBUG
char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT] =
{
diff --git a/tinyusb/common/tusb_errors.h b/tinyusb/common/tusb_errors.h
index 81b1f0906..74777e670 100644
--- a/tinyusb/common/tusb_errors.h
+++ b/tinyusb/common/tusb_errors.h
@@ -38,8 +38,7 @@
/** \ingroup Group_Common
* \defgroup Group_Error Error Codes
- * @{
- */
+ * @{ */
#ifndef _TUSB_ERRORS_H_
#define _TUSB_ERRORS_H_
@@ -94,15 +93,13 @@
ENTRY(TUSB_ERROR_FAILED )\
-/** \enum tusb_error_t
- * \brief Error Code returned
- */
+/// \brief Error Code returned
typedef enum {
ERROR_TABLE(ERROR_ENUM)
TUSB_ERROR_COUNT
}tusb_error_t;
-#if TUSB_CFG_DEBUG == 3
+#if TUSB_CFG_DEBUG
/// Enum to String for debugging purposes. Only available if \ref TUSB_CFG_DEBUG > 0
extern char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT];
#endif
diff --git a/tinyusb/tusb.h b/tinyusb/tusb.h
index 606803ae0..f34749133 100644
--- a/tinyusb/tusb.h
+++ b/tinyusb/tusb.h
@@ -110,12 +110,14 @@ tusb_error_t tusb_init(void);
@code
int main(void)
{
- // some init code
+ your_init_code();
tusb_init();
+
while(1) // the mainloop
{
- tusb_task_runner();
- // other code
+ your_application_code();
+
+ tusb_task_runner(); // handle tinyusb event, task etc ...
}
}
@endcode
diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h
index e4169d4cc..b1fd46ef0 100644
--- a/tinyusb/tusb_option.h
+++ b/tinyusb/tusb_option.h
@@ -107,14 +107,14 @@
//--------------------------------------------------------------------+
/**
determines the debug level for the stack
- - Level 3: ATTR_ALWAYS_INLINE is null, ASSERT has text, Error has its String, STATIC_VAR is NULL
- - Level 2: ATTR_ALWAYS_INLINE is attribute, ASSERT has no text, Error has no strings
- - Level 1: TBD
+ - Level 3: TBD
+ - Level 2: ATTR_ALWAYS_INLINE is null --> no function is inline
+ - Level 1: Print out if Assert failed. STATIC_VAR is NULL --> accessible when debugging
- Level 0: no debug information is generated
*/
#ifndef TUSB_CFG_DEBUG
- #define TUSB_CFG_DEBUG 2
- #warning TUSB_CFG_DEBUG is not defined, default value is 3
+ #define TUSB_CFG_DEBUG 0
+ #warning TUSB_CFG_DEBUG is not defined, default value is 0
#endif
#ifndef TUSB_CFG_ATTR_USBRAM