summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-10-24 13:27:38 +0200
committerHiFiPhile <[email protected]>2025-10-24 13:27:38 +0200
commit9f1a86c0cbf2974775687848a95a126c6503c1cf (patch)
tree5a682189a6eb3398e01144cd1c8ce9623e652632 /src
parent4dd9122417bfbad51d38e4e6079d1823fdd05f6c (diff)
Ensure type promotion
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/common/tusb_common.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 26db85373..8b988b4f5 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -41,16 +41,16 @@
#define TU_DIV_CEIL(n, d) (((n) + (d) - 1) / (d))
#define TU_DIV_ROUND_NEAREST(v, d) (((v) + (d)/2) / (d) ) // round to nearest integer
-#define TU_U16(_high, _low) ((uint16_t) (((_high) << 8) | (_low)))
-#define TU_U16_HIGH(_u16) ((uint8_t) (((_u16) >> 8) & 0x00ff))
-#define TU_U16_LOW(_u16) ((uint8_t) ((_u16) & 0x00ff))
+#define TU_U16(_high, _low) ((uint16_t) ((((uint16_t) (_high)) << 8) | ((uint16_t) (_low))))
+#define TU_U16_HIGH(_u16) ((uint8_t) (((uint16_t) (_u16) >> 8) & 0x00ffu))
+#define TU_U16_LOW(_u16) ((uint8_t) ((uint16_t) (_u16) & 0x00ffu))
#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 TU_U24(_high, _mid, _low) ((uint32_t) ((((uint32_t) (_high)) << 16) | (((uint32_t) (_mid)) << 8) | ((uint32_t) (_low))))
+#define TU_U24_HIGH(_u24) ((uint8_t) (((uint32_t) (_u24) >> 16) & 0x0000ffu))
+#define TU_U24_MID(_u24) ((uint8_t) (((uint32_t) (_u24) >> 8) & 0x0000ffu))
+#define TU_U24_LOW(_u24) ((uint8_t) ((uint32_t) (_u24) & 0x0000ffu))
#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)