+/*******************************************************************************/
+/* Byte swap instructions */
+/*******************************************************************************/
+/* Swap bytes of each 16-bit halfword in a 32-bit word, keeping halfword order */
+static inline uint32_t double_byte_swap_16(volatile uint32_t value)
+{
+ uint32_t result = 0;
+ __asm volatile ("rev16 %0, %1" : "=r" (result) : "r" (value));
+ return result;
+}
+/* Change endianness of a 16-bit halfword */
+static inline uint32_t byte_swap_16(volatile uint16_t value)
+{
+ uint32_t result = 0;
+ __asm volatile ("rev16 %0, %1" : "=r" (result) : "r" (value));
+ return (result & 0xFFFF);
+}
+/* Change endianness of a 32-bit word */
+static inline uint32_t byte_swap_32(volatile uint32_t value)
+{
+ uint32_t result = 0;
+ __asm volatile ("rev %0, %1" : "=r" (result) : "r" (value));
+ return result;
+}
+
+
+
+
+
/*******************************************************************************/
/* Interrupts */
/*******************************************************************************/