Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 29, 2014 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
More...
|
uint16_t | convertEndian16 (uint16_t val) |
| Convert a short (uint16_t) from LSB (little-endian) to MSB (big-endian) and vice versa. More...
|
|
uint32_t | convertEndian32 (uint32_t val) |
| Convert an integer (uint32_t) from LSB (little-endian) to MSB (big-endian) and vice versa. More...
|
|
template<class T , size_t N> |
constexpr auto | ArraySize (T(&)[N]) |
| Get number of items in an array. More...
|
|
template<typename T > |
void | printAddress (T *arr, uint16_t len, uint8_t verbosity=SERIAL_DEBUG, bool addNewLine=true) |
|
void | print_heap (const std::string &msg) |
|
void | print_stack (const std::string &msg) |
|
template<typename T > |
bool | isBitSet (const T value, uint8_t bit) |
|
template<typename T > |
bool | setBit (T &value, uint8_t bit) |
|
template<typename T > |
bool | clearBit (T &value, uint8_t bit) |
|
template<typename T > |
constexpr T | lowestBitSet (T value) |
| Returns the index of the lowest bit set in given value. More...
|
|
bool | isNewer (uint8_t previousValue, uint8_t newValue) |
| Returns true when newValue is newer than previousValue, for a value that is increased all the time and overflows. More...
|
|
static cs_ret_code_t | findAdvType (uint8_t type, uint8_t *advData, uint8_t advLen, cs_data_t *foundData) |
| Parses advertisement data, providing length and location of the field in case matching data is found. More...
|
|
constexpr uint16_t | stringLen (const char *str, uint16_t maxSize) |
| Gets the string length of a null terminated constant string. More...
|
|
uint32_t | getInterruptLevel () |
|
constexpr int | parseHexChar (const char chr) |
| Parses a hex char to an integer. More...
|
|
constexpr int | parseHexPair (const char *str) |
| Parses 2 hex chars to an integer. More...
|
|
constexpr bool | parseUuid (const char *str, int stringSize, uint8_t *array, int arraySize) |
| Parse UUID string (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) to a byte array. More...
|
|
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 29, 2014 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
Utilities, e.g. for printing over UART.
◆ ArraySize()
template<class T , size_t N>
constexpr auto CsUtils::ArraySize |
( |
T(&) |
[N] | ) |
|
|
constexpr |
Get number of items in an array.
Usage: auto count = ArraySize(myArray);
◆ clearBit()
template<typename T >
bool CsUtils::clearBit |
( |
T & |
value, |
|
|
uint8_t |
bit |
|
) |
| |
|
inline |
◆ convertEndian16()
uint16_t CsUtils::convertEndian16 |
( |
uint16_t |
val | ) |
|
|
inline |
Convert a short (uint16_t) from LSB (little-endian) to MSB (big-endian) and vice versa.
@val the value to be converted
- Returns
- the converted value
◆ convertEndian32()
uint32_t CsUtils::convertEndian32 |
( |
uint32_t |
val | ) |
|
|
inline |
Convert an integer (uint32_t) from LSB (little-endian) to MSB (big-endian) and vice versa.
@val the value to be converted
- Returns
- the converted value
◆ findAdvType()
static cs_ret_code_t CsUtils::findAdvType |
( |
uint8_t |
type, |
|
|
uint8_t * |
advData, |
|
|
uint8_t |
advLen, |
|
|
cs_data_t * |
foundData |
|
) |
| |
|
inlinestatic |
Parses advertisement data, providing length and location of the field in case matching data is found.
- Parameters
-
- Return values
-
ERR_SUCCESS | if the data type is found in the report. |
ERR_NOT_FOUND | if the type could not be found. |
◆ getInterruptLevel()
uint32_t CsUtils::getInterruptLevel |
( |
| ) |
|
|
inline |
◆ isBitSet()
template<typename T >
bool CsUtils::isBitSet |
( |
const T |
value, |
|
|
uint8_t |
bit |
|
) |
| |
|
inline |
◆ isNewer()
bool CsUtils::isNewer |
( |
uint8_t |
previousValue, |
|
|
uint8_t |
newValue |
|
) |
| |
|
inline |
Returns true when newValue is newer than previousValue, for a value that is increased all the time and overflows.
◆ lowestBitSet()
template<typename T >
constexpr T CsUtils::lowestBitSet |
( |
T |
value | ) |
|
|
inlineconstexpr |
Returns the index of the lowest bit set in given value.
If no bits are set, returns number of bits of value type.
Examples for uint8_t: Value | Bit representation | Lowest bit 0 | 000000000 | 8 1 | 000000001 | 0 4 | 000000100 | 2 132 | 100000100 | 2
◆ parseHexChar()
constexpr int CsUtils::parseHexChar |
( |
const char |
chr | ) |
|
|
constexpr |
Parses a hex char to an integer.
◆ parseHexPair()
constexpr int CsUtils::parseHexPair |
( |
const char * |
str | ) |
|
|
constexpr |
Parses 2 hex chars to an integer.
◆ parseUuid()
constexpr bool CsUtils::parseUuid |
( |
const char * |
str, |
|
|
int |
stringSize, |
|
|
uint8_t * |
array, |
|
|
int |
arraySize |
|
) |
| |
|
constexpr |
Parse UUID string (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) to a byte array.
◆ print_heap()
void CsUtils::print_heap |
( |
const std::string & |
msg | ) |
|
|
inline |
◆ print_stack()
void CsUtils::print_stack |
( |
const std::string & |
msg | ) |
|
|
inline |
◆ printAddress()
template<typename T >
void CsUtils::printAddress |
( |
T * |
arr, |
|
|
uint16_t |
len, |
|
|
uint8_t |
verbosity = SERIAL_DEBUG , |
|
|
bool |
addNewLine = true |
|
) |
| |
◆ setBit()
template<typename T >
bool CsUtils::setBit |
( |
T & |
value, |
|
|
uint8_t |
bit |
|
) |
| |
|
inline |
◆ stringLen()
constexpr uint16_t CsUtils::stringLen |
( |
const char * |
str, |
|
|
uint16_t |
maxSize |
|
) |
| |
|
constexpr |
Gets the string length of a null terminated constant string.
Unlike strlen(), this function is guaranteed to be optimized out.
- Parameters
-
[in] | str | The string. |
[in] | maxSize | The max size to look for a null terminator. Simply provide sizeof("string"). |
- Return values
-
The | number of bytes of the string, without the null terminator. |