From e57a25456e597375bc1168c4a953fa1f29112e5f Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Wed, 8 Feb 2017 12:28:22 +0100 Subject: [PATCH] util: add read big endian 24 --- src/btstack_util.c | 4 ++++ src/btstack_util.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/btstack_util.c b/src/btstack_util.c index c93430739..c15192f46 100644 --- a/src/btstack_util.c +++ b/src/btstack_util.c @@ -95,6 +95,10 @@ uint32_t big_endian_read_16( const uint8_t * buffer, int pos) { return ((uint16_t) buffer[(pos)+1]) | (((uint16_t)buffer[ pos ]) << 8); } +uint32_t big_endian_read_24( const uint8_t * buffer, int pos) { + return ( ((uint32_t)buffer[(pos)+2]) | (((uint32_t)buffer[(pos)+1]) << 8) | (((uint32_t) buffer[pos]) << 16)); +} + uint32_t big_endian_read_32( const uint8_t * buffer, int pos) { return ((uint32_t) buffer[(pos)+3]) | (((uint32_t)buffer[(pos)+2]) << 8) | (((uint32_t)buffer[(pos)+1]) << 16) | (((uint32_t) buffer[pos]) << 24); } diff --git a/src/btstack_util.h b/src/btstack_util.h index cf1eeb641..12387074b 100644 --- a/src/btstack_util.h +++ b/src/btstack_util.h @@ -117,6 +117,7 @@ void little_endian_store_32(uint8_t *buffer, uint16_t position, uint32_t value); * @return value */ uint32_t big_endian_read_16( const uint8_t * buffer, int pos); +uint32_t big_endian_read_24( const uint8_t * buffer, int pos); uint32_t big_endian_read_32( const uint8_t * buffer, int pos); /**