]> mj.ucw.cz Git - home-hw.git/blob - Inc/util.h
Request/reply protocol
[home-hw.git] / Inc / util.h
1 #include <stdint.h>
2 #include <stdbool.h>
3
4 typedef unsigned int uint;
5 typedef uint8_t byte;
6 typedef uint16_t u16;
7 typedef int16_t s16;
8 typedef uint32_t u32;
9 typedef int32_t s32;
10
11 #define MIN(x,y) ((x) < (y) ? (x) : (y))
12 #define MAX(x,y) ((x) > (y) ? (x) : (y))
13
14 static inline uint get_u16_le(byte *p)
15 {
16   return (p[1] << 8) | p[0];
17 }
18
19 static inline void put_u16_le(byte *p, u16 x)
20 {
21   p[0] = x;
22   p[1] = x >> 8;
23 }
24
25 // debug.c
26
27 #undef DEBUG_SEMIHOSTING
28
29 void debug_printf(const char *fmt, ...);
30 void debug_puts(const char *s);
31 void debug_putc(int c);