diff options
| author | hathach <[email protected]> | 2013-05-12 19:32:32 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-05-12 19:32:32 +0700 |
| commit | cc496074347543d19bbcc691dd46d05db2817b51 (patch) | |
| tree | 1b5e3651d3ddb47b9a0c2f73b09427e0216ee996 /tinyusb/common | |
| parent | 81780008e977fc2093155bfb7be63e00447ad3be (diff) | |
test refractor
Diffstat (limited to 'tinyusb/common')
| -rw-r--r-- | tinyusb/common/common.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index fd1d2b293..63ba26d56 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -83,14 +83,14 @@ #define STRING_CONCAT_(a, b) a##b // concat without expand #define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) // expand then concat -#define U16_HIGH_U8(u16) ((uint8_t) (((u16) > 8) & 0x00ff)) +#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_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) @@ -109,6 +109,18 @@ static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4; } +static inline uint8_t u16_high_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE; +static inline uint8_t u16_high_u8(uint16_t u16) +{ + return (uint8_t) ((u16 >> 8) & 0x00ff); +} + +static inline uint8_t u16_low_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE; +static inline uint8_t u16_low_u8(uint16_t u16) +{ + return (uint8_t) (u16 & 0x00ff); +} + //------------- Min -------------// static inline uint8_t min8_of(uint8_t x, uint8_t y) ATTR_ALWAYS_INLINE ATTR_CONST; static inline uint8_t min8_of(uint8_t x, uint8_t y) |
