X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ssr%2FInc%2Futil.h;h=d463fcc3264c789c6543c1b50ccd83a5bcf95ce9;hb=85cd812337ceb77c2fc5ab6b8ba91414a567cc0f;hp=0beed7c87232f5748061bc26b52585eb2524b8ea;hpb=08f734c44598ca90f47f4ab0dfed232c045dd403;p=home-hw.git diff --git a/ssr/Inc/util.h b/ssr/Inc/util.h index 0beed7c..d463fcc 100644 --- a/ssr/Inc/util.h +++ b/ssr/Inc/util.h @@ -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,9 +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 -#define DEBUG_SEMIHOSTING +// #define DEBUG_SEMIHOSTING +// #define DEBUG_USART USART1 void debug_printf(const char *fmt, ...); void debug_puts(const char *s);