Mistake on this page?
Report an issue in GitHub or email us
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
WSF_UTIL_API

Data Structures

struct  terminalCommand_tag
 Terminal command. More...
 

Macros

#define BDA_ADDR_LEN   6
 BD address length. More...
 
#define BDA_ADDR_STR_LEN   (BDA_ADDR_LEN * 2)
 BD address string length. More...
 
#define BDA_ADDR_IS_RPA(bda)    (((bda)[5] & 0xC0) == 0x40)
 BDA RPA check. More...
 
#define BDA_ADDR_IS_NRPA(bda)    (((bda)[5] & 0xC0) == 0x00)
 BDA NRPA check. More...
 
#define BDA_ADDR_IS_STATIC(bda)    (((bda)[5] & 0xC0) == 0xC0)
 BDA static random check. More...
 
#define BDA64_ADDR_IS_RPA(bda64)    ((((bda64) >> 40) & 0xC0) == 0x40)
 BDA64 RPA check. More...
 
#define BDA64_ADDR_IS_NRPA(bda64)    ((((bda64) >> 40) & 0xC0) == 0x00)
 BDA64 NRPA check. More...
 
#define BDA64_ADDR_IS_STATIC(bda64)    ((((bda64) >> 40) & 0xC0) == 0xC0)
 BDA64 static random check. More...
 
#define CALC128_LEN   16
 128-bit integer length in bytes More...
 
#define PRINT_ATTRIBUTE(a, b)
 Print function attributes. More...
 
#define TERMINAL_MAX_ARGC   8u
 Maximum number of arguments to any command. More...
 
#define TERMINAL_MAX_COMMAND_LEN   100u
 Maximum length of command line. More...
 
#define TERMINAL_PRINTF_MAX_LEN   256u
 Maximum length of any printed output. More...
 
#define TERMINAL_STRING_PROMPT   "> "
 Prompt string. More...
 
#define TERMINAL_STRING_ERROR   "ERROR: "
 Error prefix. More...
 
#define TERMINAL_STRING_USAGE   "USAGE: "
 Usage prefix. More...
 
#define TERMINAL_STRING_NEW_LINE   "\r\n"
 New line string. More...
 
#define WSTR_IS_HEX_FORMAT(c)
 
#define WSTR_IS_BIN_FORMAT(c)   (((char)(c)[0] == '0') && ((char)(c)[1] == 'b'))
 

Typedefs

typedef uint8_t bdAddr_t[6]
 BD address data type. More...
 
typedef uint8_t(* terminalHandler_t) (uint32_t argc, char **argv)
 Handler for a terminal command. More...
 
typedef bool_t(* terminalUartTx_t) (const uint8_t *pBuf, uint32_t len)
 Handler for transmit. More...
 
typedef struct terminalCommand_tag terminalCommand_t
 Terminal command. More...
 

Enumerations

Functions

void BdaCpy (uint8_t *pDst, const uint8_t *pSrc)
 Copy a BD address from source to destination. More...
 
bool_t BdaCmp (const uint8_t *pAddr1, const uint8_t *pAddr2)
 Compare two BD addresses. More...
 
uint8_t * BdaClr (uint8_t *pDst)
 Set a BD address to all zeros. More...
 
bool_t BdaIsZeros (const uint8_t *pAddr)
 Check if a BD address is all zeros. More...
 
char * Bda2Str (const uint8_t *pAddr)
 Convert a BD address to a string. More...
 
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...
 
void Calc128Cpy (uint8_t *pDst, uint8_t *pSrc)
 Copy a 128-bit integer from source to destination. More...
 
void Calc128Cpy64 (uint8_t *pDst, uint8_t *pSrc)
 Copy a 64-bit integer from source to destination. More...
 
void Calc128Xor (uint8_t *pDst, uint8_t *pSrc)
 Exclusive-or two 128-bit integers and return the result in pDst. More...
 
uint32_t CalcCrc32 (uint32_t crcInit, uint32_t len, const uint8_t *pBuf)
 Calculate the CRC-32 of the given buffer. More...
 
uint32_t PrintVsn (char *pStr, uint32_t size, const char *pFmt, va_list ap)
 Print a trace message. More...
 
void TerminalInit (wsfHandlerId_t handlerId)
 Initialize terminal. More...
 
void TerminalRegisterUartTxFunc (terminalUartTx_t uartTxFunc)
 Register the UART Tx Function for the platform. More...
 
void TerminalRegisterCommand (terminalCommand_t *pCommand)
 Register command with terminal. More...
 
void TerminalHandler (wsfEventMask_t event, wsfMsgHdr_t *pMsg)
 Handler for terminal messages. More...
 
void TerminalRx (uint8_t dataByte)
 Called by application when a data byte is received. More...
 
void TerminalTxStr (const char *pStr)
 Called by application to transmit string. More...
 
void TerminalTxChar (char c)
 Called by application to transmit character. More...
 
void TerminalTxPrint (const char *pStr,...)
 Called by application to print formatted data. More...
 
void TerminalTx (const uint8_t *pData, uint16_t len)
 Application function to transmit data.. More...
 
void WstrnCpy (char *pBuf, const char *pData, uint8_t n)
 Copies a string up to a given length. More...
 
void WStrReverseCpy (uint8_t *pBuf1, const uint8_t *pBuf2, uint16_t len)
 Byte by byte reverse and copy a buffer. More...
 
void WStrReverse (uint8_t *pBuf, uint8_t len)
 Byte by byte reverse a buffer. More...
 
void WStrFormatHex (char *pBuf, uint32_t val, uint8_t len)
 Format a hex value. More...
 
void WStrHexToArray (const char *pStr, uint8_t *pBuf, uint16_t len)
 Convert a formatted string to int array, zero out space after the string length. More...
 

Variables

const uint8_t calc128Zeros [16]
 128-bit zero value More...
 

Macros for converting a little endian byte buffer to integers.

#define BYTES_TO_INT16(n, p)    {n = ((int16_t)(p)[0] + ((int16_t)(p)[1] << 8));}
 convert little endian byte buffer to int16_t. More...
 
#define BYTES_TO_UINT16(n, p)    {n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8));}
 convert little endian byte buffer to uint16_t. More...
 
#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 a big endian byte buffer to integers.

#define BYTES_BE_TO_UINT16(n, p)    {n = ((uint16_t)(p)[1] + ((uint16_t)(p)[0] << 8));}
 convert big endian byte buffer to uint16_t. More...
 
#define BYTES_BE_TO_UINT24(n, p)
 convert big endian byte buffer to 24-bit uint32_t (MSB 0). More...
 
#define BYTES_BE_TO_UINT32(n, p)
 convert big endian byte buffer to uint32_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. More...
 
#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. More...
 

Macros for converting big endian integers to array of bytes

#define UINT16_TO_BE_BYTES(n)    ((uint8_t)((n) >> 8)), ((uint8_t) (n))
 convert big endian uint16_t to array of bytes. More...
 
#define UINT24_TO_BE_BYTES(n)    ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 8)), ((uint8_t) (n))
 convert 24-bit big endian uint32_t (MSB 0) to array of bytes. More...
 
#define UINT32_TO_BE_BYTES(n)    ((uint8_t)((n) >> 24)), ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 8)), ((uint8_t) (n))
 convert big endian uint32_t to array of bytes. More...
 

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. More...
 
#define UINT16_TO_BYTE1(n)    ((uint8_t) ((n) >> 8))
 convert little endian uint16_t to byte 1. More...
 
#define UINT32_TO_BYTE0(n)    ((uint8_t) (n))
 convert little endian uint32_t to byte 0. More...
 
#define UINT32_TO_BYTE1(n)    ((uint8_t) ((n) >> 8))
 convert little endian uint32_t to byte 1. More...
 
#define UINT32_TO_BYTE2(n)    ((uint8_t) ((n) >> 16))
 convert little endian uint32_t to byte 2. More...
 
#define UINT32_TO_BYTE3(n)    ((uint8_t) ((n) >> 24))
 convert little endian uint32_t to byte 3. More...
 

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. More...
 
#define BSTREAM_TO_UINT8(n, p)    {n = (uint8_t)(*(p)++);}
 convert little endian byte stream to int8_t, incrementing one byte. More...
 
#define BSTREAM_TO_INT16(n, p)    {BYTES_TO_INT16(n, p); p += 2;}
 convert little endian byte stream to int16_t, incrementing two bytes. More...
 
#define BSTREAM_TO_UINT16(n, p)    {BYTES_TO_UINT16(n, p); p += 2;}
 convert little endian byte stream to uint16_t, incrementing two bytes. More...
 
#define BSTREAM_TO_UINT24(n, p)    {BYTES_TO_UINT24(n, p); p += 3;}
 convert little endian byte stream to uint24_t, incrementing three bytes. More...
 
#define BSTREAM_TO_UINT32(n, p)    {BYTES_TO_UINT32(n, p); p += 4;}
 convert little endian byte stream to uint32_t, incrementing four bytes. More...
 
#define BSTREAM_TO_UINT40(n, p)    {BYTES_TO_UINT40(n, p); p += 5;}
 convert little endian byte stream to uint40_t, incrementing five bytes. More...
 
#define BSTREAM_TO_UINT64(n, p)    {n = BstreamToUint64(p); p += 8;}
 convert little endian byte stream to uint64_t, incrementing eigth bytes. More...
 
#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. More...
 
#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. More...
 

Macros for converting a big endian byte stream to integers, with increment.

#define BSTREAM_BE_TO_UINT16(n, p)    {BYTES_BE_TO_UINT16(n, p); p += 2;}
 convert big endian byte stream to uint16_t, incrementing one byte. More...
 
#define BSTREAM_BE_TO_UINT24(n, p)    {BYTES_BE_TO_UINT24(n, p); p += 3;}
 convert big endian byte stream to 24-bit uint32_t (MSB 0), incrementing one byte. More...
 

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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 

Macros for converting integers to a big endian byte stream, with increment.

#define UINT16_TO_BE_BSTREAM(p, n)    {*(p)++ = (uint8_t)((n) >> 8); *(p)++ = (uint8_t)(n);}
 convert uint16_t to big endian byte stream, incrementing one byte. More...
 
#define UINT32_TO_BE_BSTREAM(p, n)
 convert uint32_t to big endian byte stream, incrementing one byte. More...
 

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. More...
 
#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 converting integers to a big endian byte stream, without increment.

#define UINT16_TO_BE_BUF(p, n)    {(p)[0] = (uint8_t)((n) >> 8); (p)[1] = (uint8_t)(n);}
 convert uint16_t to big endian byte stream. More...
 
#define UINT24_TO_BE_BUF(p, n)
 convert 24-bit uint32_t (MSB 0) to big endian byte stream. More...
 
#define UINT32_TO_BE_BUF(p, n)
 convert uint32_t to big 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. More...
 

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. More...
 
#define UINT32_TO_FLT(m, e, n)    {m = UINT32_TO_FLT_M(n); e = UINT32_TO_FLT_E(n);}
 Convert uint32_t to float. More...
 
#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. More...
 

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. More...
 
#define UINT16_TO_SFLT(m, e, n)    {m = UINT16_TO_SFLT_M(n); e = UINT16_TO_SFLT_E(n);}
 Convert uint16_t to sfloat. More...
 
#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...
 

Detailed Description

Macro Definition Documentation

#define BDA64_ADDR_IS_NRPA (   bda64)    ((((bda64) >> 40) & 0xC0) == 0x00)

BDA64 NRPA check.

Definition at line 57 of file bda.h.

#define BDA64_ADDR_IS_RPA (   bda64)    ((((bda64) >> 40) & 0xC0) == 0x40)

BDA64 RPA check.

Definition at line 54 of file bda.h.

#define BDA64_ADDR_IS_STATIC (   bda64)    ((((bda64) >> 40) & 0xC0) == 0xC0)

BDA64 static random check.

Definition at line 60 of file bda.h.

#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.

Definition at line 179 of file bstream.h.

#define BDA_ADDR_IS_NRPA (   bda)    (((bda)[5] & 0xC0) == 0x00)

BDA NRPA check.

Definition at line 48 of file bda.h.

#define BDA_ADDR_IS_RPA (   bda)    (((bda)[5] & 0xC0) == 0x40)

BDA RPA check.

Definition at line 45 of file bda.h.

#define BDA_ADDR_IS_STATIC (   bda)    (((bda)[5] & 0xC0) == 0xC0)

BDA static random check.

Definition at line 51 of file bda.h.

#define BDA_ADDR_LEN   6

BD address length.

Definition at line 39 of file bda.h.

#define BDA_ADDR_STR_LEN   (BDA_ADDR_LEN * 2)

BD address string length.

Definition at line 42 of file bda.h.

#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.

Definition at line 177 of file bstream.h.

#define BSTREAM_BE_TO_UINT16 (   n,
 
)    {BYTES_BE_TO_UINT16(n, p); p += 2;}

convert big endian byte stream to uint16_t, incrementing one byte.

Definition at line 151 of file bstream.h.

#define BSTREAM_BE_TO_UINT24 (   n,
 
)    {BYTES_BE_TO_UINT24(n, p); p += 3;}

convert big endian byte stream to 24-bit uint32_t (MSB 0), incrementing one byte.

Definition at line 153 of file bstream.h.

#define BSTREAM_TO_BDA (   bda,
 
)    {BdaCpy(bda, p); p += BDA_ADDR_LEN;}

convert little endian byte stream to six byte Bluetooth device address, incrementing six bytes.

Definition at line 141 of file bstream.h.

#define BSTREAM_TO_BDA64 (   bda,
 
)    {bda = BstreamToBda64(p); p += BDA_ADDR_LEN;}

convert little endian byte stream to eight byte Bluetooth device address, incrementing eight bytes.

Definition at line 143 of file bstream.h.

#define BSTREAM_TO_INT16 (   n,
 
)    {BYTES_TO_INT16(n, p); p += 2;}

convert little endian byte stream to int16_t, incrementing two bytes.

Definition at line 129 of file bstream.h.

#define BSTREAM_TO_INT8 (   n,
 
)    {n = (int8_t)(*(p)++);}

convert little endian byte stream to uint8_t, incrementing one byte.

Definition at line 125 of file bstream.h.

#define BSTREAM_TO_UINT16 (   n,
 
)    {BYTES_TO_UINT16(n, p); p += 2;}

convert little endian byte stream to uint16_t, incrementing two bytes.

Definition at line 131 of file bstream.h.

#define BSTREAM_TO_UINT24 (   n,
 
)    {BYTES_TO_UINT24(n, p); p += 3;}

convert little endian byte stream to uint24_t, incrementing three bytes.

Definition at line 133 of file bstream.h.

#define BSTREAM_TO_UINT32 (   n,
 
)    {BYTES_TO_UINT32(n, p); p += 4;}

convert little endian byte stream to uint32_t, incrementing four bytes.

Definition at line 135 of file bstream.h.

#define BSTREAM_TO_UINT40 (   n,
 
)    {BYTES_TO_UINT40(n, p); p += 5;}

convert little endian byte stream to uint40_t, incrementing five bytes.

Definition at line 137 of file bstream.h.

#define BSTREAM_TO_UINT64 (   n,
 
)    {n = BstreamToUint64(p); p += 8;}

convert little endian byte stream to uint64_t, incrementing eigth bytes.

Definition at line 139 of file bstream.h.

#define BSTREAM_TO_UINT8 (   n,
 
)    {n = (uint8_t)(*(p)++);}

convert little endian byte stream to int8_t, incrementing one byte.

Definition at line 127 of file bstream.h.

#define BYTES_BE_TO_UINT16 (   n,
 
)    {n = ((uint16_t)(p)[1] + ((uint16_t)(p)[0] << 8));}

convert big endian byte buffer to uint16_t.

Definition at line 70 of file bstream.h.

#define BYTES_BE_TO_UINT24 (   n,
 
)
Value:
{n = ((uint16_t)(p)[2] + ((uint16_t)(p)[1] << 8) + \
((uint16_t)(p)[0] << 16));}

convert big endian byte buffer to 24-bit uint32_t (MSB 0).

Definition at line 72 of file bstream.h.

#define BYTES_BE_TO_UINT32 (   n,
 
)
Value:
{n = ((uint32_t)(p)[3] + ((uint32_t)(p)[2] << 8) + \
((uint32_t)(p)[1] << 16) + ((uint32_t)(p)[0] << 24));}

convert big endian byte buffer to uint32_t.

Definition at line 75 of file bstream.h.

#define BYTES_TO_INT16 (   n,
 
)    {n = ((int16_t)(p)[0] + ((int16_t)(p)[1] << 8));}

convert little endian byte buffer to int16_t.

Definition at line 45 of file bstream.h.

#define BYTES_TO_UINT16 (   n,
 
)    {n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8));}

convert little endian byte buffer to uint16_t.

Definition at line 47 of file bstream.h.

#define BYTES_TO_UINT24 (   n,
 
)
Value:
{n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8) + \
((uint16_t)(p)[2] << 16));}

convert little endian byte buffer to uint24_t.

Definition at line 49 of file bstream.h.

#define BYTES_TO_UINT32 (   n,
 
)
Value:
{n = ((uint32_t)(p)[0] + ((uint32_t)(p)[1] << 8) + \
((uint32_t)(p)[2] << 16) + ((uint32_t)(p)[3] << 24));}

convert little endian byte buffer to uint32_t.

Definition at line 52 of file bstream.h.

#define BYTES_TO_UINT40 (   n,
 
)
Value:
{n = ((uint64_t)(p)[0] + ((uint64_t)(p)[1] << 8) + \
((uint64_t)(p)[2] << 16) + ((uint64_t)(p)[3] << 24) + \
((uint64_t)(p)[4] << 32));}

convert little endian byte buffer to uint40_t.

Definition at line 55 of file bstream.h.

#define BYTES_TO_UINT64 (   n,
 
)
Value:
{n = ((uint64_t)(p)[0] + ((uint64_t)(p)[1] << 8) + \
((uint64_t)(p)[2] << 16) + ((uint64_t)(p)[3] << 24) + \
((uint64_t)(p)[4] << 32) + ((uint64_t)(p)[5] << 40) + \
((uint64_t)(p)[6] << 48) + ((uint64_t)(p)[7] << 56));}

convert little endian byte buffer to uint64_t.

Definition at line 59 of file bstream.h.

#define BYTES_UINT16_CMP (   p,
 
)    ((p)[1] == UINT16_TO_BYTE1(n) && (p)[0] == UINT16_TO_BYTE0(n))

compare 2 byte little endian buffer with a uint16_t.

Definition at line 230 of file bstream.h.

#define CALC128_LEN   16

128-bit integer length in bytes

Definition at line 39 of file calc128.h.

#define FLT_TO_UINT32 (   m,
 
)    ((m) | ((int32_t)(e) * 16777216))

Convert float to uint32.

Definition at line 238 of file bstream.h.

#define PRINT_ATTRIBUTE (   a,
 
)

Print function attributes.

Definition at line 43 of file print.h.

#define SFLT_TO_UINT16 (   m,
 
)    ((m) | (0xF000 & ((int16_t)(e) * 4096)))

Convert sfloat to uint16_t.

Definition at line 253 of file bstream.h.

#define TERMINAL_MAX_ARGC   8u

Maximum number of arguments to any command.

Definition at line 41 of file terminal.h.

#define TERMINAL_MAX_COMMAND_LEN   100u

Maximum length of command line.

Definition at line 44 of file terminal.h.

#define TERMINAL_PRINTF_MAX_LEN   256u

Maximum length of any printed output.

Definition at line 46 of file terminal.h.

#define TERMINAL_STRING_ERROR   "ERROR: "

Error prefix.

Definition at line 48 of file terminal.h.

#define TERMINAL_STRING_NEW_LINE   "\r\n"

New line string.

Definition at line 50 of file terminal.h.

#define TERMINAL_STRING_PROMPT   "> "

Prompt string.

Definition at line 47 of file terminal.h.

#define TERMINAL_STRING_USAGE   "USAGE: "

Usage prefix.

Definition at line 49 of file terminal.h.

#define UINT16_TO_BE_BSTREAM (   p,
 
)    {*(p)++ = (uint8_t)((n) >> 8); *(p)++ = (uint8_t)(n);}

convert uint16_t to big endian byte stream, incrementing one byte.

Definition at line 187 of file bstream.h.

#define UINT16_TO_BE_BUF (   p,
 
)    {(p)[0] = (uint8_t)((n) >> 8); (p)[1] = (uint8_t)(n);}

convert uint16_t to big endian byte stream.

Definition at line 216 of file bstream.h.

#define UINT16_TO_BE_BYTES (   n)    ((uint8_t)((n) >> 8)), ((uint8_t) (n))

convert big endian uint16_t to array of bytes.

Definition at line 94 of file bstream.h.

#define UINT16_TO_BSTREAM (   p,
 
)    {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8);}

convert uint16_t to little endian byte stream, incrementing two bytes.

Definition at line 163 of file bstream.h.

#define UINT16_TO_BUF (   p,
 
)    {(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8);}

convert uint16_t to little endian byte stream.

Definition at line 198 of file bstream.h.

#define UINT16_TO_BYTE0 (   n)    ((uint8_t) (n))

convert little endian uint16_t to byte 0.

Definition at line 106 of file bstream.h.

#define UINT16_TO_BYTE1 (   n)    ((uint8_t) ((n) >> 8))

convert little endian uint16_t to byte 1.

Definition at line 108 of file bstream.h.

#define UINT16_TO_BYTES (   n)    ((uint8_t) (n)), ((uint8_t)((n) >> 8))

convert little endian uint16_t to array of bytes.

Definition at line 84 of file bstream.h.

#define UINT16_TO_SFLT (   m,
  e,
 
)    {m = UINT16_TO_SFLT_M(n); e = UINT16_TO_SFLT_E(n);}

Convert uint16_t to sfloat.

Definition at line 255 of file bstream.h.

#define UINT16_TO_SFLT_E (   n)
Value:
(((n >> 12) >= 0x0008) ? \
((int8_t)(((n >> 12) | 0xF0))) : ((int8_t)(n >> 12)))

Convert uint16_T to sfloat exponent component.

Definition at line 260 of file bstream.h.

#define UINT16_TO_SFLT_M (   n)
Value:
((((n) & 0x0FFF) >= 0x0800) ? \
((int16_t)(((n) | 0xF000))) : ((int16_t)((n) & 0x0FFF)))

Convert uint16_T to sfloat mantissa component.

Definition at line 257 of file bstream.h.

#define UINT24_TO_BE_BUF (   p,
 
)
Value:
{(p)[0] = (uint8_t)((n) >> 16); (p)[1] = (uint8_t)((n) >> 8); \
(p)[2] = (uint8_t)(n);}

convert 24-bit uint32_t (MSB 0) to big endian byte stream.

Definition at line 218 of file bstream.h.

#define UINT24_TO_BE_BYTES (   n)    ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 8)), ((uint8_t) (n))

convert 24-bit big endian uint32_t (MSB 0) to array of bytes.

Definition at line 96 of file bstream.h.

#define UINT24_TO_BSTREAM (   p,
 
)
Value:
{*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
*(p)++ = (uint8_t)((n) >> 16);}

convert uint24_t to little endian byte stream, incrementing three bytes.

Definition at line 165 of file bstream.h.

#define UINT24_TO_BUF (   p,
 
)
Value:
{(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8); \
(p)[2] = (uint8_t)((n) >> 16);}

convert uint24_t to little endian byte stream.

Definition at line 200 of file bstream.h.

#define UINT32_TO_BE_BSTREAM (   p,
 
)
Value:
{*(p)++ = (uint8_t)((n) >> 24); *(p)++ = (uint8_t)((n) >> 16);\
*(p)++ = (uint8_t)((n) >> 8); *(p)++ = (uint8_t)(n);}

convert uint32_t to big endian byte stream, incrementing one byte.

Definition at line 189 of file bstream.h.

#define UINT32_TO_BE_BUF (   p,
 
)
Value:
{(p)[0] = (uint8_t)((n) >> 24); (p)[1] = (uint8_t)((n) >> 16); \
(p)[2] = (uint8_t)((n) >> 8); (p)[3] = (uint8_t)(n);}

convert uint32_t to big endian byte stream.

Definition at line 221 of file bstream.h.

#define UINT32_TO_BE_BYTES (   n)    ((uint8_t)((n) >> 24)), ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 8)), ((uint8_t) (n))

convert big endian uint32_t to array of bytes.

Definition at line 98 of file bstream.h.

#define UINT32_TO_BSTREAM (   p,
 
)
Value:
{*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
*(p)++ = (uint8_t)((n) >> 16); *(p)++ = (uint8_t)((n) >> 24);}

convert uint32_t to little endian byte stream, incrementing four bytes.

Definition at line 168 of file bstream.h.

#define UINT32_TO_BUF (   p,
 
)
Value:
{(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8); \
(p)[2] = (uint8_t)((n) >> 16); (p)[3] = (uint8_t)((n) >> 24);}

convert uint32_t to little endian byte stream.

Definition at line 203 of file bstream.h.

#define UINT32_TO_BYTE0 (   n)    ((uint8_t) (n))

convert little endian uint32_t to byte 0.

Definition at line 111 of file bstream.h.

#define UINT32_TO_BYTE1 (   n)    ((uint8_t) ((n) >> 8))

convert little endian uint32_t to byte 1.

Definition at line 113 of file bstream.h.

#define UINT32_TO_BYTE2 (   n)    ((uint8_t) ((n) >> 16))

convert little endian uint32_t to byte 2.

Definition at line 115 of file bstream.h.

#define UINT32_TO_BYTE3 (   n)    ((uint8_t) ((n) >> 24))

convert little endian uint32_t to byte 3.

Definition at line 117 of file bstream.h.

#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.

Definition at line 86 of file bstream.h.

#define UINT32_TO_FLT (   m,
  e,
 
)    {m = UINT32_TO_FLT_M(n); e = UINT32_TO_FLT_E(n);}

Convert uint32_t to float.

Definition at line 240 of file bstream.h.

#define UINT32_TO_FLT_E (   n)    ((int8_t)(n >> 24))

Convert uint32_t to float exponent component.

Definition at line 245 of file bstream.h.

#define UINT32_TO_FLT_M (   n)
Value:
((((n) & 0x00FFFFFF) >= 0x00800000) ? \
((int32_t)(((n) | 0xFF000000))) : ((int32_t)((n) & 0x00FFFFFF)))

Convert uint32_t to float mantissa component.

Definition at line 242 of file bstream.h.

#define UINT40_TO_BSTREAM (   p,
 
)
Value:
{*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
*(p)++ = (uint8_t)((n) >> 16); *(p)++ = (uint8_t)((n) >> 24); \
*(p)++ = (uint8_t)((n) >> 32);}

convert uint40_t to little endian byte stream, incrementing five bytes.

Definition at line 171 of file bstream.h.

#define UINT40_TO_BUF (   p,
 
)
Value:
{(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8); \
(p)[2] = (uint8_t)((n) >> 16); (p)[3] = (uint8_t)((n) >> 24);\
(p)[4] = (uint8_t)((n) >> 32);}

convert uint40_t to little endian byte stream.

Definition at line 206 of file bstream.h.

#define UINT64_TO_BSTREAM (   p,
 
)    {Uint64ToBstream(p, n); p += sizeof(uint64_t);}

convert uint64_t to little endian byte stream, incrementing eight bytes.

Definition at line 175 of file bstream.h.

#define UINT8_TO_BSTREAM (   p,
 
)    {*(p)++ = (uint8_t)(n);}

convert uint8_t to little endian byte stream, incrementing one byte.

Definition at line 161 of file bstream.h.

#define WSTR_IS_BIN_FORMAT (   c)    (((char)(c)[0] == '0') && ((char)(c)[1] == 'b'))

Binary format '0b' check

Definition at line 44 of file wstr.h.

#define WSTR_IS_HEX_FORMAT (   c)
Value:
(((char)(c)[0] == '0') && \
(((char)(c)[1] == 'x') || ((char)(c)[1] == 'X')))

HEX format '0x' or '0X' check

Definition at line 40 of file wstr.h.

Typedef Documentation

typedef uint8_t bdAddr_t[6]

BD address data type.

Definition at line 67 of file bda.h.

Terminal command.

typedef uint8_t(* terminalHandler_t) (uint32_t argc, char **argv)

Handler for a terminal command.

Parameters
argcThe number of arguments passed to the command.
argvThe array of arguments; the 0th argument is the command.
Returns
Error code.

Definition at line 76 of file terminal.h.

typedef bool_t(* terminalUartTx_t) (const uint8_t *pBuf, uint32_t len)

Handler for transmit.

Parameters
pBufBuffer to transmit.
lenNumber of bytes to transmit.

Definition at line 86 of file terminal.h.

Enumeration Type Documentation

anonymous enum

Terminal command error codes.

Enumerator
TERMINAL_ERROR_OK 

Command completed.

TERMINAL_ERROR_BAD_ARGUMENTS 

ERROR: Invalid argument(s)

TERMINAL_ERROR_TOO_FEW_ARGUMENTS 

ERROR: Too few arguments.

TERMINAL_ERROR_TOO_MANY_ARGUMENTS 

ERROR: Too many arguments.

TERMINAL_ERROR_EXEC 

Command completed with execution error.

Definition at line 53 of file terminal.h.

Function Documentation

char* Bda2Str ( const uint8_t *  pAddr)

Convert a BD address to a string.

Parameters
pAddrPointer to BD address.
Returns
Pointer to string.
void Bda64ToBstream ( uint8_t *  p,
uint64_t  bda 
)

Convert BDA64 to bstream.

Parameters
pBstream pointer.
bdauint64_t BDA.
uint8_t* BdaClr ( uint8_t *  pDst)

Set a BD address to all zeros.

Parameters
pDstPointer to destination.
Returns
pDst + BDA_ADDR_LEN
bool_t BdaCmp ( const uint8_t *  pAddr1,
const uint8_t *  pAddr2 
)

Compare two BD addresses.

Parameters
pAddr1First address.
pAddr2Second address.
Returns
TRUE if addresses match, FALSE otherwise.
void BdaCpy ( uint8_t *  pDst,
const uint8_t *  pSrc 
)

Copy a BD address from source to destination.

Parameters
pDstPointer to destination.
pSrcPointer to source.
bool_t BdaIsZeros ( const uint8_t *  pAddr)

Check if a BD address is all zeros.

Parameters
pAddrPointer to address.
Returns
TRUE if address is all zeros, FALSE otherwise.
uint64_t BstreamToBda64 ( const uint8_t *  p)

Convert bstream to BDA64.

Parameters
pBstream pointer.
Returns
Resulting BDA64 number.
uint64_t BstreamToUint64 ( const uint8_t *  p)

Convert bstream to uint64_t.

Parameters
pBstream pointer.
Returns
Resulting uint64_t number.
void Calc128Cpy ( uint8_t *  pDst,
uint8_t *  pSrc 
)

Copy a 128-bit integer from source to destination.

Parameters
pDstPointer to destination.
pSrcPointer to source.
void Calc128Cpy64 ( uint8_t *  pDst,
uint8_t *  pSrc 
)

Copy a 64-bit integer from source to destination.

Parameters
pDstPointer to destination.
pSrcPointer to source.
void Calc128Xor ( uint8_t *  pDst,
uint8_t *  pSrc 
)

Exclusive-or two 128-bit integers and return the result in pDst.

Parameters
pDstPointer to destination.
pSrcPointer to source.
uint32_t CalcCrc32 ( uint32_t  crcInit,
uint32_t  len,
const uint8_t *  pBuf 
)

Calculate the CRC-32 of the given buffer.

Parameters
crcInitInitial value of the CRC.
lenLength of the buffer.
pBufBuffer to compute the CRC.

This routine was originally generated with crcmod.py using the following parameters:

  • polynomial 0x104C11DB7
  • bit reverse algorithm
uint32_t PrintVsn ( char *  pStr,
uint32_t  size,
const char *  pFmt,
va_list  ap 
)

Print a trace message.

Parameters
pStrStorage for formatted string.
sizeMaximum number of characters to store.
pFmtFormat string.
apArguments.
Returns
Number of characters stored.
void TerminalHandler ( wsfEventMask_t  event,
wsfMsgHdr_t pMsg 
)

Handler for terminal messages.

Parameters
eventWSF event mask.
pMsgWSF message.
void TerminalInit ( wsfHandlerId_t  handlerId)

Initialize terminal.

Parameters
handlerIdHandler ID for TerminalHandler().
void TerminalRegisterCommand ( terminalCommand_t pCommand)

Register command with terminal.

Parameters
pCommandCommand.
void TerminalRegisterUartTxFunc ( terminalUartTx_t  uartTxFunc)

Register the UART Tx Function for the platform.

Parameters
uartTxFuncUART Tx callback function.
void TerminalRx ( uint8_t  dataByte)

Called by application when a data byte is received.

Parameters
dataBytereceived byte
void TerminalTx ( const uint8_t *  pData,
uint16_t  len 
)

Application function to transmit data..

Parameters
pDataData.
lenLength of data, in bytes.
void TerminalTxChar ( char  c)

Called by application to transmit character.

Parameters
cCharacter.
void TerminalTxPrint ( const char *  pStr,
  ... 
)

Called by application to print formatted data.

Parameters
pStrMessage format string
...Additional arguments, printf-style
void TerminalTxStr ( const char *  pStr)

Called by application to transmit string.

Parameters
pStrString.
void Uint64ToBstream ( uint8_t *  p,
uint64_t  n 
)

Convert uint64_t to bstream.

Parameters
pBstream pointer.
nuint64_t number.
void WStrFormatHex ( char *  pBuf,
uint32_t  val,
uint8_t  len 
)

Format a hex value.

Parameters
pBufStorage for string representation of value.
valValue.
lenLength of value, in bits.
void WStrHexToArray ( const char *  pStr,
uint8_t *  pBuf,
uint16_t  len 
)

Convert a formatted string to int array, zero out space after the string length.

Parameters
pStrPointer to the string to convert.
pBufPointer to destination buffer.
lenSize of pBuf in bytes.
Returns
none.
void WstrnCpy ( char *  pBuf,
const char *  pData,
uint8_t  n 
)

Copies a string up to a given length.

Parameters
pBufPointer to buffer to copy to.
pDataPointer to the string to copy.
nSize of pBuf in bytes.
Returns
none.
void WStrReverse ( uint8_t *  pBuf,
uint8_t  len 
)

Byte by byte reverse a buffer.

Parameters
pBufBuffer to reverse.
lensize of pBuf in bytes.
void WStrReverseCpy ( uint8_t *  pBuf1,
const uint8_t *  pBuf2,
uint16_t  len 
)

Byte by byte reverse and copy a buffer.

Parameters
pBuf1Buffer to hold reversed copy.
pBuf2Buffer to copy.
lenSize of pBuf1 and pBuf2 in bytes.

Variable Documentation

const uint8_t calc128Zeros[16]

128-bit zero value

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.