diff options
Diffstat (limited to 'firmware/system.h')
-rw-r--r-- | firmware/system.h | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/firmware/system.h b/firmware/system.h index 342b60cba0..1191e59843 100644 --- a/firmware/system.h +++ b/firmware/system.h | |||
@@ -22,36 +22,12 @@ | |||
22 | 22 | ||
23 | #include "sh7034.h" | 23 | #include "sh7034.h" |
24 | 24 | ||
25 | /* | 25 | #define FREQ 12000000 /* cycle time ~83.3ns */ |
26 | * 11.059,200 MHz => 90.4224537037037037037037037037037... ns | ||
27 | * 12.000,000 MHz => 83.3333333333333333333333333333333... ns | ||
28 | */ | ||
29 | |||
30 | #define FREQ 12000000 | ||
31 | #define BAUDRATE 9600 | 26 | #define BAUDRATE 9600 |
32 | 27 | ||
33 | //#define PHI ((int)(11.059200 MHz)) | ||
34 | //#define BAUDRATE 115200 /* 115200 - 9600 */ | ||
35 | |||
36 | #ifdef LITTLE_ENDIAN | 28 | #ifdef LITTLE_ENDIAN |
37 | #define SWAB16(x) (x) | 29 | #define SWAB16(x) (x) |
38 | #define SWAB32(x) (x) | 30 | #define SWAB32(x) (x) |
39 | #else | ||
40 | #define SWAB16(x) \ | ||
41 | ({ \ | ||
42 | unsigned short __x = x; \ | ||
43 | (((__x & 0x00ff) << 8) | \ | ||
44 | ((__x & 0xff00) >> 8)); \ | ||
45 | }) | ||
46 | |||
47 | #define SWAB32(x) \ | ||
48 | ({ \ | ||
49 | unsigned long __x = x; \ | ||
50 | (((__x & 0x000000ff) << 24) | \ | ||
51 | ((__x & 0x0000ff00) << 8) | \ | ||
52 | ((__x & 0x00ff0000) >> 8) | \ | ||
53 | ((__x & 0xff000000) >> 24)); \ | ||
54 | }) | ||
55 | #endif | 31 | #endif |
56 | 32 | ||
57 | #define nop \ | 33 | #define nop \ |
@@ -188,38 +164,38 @@ extern char __swap_bit[256]; | |||
188 | 164 | ||
189 | #ifndef SIMULATOR | 165 | #ifndef SIMULATOR |
190 | 166 | ||
191 | static inline short swabHI (short value) | 167 | static inline short SWAB16(short value) |
192 | /* | 168 | /* |
193 | result[15..8] = value[ 7..0]; | 169 | result[15..8] = value[ 7..0]; |
194 | result[ 7..0] = value[15..8]; | 170 | result[ 7..0] = value[15..8]; |
195 | */ | 171 | */ |
196 | { | 172 | { |
197 | short result; | 173 | short result; |
198 | asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value)); | 174 | asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value)); |
199 | return result; | 175 | return result; |
200 | } | 176 | } |
201 | 177 | ||
202 | static inline int swawSI (int value) | 178 | static inline long SWAW32(long value) |
203 | /* | 179 | /* |
204 | result[31..16] = value[15.. 0]; | 180 | result[31..16] = value[15.. 0]; |
205 | result[15.. 0] = value[31..16]; | 181 | result[15.. 0] = value[31..16]; |
206 | */ | 182 | */ |
207 | { | 183 | { |
208 | int result; | 184 | long result; |
209 | asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value)); | 185 | asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value)); |
210 | return result; | 186 | return result; |
211 | } | 187 | } |
212 | 188 | ||
213 | static inline int swabSI (int value) // should be avoided as much as possible | 189 | static inline long SWAB32(long value) |
214 | /* | 190 | /* |
215 | result[31..24] = value[ 7.. 0]; | 191 | result[31..24] = value[ 7.. 0]; |
216 | result[23..16] = value[15.. 8]; | 192 | result[23..16] = value[15.. 8]; |
217 | result[15.. 8] = value[23..16]; | 193 | result[15.. 8] = value[23..16]; |
218 | result[ 7.. 0] = value[31..24]; | 194 | result[ 7.. 0] = value[31..24]; |
219 | */ | 195 | */ |
220 | { | 196 | { |
221 | return swabHI(swawSI(swabSI(value))); | 197 | return SWAB16(SWAW32(SWAB16(value))); |
222 | } | 198 | } |
223 | 199 | ||
224 | /* Test And Set - UNTESTED */ | 200 | /* Test And Set - UNTESTED */ |
225 | static inline int tas (volatile int *pointer) | 201 | static inline int tas (volatile int *pointer) |