2 * General Utility Library for STM32
4 * (c) 2018--2019 Martin Mareš <mj@ucw.cz>
15 typedef unsigned int uint;
24 #define MIN(x,y) ((x) < (y) ? (x) : (y))
25 #define MAX(x,y) ((x) > (y) ? (x) : (y))
27 #define UNUSED __attribute__((unused))
29 // Unaligned access to data
31 static inline uint get_u16_le(byte *p)
33 return (p[1] << 8) | p[0];
36 static inline uint get_u16_be(byte *p)
38 return (p[0] << 8) | p[1];
41 static inline uint get_u32_le(byte *p)
43 return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
46 static inline uint get_u32_be(byte *p)
48 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
51 static inline void put_u16_le(byte *p, u16 x)
57 static inline void put_u16_be(byte *p, u16 x)
63 static inline void put_u32_be(byte *p, u32 x)
66 p[1] = (x >> 16) & 0xff;
67 p[2] = (x >> 8) & 0xff;
71 static inline void put_u32_le(byte *p, u32 x)
74 p[2] = (x >> 16) & 0xff;
75 p[1] = (x >> 8) & 0xff;
81 void debug_printf(const char *fmt, ...);
82 void debug_puts(const char *s);
83 void debug_putc(int c);