Cordio Stack and Cordio Profiles  r2p3-02rel0
bstream.h File Reference

Byte stream to integer conversion macros. More...

#include "util/bda.h"
Include dependency graph for bstream.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

Macros for converting a little endian byte buffer to integers.
#define BYTES_TO_UINT16(n, p)    {n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8));}
 convert little endian byte buffer to uint16_t.
 
#define BYTES_TO_UINT24(n, p)
 convert little endian byte buffer to uint24_t. More...
 
#define BYTES_TO_UINT32(n, p)
 convert little endian byte buffer to uint32_t. More...
 
#define BYTES_TO_UINT40(n, p)
 convert little endian byte buffer to uint40_t. More...
 
#define BYTES_TO_UINT64(n, p)
 convert little endian byte buffer to uint64_t. More...
 
Macros for converting little endian integers to array of bytes
#define UINT16_TO_BYTES(n)    ((uint8_t) (n)), ((uint8_t)((n) >> 8))
 convert little endian uint16_t to array of bytes.
 
#define UINT32_TO_BYTES(n)    ((uint8_t) (n)), ((uint8_t)((n) >> 8)), ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 24))
 convert little endian uint32_t to array of bytes.
 
Macros for converting little endian integers to single bytes
#define UINT16_TO_BYTE0(n)    ((uint8_t) (n))
 convert little endian uint16_t to byte 0.
 
#define UINT16_TO_BYTE1(n)    ((uint8_t) ((n) >> 8))
 convert little endian uint16_t to byte 1.
 
#define UINT32_TO_BYTE0(n)    ((uint8_t) (n))
 convert little endian uint32_t to byte 0.
 
#define UINT32_TO_BYTE1(n)    ((uint8_t) ((n) >> 8))
 convert little endian uint32_t to byte 1.
 
#define UINT32_TO_BYTE2(n)    ((uint8_t) ((n) >> 16))
 convert little endian uint32_t to byte 2.
 
#define UINT32_TO_BYTE3(n)    ((uint8_t) ((n) >> 24))
 convert little endian uint32_t to byte 3.
 
Macros for converting a little endian byte stream to integers, with increment.
#define BSTREAM_TO_INT8(n, p)    {n = (int8_t)(*(p)++);}
 convert little endian byte stream to uint8_t, incrementing one byte.
 
#define BSTREAM_TO_UINT8(n, p)    {n = (uint8_t)(*(p)++);}
 convert little endian byte stream to int8_t, incrementing one byte.
 
#define BSTREAM_TO_UINT16(n, p)    {BYTES_TO_UINT16(n, p); p += 2;}
 convert little endian byte stream to uint16_t, incrementing two bytes.
 
#define BSTREAM_TO_UINT24(n, p)    {BYTES_TO_UINT24(n, p); p += 3;}
 convert little endian byte stream to uint24_t, incrementing three bytes.
 
#define BSTREAM_TO_UINT32(n, p)    {BYTES_TO_UINT32(n, p); p += 4;}
 convert little endian byte stream to uint32_t, incrementing four bytes.
 
#define BSTREAM_TO_UINT40(n, p)    {BYTES_TO_UINT40(n, p); p += 5;}
 convert little endian byte stream to uint40_t, incrementing five bytes.
 
#define BSTREAM_TO_UINT64(n, p)    {n = BstreamToUint64(p); p += 8;}
 convert little endian byte stream to uint64_t, incrementing eigth bytes.
 
#define BSTREAM_TO_BDA(bda, p)    {BdaCpy(bda, p); p += BDA_ADDR_LEN;}
 convert little endian byte stream to six byte Bluetooth device address, incrementing six bytes.
 
#define BSTREAM_TO_BDA64(bda, p)   {bda = BstreamToBda64(p); p += BDA_ADDR_LEN;}
 convert little endian byte stream to eight byte Bluetooth device address, incrementing eight bytes.
 
Macros for converting integers to a little endian byte stream, with increment.
#define UINT8_TO_BSTREAM(p, n)    {*(p)++ = (uint8_t)(n);}
 convert uint8_t to little endian byte stream, incrementing one byte.
 
#define UINT16_TO_BSTREAM(p, n)    {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8);}
 convert uint16_t to little endian byte stream, incrementing two bytes.
 
#define UINT24_TO_BSTREAM(p, n)
 convert uint24_t to little endian byte stream, incrementing three bytes. More...
 
#define UINT32_TO_BSTREAM(p, n)
 convert uint32_t to little endian byte stream, incrementing four bytes. More...
 
#define UINT40_TO_BSTREAM(p, n)
 convert uint40_t to little endian byte stream, incrementing five bytes. More...
 
#define UINT64_TO_BSTREAM(p, n)    {Uint64ToBstream(p, n); p += sizeof(uint64_t);}
 convert uint64_t to little endian byte stream, incrementing eight bytes.
 
#define BDA_TO_BSTREAM(p, bda)    {BdaCpy(p, bda); p += BDA_ADDR_LEN;}
 convert six byte Bluetooth device address to little endian byte stream, incrementing six bytes.
 
#define BDA64_TO_BSTREAM(p, bda)   {Bda64ToBstream(p, bda); p += BDA_ADDR_LEN;}
 convert eight byte Bluetooth device address to little endian byte stream, incrementing eigth bytes.
 
Macros for converting integers to a little endian byte stream, without increment.
#define UINT16_TO_BUF(p, n)    {(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8);}
 convert uint16_t to little endian byte stream.
 
#define UINT24_TO_BUF(p, n)
 convert uint24_t to little endian byte stream. More...
 
#define UINT32_TO_BUF(p, n)
 convert uint32_t to little endian byte stream. More...
 
#define UINT40_TO_BUF(p, n)
 convert uint40_t to little endian byte stream. More...
 
Macros for comparing a little endian byte buffer to integers.
#define BYTES_UINT16_CMP(p, n)    ((p)[1] == UINT16_TO_BYTE1(n) && (p)[0] == UINT16_TO_BYTE0(n))
 compare 2 byte little endian buffer with a uint16_t.
 
Macros for IEEE FLOAT type: exponent = byte 3, mantissa = bytes 2-0
#define FLT_TO_UINT32(m, e)    ((m) | ((int32_t)(e) * 16777216))
 Convert float to uint32.
 
#define UINT32_TO_FLT(m, e, n)    {m = UINT32_TO_FLT_M(n); e = UINT32_TO_FLT_E(n);}
 Convert uint32_t to float.
 
#define UINT32_TO_FLT_M(n)
 Convert uint32_t to float mantissa component. More...
 
#define UINT32_TO_FLT_E(n)    ((int8_t)(n >> 24))
 Convert uint32_t to float exponent component.
 
Macros for IEEE SFLOAT type: exponent = bits 15-12, mantissa = bits 11-0
#define SFLT_TO_UINT16(m, e)    ((m) | (0xF000 & ((int16_t)(e) * 4096)))
 Convert sfloat to uint16_t.
 
#define UINT16_TO_SFLT(m, e, n)    {m = UINT16_TO_SFLT_M(n); e = UINT16_TO_SFLT_E(n);}
 Convert uint16_t to sfloat.
 
#define UINT16_TO_SFLT_M(n)
 Convert uint16_T to sfloat mantissa component. More...
 
#define UINT16_TO_SFLT_E(n)
 Convert uint16_T to sfloat exponent component. More...
 

Functions

uint64_t BstreamToBda64 (const uint8_t *p)
 Convert bstream to BDA64. More...
 
uint64_t BstreamToUint64 (const uint8_t *p)
 Convert bstream to uint64_t. More...
 
void Bda64ToBstream (uint8_t *p, uint64_t bda)
 Convert BDA64 to bstream. More...
 
void Uint64ToBstream (uint8_t *p, uint64_t n)
 Convert uint64_t to bstream. More...
 

Description

Byte stream to integer conversion macros.

Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved. Arm Ltd. confidential and proprietary.

IMPORTANT. Your use of this file is governed by a Software License Agreement ("Agreement") that must be accepted in order to download or otherwise receive a copy of this file. You may not use or copy this file for any purpose other than as described in the Agreement. If you do not agree to all of the terms of the Agreement do not use this file and delete all copies in your possession or control; if you do not have a copy of the Agreement, you must contact Arm Ltd. prior to any use, copying or further distribution of this software.

Definition in file bstream.h.