mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Revision:
160:5571c4ff569f
Parent:
142:4eea097334d6
diff -r 1c57384330a6 -r 5571c4ff569f TARGET_TB_SENSE_12/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_common.h
--- a/TARGET_TB_SENSE_12/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_common.h	Thu Nov 23 11:44:04 2017 +0000
+++ b/TARGET_TB_SENSE_12/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_common.h	Wed Jan 17 16:13:02 2018 +0000
@@ -1,9 +1,9 @@
 /***************************************************************************//**
  * @file em_common.h
  * @brief General purpose utilities.
- * @version 5.1.2
+ * @version 5.3.3
  *******************************************************************************
- * @section License
+ * # License
  * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
  *******************************************************************************
  *
@@ -116,7 +116,7 @@
 
 #if defined(__ICCARM__)
 /** @brief IAR Embedded Workbench: Macros for handling aligned structs. */
-#define SL_ALIGN(X) _Pragma(STRINGIZE(data_alignment=X))
+#define SL_ALIGN(X) _Pragma(STRINGIZE(data_alignment = X))
 
 /** @brief IAR Embedded Workbench: Macros for handling weak symbols. */
 #define SL_WEAK __weak
@@ -124,9 +124,11 @@
 /** @brief IAR Embedded Workbench: Macro for handling non-returning functions. */
 #define SL_NORETURN __noreturn
 
+/* *INDENT-OFF* */
 /** IAR Embedded Workbench: Macro for handling section placement */
 #define SL_ATTRIBUTE_SECTION(X) @ X
 #endif
+/* *INDENT-ON* */
 
 #define SL_ATTRIBUTE_ALIGN(X)
 
@@ -134,10 +136,10 @@
 /* GCC compilers */
 
 /** @brief Macro for getting minimum value. No sideeffects, a and b are evaluated once only. */
-#define SL_MIN(a, b) __extension__({__typeof__(a) _a = (a); __typeof__(b) _b = (b); _a < _b ? _a : _b;})
+#define SL_MIN(a, b) __extension__({ __typeof__(a)_a = (a); __typeof__(b)_b = (b); _a < _b ? _a : _b; })
 
 /** @brief Macro for getting maximum value. No sideeffects, a and b are evaluated once only. */
-#define SL_MAX(a, b) __extension__({__typeof__(a) _a = (a); __typeof__(b) _b = (b); _a > _b ? _a : _b;})
+#define SL_MAX(a, b) __extension__({ __typeof__(a)_a = (a); __typeof__(b)_b = (b); _a > _b ? _a : _b; })
 
 /** @brief GCC style macro for handling packed structs. */
 #define SL_ATTRIBUTE_PACKED __attribute__ ((packed))
@@ -198,18 +200,63 @@
 
 #else
   uint32_t zeros;
-  for(zeros=0; (zeros<32) && ((value&0x1) == 0); zeros++, value>>=1);
+  for (zeros = 0; (zeros < 32) && ((value & 0x1) == 0); zeros++, value >>= 1) {
+    ;
+  }
   return zeros;
 #endif
 }
 
-
 /* Deprecated function. New code should use @ref SL_CTZ. */
 __STATIC_INLINE uint32_t EFM32_CTZ(uint32_t value)
 {
   return SL_CTZ(value);
 }
 
+/***************************************************************************//**
+ * @brief
+ *   Reverse the bits. Use the RBIT instruction if available, else process.
+ *
+ * @param[in] value
+ *   Data value to reverse.
+ *
+ * @return
+ *   Reversed value.
+ ******************************************************************************/
+__STATIC_INLINE uint32_t SL_RBIT(uint32_t value)
+{
+  uint32_t result;
+
+#if (__CORTEX_M >= 0x03U)
+  result = __RBIT(value);
+#else
+  int32_t s = 4 * 8 - 1;
+
+  result = value;
+  for (value >>= 1U; value; value >>= 1U) {
+    result <<= 1U;
+    result |= value & 1U;
+    s--;
+  }
+  result <<= s;
+#endif
+  return result;
+}
+
+/***************************************************************************//**
+ * @brief
+ *   Reverse the bits. Use the RBIT instruction if available, else process.
+ *
+ * @param[in] value
+ *   16-bit data value to reverse.
+ *
+ * @return
+ *   16-bit reversed value.
+ ******************************************************************************/
+__STATIC_INLINE uint32_t SL_RBIT16(uint32_t value)
+{
+  return SL_RBIT(value) >> 16;
+}
 
 /** @} (end addtogroup COMMON) */
 /** @} (end addtogroup emlib) */