summaryrefslogtreecommitdiff
path: root/tinyusb/common
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-02-05 13:57:06 +0700
committerhathach <[email protected]>2013-02-05 13:57:06 +0700
commitaeccdfde3f4462fae5e3b9cbb4eae76526bdb204 (patch)
treeb70a35ec9335c085817aa11208b7e37a7c02fc91 /tinyusb/common
parentaa040c4c984039ba9b5820aa15fd0264582bc207 (diff)
remove TUSB prefix for class enum definitions
add most of HID USAGE TABLE and definitions etc ...
Diffstat (limited to 'tinyusb/common')
-rw-r--r--tinyusb/common/common.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h
index ec3e3f2ac..403ca5d6c 100644
--- a/tinyusb/common/common.h
+++ b/tinyusb/common/common.h
@@ -86,6 +86,18 @@
#define STRING_(x) #x // stringify without expand
#define XSTRING_(x) STRING_(x) // expand then stringify
+#define U16_HIGH_U8(u16) ((uint8_t) (((u16) > 8) & 0x00ff))
+#define U16_LOW_U8(u16) ((uint8_t) ((u16) & 0x00ff))
+#define U16_TO_U8S_BE(u16) U16_HIGH_U8(u16), U16_LOW_U8(u16)
+#define U16_TO_U8S_LE(u16) U16_LOW_U8(u16), U16_HIGH_U8(u16)
+
+#define U32_B1_U8(u32) ((uint8_t) (((u32) > 24) & 0x000000ff)) // MSB
+#define U32_B2_U8(u32) ((uint8_t) (((u32) > 16) & 0x000000ff))
+#define U32_B3_U8(u32) ((uint8_t) (((u32) > 8) & 0x000000ff))
+#define U32_B4_U8(u32) ((uint8_t) ((u32) & 0x000000ff)) // LSB
+
+#define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32)
+#define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32)
/// form an uint32_t from 4 x uint8_t
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST;
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4)