Merge commit 'd6732a1b96814a2ea635b3d517f498127843a097'

* commit 'd6732a1b96814a2ea635b3d517f498127843a097':
  Squashed 'features/frameworks/nanostack-libservice/' changes from 09056ed..ddd45db
pull/6876/head
Juhani Puurula 2018-05-11 09:59:29 +03:00
commit 7c38f19745
1 changed files with 40 additions and 0 deletions

View File

@ -114,6 +114,29 @@ NS_INLINE uint8_t *common_write_24_bit(uint_fast24_t value, uint8_t ptr[__static
*/
NS_INLINE uint_fast24_t common_read_24_bit(const uint8_t data_buf[__static 3]);
/*
* Common write 24-bit variable to 8-bit pointer.
*
* Write 24 bits in little-endian byte order.
*
* \param value 24-bit variable
* \param ptr pointer where data to be written
*
* \return updated pointer
*/
NS_INLINE uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3]);
/*
* Common read 24-bit variable from 8-bit pointer.
*
* Read 24 bits in little-endian byte order.
*
* \param data_buf pointer where data to be read
*
* \return 24-bit variable
*/
NS_INLINE uint_fast24_t common_read_24_bit_inverse(const uint8_t data_buf[__static 3]);
/*
* Common write 16-bit variable to 8-bit pointer.
*
@ -420,6 +443,23 @@ COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit(const uint8_t data_buf[__st
return temp_24;
}
COMMON_FUNCTIONS_FN uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3])
{
*ptr++ = value;
*ptr++ = value >> 8;
*ptr++ = value >> 16;
return ptr;
}
COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit_inverse(const uint8_t data_buf[__static 3])
{
uint_fast24_t temp_24;
temp_24 = *data_buf++;
temp_24 += (uint_fast24_t)(*data_buf++) << 8;
temp_24 += (uint_fast24_t)(*data_buf++) << 16;
return temp_24;
}
COMMON_FUNCTIONS_FN uint8_t *common_write_16_bit(uint16_t value, uint8_t ptr[__static 2])
{
*ptr++ = value >> 8;