Skip to content

Commit 1037946

Browse files
author
Jarkko Paso
committed
Common write 24-bit inverse implemented
1 parent 09056ed commit 1037946

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
@@ -114,6 +114,18 @@ NS_INLINE uint8_t *common_write_24_bit(uint_fast24_t value, uint8_t ptr[__static
114114
*/
115115
NS_INLINE uint_fast24_t common_read_24_bit(const uint8_t data_buf[__static 3]);
116116

117+
/*
118+
* Common write 24-bit variable to 8-bit pointer.
119+
*
120+
* Write 24 bits in little-endian byte order.
121+
*
122+
* \param value 24-bit variable
123+
* \param ptr pointer where data to be written
124+
*
125+
* \return updated pointer
126+
*/
127+
NS_INLINE uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3]);
128+
117129
/*
118130
* Common write 16-bit variable to 8-bit pointer.
119131
*
@@ -420,6 +432,14 @@ COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit(const uint8_t data_buf[__st
420432
return temp_24;
421433
}
422434

435+
COMMON_FUNCTIONS_FN uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3])
436+
{
437+
*ptr++ = value;
438+
*ptr++ = value >> 8;
439+
*ptr++ = value >> 16;
440+
return ptr;
441+
}
442+
423443
COMMON_FUNCTIONS_FN uint8_t *common_write_16_bit(uint16_t value, uint8_t ptr[__static 2])
424444
{
425445
*ptr++ = value >> 8;

0 commit comments

Comments
 (0)