4 typedef unsigned int uint;
11 #define MIN(x,y) ((x) < (y) ? (x) : (y))
12 #define MAX(x,y) ((x) > (y) ? (x) : (y))
14 #define UNUSED __attribute__((unused))
16 static inline uint get_u16_le(byte *p)
18 return (p[1] << 8) | p[0];
21 static inline uint get_u16_be(byte *p)
23 return (p[0] << 8) | p[1];
26 static inline uint get_u32_le(byte *p)
28 return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
31 static inline uint get_u32_be(byte *p)
33 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
36 static inline void put_u16_le(byte *p, u16 x)
42 static inline void put_u16_be(byte *p, u16 x)
48 static inline void put_u32_be(byte *p, u32 x)
51 p[1] = (x >> 16) & 0xff;
52 p[2] = (x >> 8) & 0xff;
56 static inline void put_u32_le(byte *p, u32 x)
59 p[2] = (x >> 16) & 0xff;
60 p[1] = (x >> 8) & 0xff;
66 // #define DEBUG_SEMIHOSTING
67 #define DEBUG_USART USART1
69 void debug_printf(const char *fmt, ...);
70 void debug_puts(const char *s);
71 void debug_putc(int c);