]> mj.ucw.cz Git - home-hw.git/blobdiff - ssr/Inc/util.h
FIXME'd
[home-hw.git] / ssr / Inc / util.h
index 405098c869505bb5ae6780c5c1c1da12edba0ad2..d463fcc3264c789c6543c1b50ccd83a5bcf95ce9 100644 (file)
@@ -16,6 +16,21 @@ static inline uint get_u16_le(byte *p)
   return (p[1] << 8) | p[0];
 }
 
+static inline uint get_u16_be(byte *p)
+{
+  return (p[0] << 8) | p[1];
+}
+
+static inline uint get_u32_le(byte *p)
+{
+  return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
+}
+
+static inline uint get_u32_be(byte *p)
+{
+  return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+}
+
 static inline void put_u16_le(byte *p, u16 x)
 {
   p[0] = x;
@@ -36,10 +51,18 @@ static inline void put_u32_be(byte *p, u32 x)
   p[3] = x & 0xff;
 }
 
+static inline void put_u32_le(byte *p, u32 x)
+{
+  p[3] = x >> 24;
+  p[2] = (x >> 16) & 0xff;
+  p[1] = (x >> 8) & 0xff;
+  p[0] = x & 0xff;
+}
+
 // debug.c
 
-#undef DEBUG_SEMIHOSTING
-#define DEBUG_USART USART1
+// #define DEBUG_SEMIHOSTING
+// #define DEBUG_USART USART1
 
 void debug_printf(const char *fmt, ...);
 void debug_puts(const char *s);