Skip to content

Commit 4720a2e

Browse files
author
Jarkko Paso
committed
Common read 24-bit inverse implemented
1 parent 1037946 commit 4720a2e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

mbed-client-libservice/common_functions.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ NS_INLINE uint_fast24_t common_read_24_bit(const uint8_t data_buf[__static 3]);
126126
*/
127127
NS_INLINE uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3]);
128128

129+
/*
130+
* Common read 24-bit variable from 8-bit pointer.
131+
*
132+
* Read 24 bits in little-endian byte order.
133+
*
134+
* \param data_buf pointer where data to be read
135+
*
136+
* \return 24-bit variable
137+
*/
138+
NS_INLINE uint_fast24_t common_read_24_bit_inverse(const uint8_t data_buf[__static 3]);
139+
129140
/*
130141
* Common write 16-bit variable to 8-bit pointer.
131142
*
@@ -440,6 +451,15 @@ COMMON_FUNCTIONS_FN uint8_t *common_write_24_bit_inverse(uint_fast24_t value, ui
440451
return ptr;
441452
}
442453

454+
COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit_inverse(const uint8_t data_buf[__static 3])
455+
{
456+
uint_fast24_t temp_24;
457+
temp_24 = *data_buf++;
458+
temp_24 += (uint_fast24_t)(*data_buf++) << 8;
459+
temp_24 += (uint_fast24_t)(*data_buf++) << 16;
460+
return temp_24;
461+
}
462+
443463
COMMON_FUNCTIONS_FN uint8_t *common_write_16_bit(uint16_t value, uint8_t ptr[__static 2])
444464
{
445465
*ptr++ = value >> 8;

0 commit comments

Comments
 (0)