From 7475550ae8e4f128ac829a0d178298c72f840ce3 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 29 May 2019 17:27:41 +0200 Subject: [PATCH] Add buffer_read16be() Add a function to read 16 bits in big-endian to a uint16_t. --- app/src/buffer_util.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/buffer_util.h b/app/src/buffer_util.h index 4bfd08d3..a79014b1 100644 --- a/app/src/buffer_util.h +++ b/app/src/buffer_util.h @@ -18,6 +18,11 @@ buffer_write32be(uint8_t *buf, uint32_t value) { buf[3] = value; } +static inline uint16_t +buffer_read16be(const uint8_t *buf) { + return (buf[0] << 8) | buf[1]; +} + static inline uint32_t buffer_read32be(const uint8_t *buf) { return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];