From: Mathieu Pilato Date: Fri, 31 Mar 2023 19:59:15 +0000 (+0200) Subject: libsigrok-internal.h: Add read_u24be helper function X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7d893e3bf60c287f16d1e5f39a98fa823f33a9d2;p=libsigrok.git libsigrok-internal.h: Add read_u24be helper function --- diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index df149bce..215fce16 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -172,6 +172,23 @@ static inline uint32_t read_u24le(const uint8_t *p) return u; } +/** + * Read a 24 bits big endian unsigned integer out of memory. + * @param x a pointer to the input memory + * @return the corresponding unsigned integer + */ +static inline uint32_t read_u24be(const uint8_t *p) +{ + uint32_t u; + + u = 0; + u <<= 8; u |= p[0]; + u <<= 8; u |= p[1]; + u <<= 8; u |= p[2]; + + return u; +} + /** * Read a 32 bits big endian unsigned integer out of memory. * @param x a pointer to the input memory