]> mj.ucw.cz Git - home-hw.git/blobdiff - Inc/util.h
Whoa! Interrupt-driven I2C is working!
[home-hw.git] / Inc / util.h
index 388a1bd758946472fc8a1ba8701c9f03d5ec4de5..827cc9c4a09082cf23336f38c7de54c5b3de9ace 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdint.h>
+#include <stdbool.h>
 
 typedef unsigned int uint;
 typedef uint8_t byte;
@@ -10,9 +11,20 @@ typedef int32_t s32;
 #define MIN(x,y) ((x) < (y) ? (x) : (y))
 #define MAX(x,y) ((x) > (y) ? (x) : (y))
 
+static inline uint get_u16_le(byte *p)
+{
+  return (p[1] << 8) | p[0];
+}
+
+static inline void put_u16_le(byte *p, u16 x)
+{
+  p[0] = x;
+  p[1] = x >> 8;
+}
+
 // debug.c
 
-#undef DEBUG_SEMIHOSTING
+#define DEBUG_SEMIHOSTING
 
 void debug_printf(const char *fmt, ...);
 void debug_puts(const char *s);