From 78e6bb8ee25ed3215b010f402a0af849b7f7d25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Sun, 21 Apr 2002 21:53:45 +0000 Subject: [PATCH] Added SWAB (swap bytes) macros git-svn-id: svn://svn.rockbox.org/rockbox/trunk@162 a1c6a512-1295-4272-9138-f99709370657 --- firmware/system.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/firmware/system.h b/firmware/system.h index 88c8449df4..8ffc7547b7 100644 --- a/firmware/system.h +++ b/firmware/system.h @@ -19,7 +19,8 @@ #ifndef __SYSTEM_H__ #define __SYSTEM_H__ -#include + +#include "sh7034.h" /* * 11.059,200 MHz => 90.4224537037037037037037037037037... ns @@ -32,6 +33,21 @@ //#define PHI ((int)(11.059200 MHz)) //#define BAUDRATE 115200 /* 115200 - 9600 */ +#ifdef LITTLE_ENDIAN +#define SWAB16(x) (x) +#define SWAB32(x) (x) +#else +#define SWAB16(x) \ + (((x & 0x00ff) << 8) | \ + ((x & 0xff00) >> 8)) + +#define SWAB32(x) \ + (((x & 0x000000ff) << 24) | \ + ((x & 0x0000ff00) << 8) | \ + ((x & 0x00ff0000) >> 8) | \ + ((x & 0xff000000) >> 24)) +#endif + #define nop \ asm volatile ("nop")