summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2019-12-24 21:11:40 +0700
committerGitHub <[email protected]>2019-12-24 21:11:40 +0700
commit21cc8237e1130c489bc4ef3b7dea1c41eef25d56 (patch)
treede9ef9a7d0bff897e84ec46853f21170900d250e /src/common
parenta601f59df5e61801cbbe87467c70a48b740d4bfd (diff)
parentbbada1d3e6dba5b339c7cd4129e5df7b3203c11b (diff)
Merge pull request #243 from hathach/port-samg55
merge WIP branch for samd dcd fix
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_common.h43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 59e1fe7fd..5700c1282 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -139,9 +139,9 @@ static inline uint8_t tu_log2(uint32_t value)
}
// Bit
-static inline uint32_t tu_bit_set (uint32_t value, uint8_t n) { return value | TU_BIT(n); }
-static inline uint32_t tu_bit_clear(uint32_t value, uint8_t n) { return value & (~TU_BIT(n)); }
-static inline bool tu_bit_test (uint32_t value, uint8_t n) { return (value & TU_BIT(n)) ? true : false; }
+static inline uint32_t tu_bit_set (uint32_t value, uint8_t pos) { return value | TU_BIT(pos); }
+static inline uint32_t tu_bit_clear(uint32_t value, uint8_t pos) { return value & (~TU_BIT(pos)); }
+static inline bool tu_bit_test (uint32_t value, uint8_t pos) { return (value & TU_BIT(pos)) ? true : false; }
/*------------------------------------------------------------------*/
/* Count number of arguments of __VA_ARGS__
@@ -213,22 +213,47 @@ static inline bool tu_bit_test (uint32_t value, uint8_t n) { return (value &
// 2 : print out log
#if CFG_TUSB_DEBUG
-void tu_print_mem(void const *buf, uint8_t size, uint16_t count);
+void tu_print_mem(void const *buf, uint16_t count, uint8_t indent);
#ifndef tu_printf
- #define tu_printf printf
+ #define tu_printf printf
#endif
// Log with debug level 1
-#define TU_LOG1 tu_printf
-#define TU_LOG1_MEM tu_print_mem
+#define TU_LOG1 tu_printf
+#define TU_LOG1_MEM tu_print_mem
+#define TU_LOG1_LOCATION() tu_printf("%s: %d:\n", __PRETTY_FUNCTION__, __LINE__)
// Log with debug level 2
#if CFG_TUSB_DEBUG > 1
- #define TU_LOG2 TU_LOG1
- #define TU_LOG2_MEM TU_LOG1_MEM
+ #define TU_LOG2 TU_LOG1
+ #define TU_LOG2_MEM TU_LOG1_MEM
+ #define TU_LOG2_LOCATION() TU_LOG1_LOCATION()
#endif
+
+typedef struct
+{
+ uint32_t key;
+ char const * data;
+}lookup_entry_t;
+
+typedef struct
+{
+ uint16_t count;
+ lookup_entry_t const* items;
+} lookup_table_t;
+
+static inline char const* lookup_find(lookup_table_t const* p_table, uint32_t key)
+{
+ for(uint16_t i=0; i<p_table->count; i++)
+ {
+ if (p_table->items[i].key == key) return p_table->items[i].data;
+ }
+
+ return NULL;
+}
+
#endif // CFG_TUSB_DEBUG
#ifndef TU_LOG1