summaryrefslogtreecommitdiff
path: root/tinyusb/common/common.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-12-27 13:40:31 +0700
committerhathach <[email protected]>2013-12-27 13:40:59 +0700
commit275e834bbed4928094b0a631c7dd36fdcc0b40fe (patch)
treeef56607443081a29ab50fa17452294add7141f33 /tinyusb/common/common.h
parent8de6ee22dc81d871a14d3c3cb63aa3863a5cb2d6 (diff)
add device_os_none keil project for all boards
Diffstat (limited to 'tinyusb/common/common.h')
-rw-r--r--tinyusb/common/common.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h
index 399b419b9..3ab530e6a 100644
--- a/tinyusb/common/common.h
+++ b/tinyusb/common/common.h
@@ -85,7 +85,6 @@
#include "osal/osal.h"
-
//--------------------------------------------------------------------+
// MACROS
//--------------------------------------------------------------------+
@@ -110,7 +109,14 @@
#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)
-#define __n2be_16(u16) ((uint16_t) ((U16_LOW_U8(u16) << 8) | U16_HIGH_U8(u16)) ) // TODO refractor later
+//------------- Endian Conversion -------------//
+#define ENDIAN_BE(le32) \
+ (uint32_t) ( ((le32 & 0xFF) << 24) | ((le32 & 0xFF00) << 8) | ((le32 >> 8) & 0xFF00) | ((le32 >> 24) & 0xFF) )
+
+#define ENDIAN_BE16(le16) ((uint16_t) ((U16_LOW_U8(le16) << 8) | U16_HIGH_U8(le16)) )
+
+// TODO refractor to built-in function
+#define __n2be_16(u16) ((uint16_t) ((U16_LOW_U8(u16) << 8) | U16_HIGH_U8(u16)) )
#define __be2n_16(u16) __n2be_16(u16)
//--------------------------------------------------------------------+