}
#define WL16(p, x) write_u16le((uint8_t *)(p), (uint16_t)(x))
+/**
+ * Write a 24 bits unsigned integer to memory stored as little endian.
+ * @param p a pointer to the output memory
+ * @param x the input unsigned integer
+ */
+static inline void write_u24le(uint8_t *p, uint32_t x)
+{
+ p[0] = x & 0xff; x >>= 8;
+ p[1] = x & 0xff; x >>= 8;
+ p[2] = x & 0xff; x >>= 8;
+}
+#define WL24(p, x) write_u24le((uint8_t *)(p), (uint32_t)(x))
+
/**
* Write a 32 bits unsigned integer to memory stored as big endian.
* @param p a pointer to the output memory
}
#define WL32(p, x) write_u32le((uint8_t *)(p), (uint32_t)(x))
+/**
+ * Write a 40 bits unsigned integer to memory stored as little endian.
+ * @param p a pointer to the output memory
+ * @param x the input unsigned integer
+ */
+static inline void write_u40le(uint8_t *p, uint64_t x)
+{
+ p[0] = x & 0xff; x >>= 8;
+ p[1] = x & 0xff; x >>= 8;
+ p[2] = x & 0xff; x >>= 8;
+ p[3] = x & 0xff; x >>= 8;
+ p[4] = x & 0xff; x >>= 8;
+}
+#define WL40(p, x) write_u40le((uint8_t *)(p), (uint64_t)(x))
+
/**
* Write a 48 bits unsigned integer to memory stored as little endian.
* @param p a pointer to the output memory
*p += sizeof(x);
}
+/**
+ * Write unsigned 24bit liggle endian integer to raw memory, increment write position.
+ * @param[in, out] p Pointer into byte stream.
+ * @param[in] x Value to write.
+ */
+static inline void write_u24le_inc(uint8_t **p, uint32_t x)
+{
+ if (!p || !*p)
+ return;
+ write_u24le(*p, x);
+ *p += 3 * sizeof(uint8_t);
+}
+
/**
* Write unsigned 32bit big endian integer to raw memory, increment write position.
* @param[in, out] p Pointer into byte stream.
*p += sizeof(x);
}
+/**
+ * Write unsigned 40bit little endian integer to raw memory, increment write position.
+ * @param[in, out] p Pointer into byte stream.
+ * @param[in] x Value to write.
+ */
+static inline void write_u40le_inc(uint8_t **p, uint64_t x)
+{
+ if (!p || !*p)
+ return;
+ write_u40le(*p, x);
+ *p += 5 * sizeof(uint8_t);
+}
+
/**
* Write unsigned 48bit little endian integer to raw memory, increment write position.
* @param[in, out] p Pointer into byte stream.