summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-09-28 17:17:10 +0200
committerMengsk <[email protected]>2025-09-30 15:51:50 +0200
commit9637a2006bdfa77911cd274f0b9cff7de7ae54e9 (patch)
tree3791cc14e05e6ff12b7d8934ec08e32450477e0a /src/common
parent78121a8d3f273420f8a2798364c2dd2fb9bb700f (diff)
More descriptors working
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_common.h7
-rw-r--r--src/common/tusb_compiler.h12
2 files changed, 19 insertions, 0 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 9c4699362..a9997ad3f 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -45,6 +45,13 @@
#define U16_TO_U8S_BE(_u16) TU_U16_HIGH(_u16), TU_U16_LOW(_u16)
#define U16_TO_U8S_LE(_u16) TU_U16_LOW(_u16), TU_U16_HIGH(_u16)
+#define TU_U24(_high, _mid, _low) ((uint32_t) (((_high) << 16) | ((_mid) << 8) | (_low)))
+#define TU_U24_HIGH(_u24) ((uint8_t) (((_u24) >> 16) & 0x0000ff))
+#define TU_U24_MID(_u24) ((uint8_t) (((_u24) >> 8) & 0x0000ff))
+#define TU_U24_LOW(_u24) ((uint8_t) (((_u24) ) & 0x0000ff))
+#define U24_TO_U8S_BE(_u24) TU_U24_HIGH(_u24), TU_U24_MID(_u24), TU_U24_LOW(_u24)
+#define U24_TO_U8S_LE(_u24) TU_U24_LOW(_u24), TU_U24_MID(_u24), TU_U24_HIGH(_u24)
+
#define TU_U32_BYTE3(_u32) ((uint8_t) ((((uint32_t) _u32) >> 24) & 0x000000ff)) // MSB
#define TU_U32_BYTE2(_u32) ((uint8_t) ((((uint32_t) _u32) >> 16) & 0x000000ff))
#define TU_U32_BYTE1(_u32) ((uint8_t) ((((uint32_t) _u32) >> 8) & 0x000000ff))
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index 9b33a6f61..b0dae6488 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -118,6 +118,18 @@
#define _TU_ARGS_APPLY_7(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1) _s _TU_ARGS_APPLY_6(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7)
#define _TU_ARGS_APPLY_8(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) _X(_a1) _s _TU_ARGS_APPLY_7(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7, _a8)
+// Apply an macro X to each of the arguments and expand the result wtih comma
+#define TU_ARGS_APPLY_EXPAND(_X, ...) TU_XSTRCAT(_TU_ARGS_APPLY_EXPAND_, TU_ARGS_NUM(__VA_ARGS__))(_X, __VA_ARGS__)
+
+#define _TU_ARGS_APPLY_EXPAND_1(_X, _a1) _X(_a1)
+#define _TU_ARGS_APPLY_EXPAND_2(_X, _a1, _a2) _X(_a1), _X(_a2)
+#define _TU_ARGS_APPLY_EXPAND_3(_X, _a1, _a2, _a3) _X(_a1), _TU_ARGS_APPLY_EXPAND_2(_X, _a2, _a3)
+#define _TU_ARGS_APPLY_EXPAND_4(_X, _a1, _a2, _a3, _a4) _X(_a1), _TU_ARGS_APPLY_EXPAND_3(_X, _a2, _a3, _a4)
+#define _TU_ARGS_APPLY_EXPAND_5(_X, _a1, _a2, _a3, _a4, _a5) _X(_a1), _TU_ARGS_APPLY_EXPAND_4(_X, _a2, _a3, _a4, _a5)
+#define _TU_ARGS_APPLY_EXPAND_6(_X, _a1, _a2, _a3, _a4, _a5, _a6) _X(_a1), _TU_ARGS_APPLY_EXPAND_5(_X, _a2, _a3, _a4, _a5, _a6)
+#define _TU_ARGS_APPLY_EXPAND_7(_X, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1), _TU_ARGS_APPLY_EXPAND_6(_X, _a2, _a3, _a4, _a5, _a6, _a7)
+#define _TU_ARGS_APPLY_EXPAND_8(_X, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) _X(_a1), _TU_ARGS_APPLY_EXPAND_7(_X, _a2, _a3, _a4, _a5, _a6, _a7, _a8)
+
//--------------------------------------------------------------------+
// Macro for function default arguments
//--------------------------------------------------------------------+