Various types and definitions available to all applications. More...
Data Structures | |
struct | uint8_array_t |
Byte array type. More... | |
struct | regcertdatalist_t |
IEEE 11073-20601 Regulatory Certification Data List Structure. More... | |
struct | sfloat_t |
SFLOAT format (IEEE-11073 16-bit FLOAT, meaning 4 bits for exponent (base 10) and 12 bits mantissa) More... | |
struct | ble_date_time_t |
Date and Time structure. More... | |
Macros | |
#define | STRING_CONCATENATE_IMPL(lhs, rhs) lhs ## rhs |
Implementation specific macro for delayed macro expansion used in string concatenation. More... | |
#define | STRING_CONCATENATE(lhs, rhs) STRING_CONCATENATE_IMPL(lhs, rhs) |
Macro used to concatenate string using delayed macro expansion. More... | |
#define | STATIC_ASSERT(EXPR) ;enum { STRING_CONCATENATE(assert_line_, __LINE__) = 1/(!!(EXPR)) } |
Macro for doing static (i.e. compile time) assertion. More... | |
#define | ROUNDED_DIV(A, B) (((A) + ((B) / 2)) / (B)) |
Perform rounded integer division (as opposed to truncating the result). More... | |
#define | IS_POWER_OF_TWO(A) ( ((A) != 0) && ((((A) - 1) & (A)) == 0) ) |
Check if the integer provided is a power of two. More... | |
#define | MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) |
To convert milliseconds to ticks. More... | |
#define | CEIL_DIV(A, B) (((A) + (B) - 1) / (B)) |
Perform integer division, making sure the result is rounded up. More... | |
#define | WORD_ALIGNED_MEM_BUFF(NAME, MIN_SIZE) static uint32_t NAME[CEIL_DIV(MIN_SIZE, sizeof(uint32_t))] |
Function for creating a buffer aligned to 4 bytes. More... | |
Typedefs | |
typedef uint8_t | uint16_le_t [2] |
type for holding an encoded (i.e. little endian) 16 bit unsigned integer. | |
typedef uint8_t | uint32_le_t [4] |
type for holding an encoded (i.e. little endian) 32 bit unsigned integer. | |
typedef uint8_t | nibble_t |
typedef uint32_t | uint24_t |
typedef uint64_t | uint40_t |
Enumerations | |
enum | { UNIT_0_625_MS = 625, UNIT_1_25_MS = 1250, UNIT_10_MS = 10000 } |
Functions | |
static __INLINE uint64_t | value_rescale (uint32_t value, uint32_t old_unit_reversal, uint16_t new_unit_reversal) |
Function for changing the value unit. More... | |
static __INLINE uint8_t | uint16_encode (uint16_t value, uint8_t *p_encoded_data) |
Function for encoding a uint16 value. More... | |
static __INLINE uint8_t | uint24_encode (uint32_t value, uint8_t *p_encoded_data) |
Function for encoding a three-byte value. More... | |
static __INLINE uint8_t | uint32_encode (uint32_t value, uint8_t *p_encoded_data) |
Function for encoding a uint32 value. More... | |
static __INLINE uint16_t | uint16_decode (const uint8_t *p_encoded_data) |
Function for decoding a uint16 value. More... | |
static __INLINE uint32_t | uint24_decode (const uint8_t *p_encoded_data) |
Function for decoding a three-byte value. More... | |
static __INLINE uint32_t | uint32_decode (const uint8_t *p_encoded_data) |
Function for decoding a uint32 value. More... | |
static __INLINE uint8_t | battery_level_in_percent (const uint16_t mvolts) |
Function for converting the input voltage (in milli volts) into percentage of 3.0 Volts. More... | |
static __INLINE bool | is_word_aligned (void const *p) |
Function for checking if a pointer value is aligned to a 4 byte boundary. More... | |
static __INLINE uint8_t | bds_uint16_encode (const uint16_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a uint16 value. More... | |
static __INLINE uint8_t | bds_int16_encode (const int16_t *p_value, uint8_t *p_encoded_data) |
static __INLINE uint8_t | bds_uint24_encode (const uint32_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a uint24 value. More... | |
static __INLINE uint8_t | bds_uint32_encode (const uint32_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a uint32 value. More... | |
static __INLINE uint8_t | bds_uint40_encode (const uint64_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a uint40 value. More... | |
static __INLINE uint8_t | bds_sfloat_encode (const sfloat_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a sfloat value. More... | |
static __INLINE uint8_t | bds_uint8_array_encode (const uint8_array_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a uint8_array value. More... | |
static __INLINE uint8_t | bds_ble_srv_utf8_str_encode (const ble_srv_utf8_str_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a utf8_str value. More... | |
static __INLINE uint8_t | bds_regcertdatalist_encode (const regcertdatalist_t *p_value, uint8_t *p_encoded_data) |
Function for encoding a regcertdatalist value. More... | |
static __INLINE uint8_t | bds_ble_date_time_encode (const ble_date_time_t *p_date_time, uint8_t *p_encoded_data) |
Function for decoding a date_time value. More... | |
static __INLINE uint8_t | bds_uint16_decode (const uint8_t len, const uint8_t *p_encoded_data, uint16_t *p_decoded_val) |
Function for decoding a uint16 value. More... | |
static __INLINE uint8_t | bds_int16_decode (const uint8_t len, const uint8_t *p_encoded_data, int16_t *p_decoded_val) |
Function for decoding a int16 value. More... | |
static __INLINE uint8_t | bds_uint24_decode (const uint8_t len, const uint8_t *p_encoded_data, uint32_t *p_decoded_val) |
Function for decoding a uint24 value. More... | |
static __INLINE uint8_t | bds_uint32_decode (const uint8_t len, const uint8_t *p_encoded_data, uint32_t *p_decoded_val) |
Function for decoding a uint32 value. More... | |
static __INLINE uint8_t | bds_uint40_decode (const uint8_t len, const uint8_t *p_encoded_data, uint64_t *p_decoded_val) |
Function for decoding a uint40 value. More... | |
static __INLINE uint8_t | bds_sfloat_decode (const uint8_t len, const uint8_t *p_encoded_data, sfloat_t *p_decoded_val) |
Function for decoding a sfloat value. More... | |
static __INLINE uint8_t | bds_uint8_array_decode (const uint8_t len, const uint8_t *p_encoded_data, uint8_array_t *p_decoded_val) |
Function for decoding a uint8_array value. More... | |
static __INLINE uint8_t | bds_ble_srv_utf8_str_decode (const uint8_t len, const uint8_t *p_encoded_data, ble_srv_utf8_str_t *p_decoded_val) |
Function for decoding a utf8_str value. More... | |
static __INLINE uint8_t | bds_regcertdatalist_decode (const uint8_t len, const uint8_t *p_encoded_data, regcertdatalist_t *p_decoded_val) |
Function for decoding a regcertdatalist value. More... | |
static __INLINE uint8_t | bds_ble_date_time_decode (const uint8_t len, const uint8_t *p_encoded_data, ble_date_time_t *p_date_time) |
Function for decoding a date_time value. More... | |
Various types and definitions available to all applications.
#define CEIL_DIV | ( | A, | |
B | |||
) | (((A) + (B) - 1) / (B)) |
Perform integer division, making sure the result is rounded up.
One typical use for this is to compute the number of objects with size B is needed to hold A number of bytes.
[in] | A | Numerator. |
[in] | B | Denominator. |
#define IS_POWER_OF_TWO | ( | A | ) | ( ((A) != 0) && ((((A) - 1) & (A)) == 0) ) |
Check if the integer provided is a power of two.
[in] | A | Number to be tested. |
#define MSEC_TO_UNITS | ( | TIME, | |
RESOLUTION | |||
) | (((TIME) * 1000) / (RESOLUTION)) |
To convert milliseconds to ticks.
[in] | TIME | Number of milliseconds to convert. |
[in] | RESOLUTION | Unit to be converted to in [us/ticks]. |
#define ROUNDED_DIV | ( | A, | |
B | |||
) | (((A) + ((B) / 2)) / (B)) |
Perform rounded integer division (as opposed to truncating the result).
[in] | A | Numerator. |
[in] | B | Denominator. |
#define STATIC_ASSERT | ( | EXPR | ) | ;enum { STRING_CONCATENATE(assert_line_, __LINE__) = 1/(!!(EXPR)) } |
Macro for doing static (i.e. compile time) assertion.
[in] | EXPR | Constant expression to be verified. |
#define STRING_CONCATENATE | ( | lhs, | |
rhs | |||
) | STRING_CONCATENATE_IMPL(lhs, rhs) |
Macro used to concatenate string using delayed macro expansion.
[in] | lhs | Left hand side in concatenation |
[in] | rhs | Right hand side in concatenation |
#define STRING_CONCATENATE_IMPL | ( | lhs, | |
rhs | |||
) | lhs ## rhs |
Implementation specific macro for delayed macro expansion used in string concatenation.
[in] | lhs | Left hand side in concatenation |
[in] | rhs | Right hand side in concatenation |
#define WORD_ALIGNED_MEM_BUFF | ( | NAME, | |
MIN_SIZE | |||
) | static uint32_t NAME[CEIL_DIV(MIN_SIZE, sizeof(uint32_t))] |
Function for creating a buffer aligned to 4 bytes.
[in] | NAME | Name of the buffor. |
[in] | MIN_SIZE | Size of this buffor (it will be rounded up to multiples of 4 bytes). |
anonymous enum |
|
static |
Function for converting the input voltage (in milli volts) into percentage of 3.0 Volts.
The calculation is based on a linearized version of the battery's discharge curve. 3.0V returns 100% battery level. The limit for power failure is 2.1V and is considered to be the lower boundary.
The discharge curve for CR2032 is non-linear. In this model it is split into 4 linear sections:
These numbers are by no means accurate. Temperature and load in the actual application is not accounted for!
[in] | mvolts | The voltage in mV |
|
static |
Function for decoding a date_time value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_date_time | pointer to the decoded value |
|
static |
Function for decoding a date_time value.
[in] | p_date_time | pointer to the date_time structure to encode. |
[in] | p_encoded_data | pointer to the encoded data |
|
static |
Function for decoding a utf8_str value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a utf8_str value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a int16 value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for decoding a regcertdatalist value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a regcertdatalist value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a sfloat value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a sfloat value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a uint16 value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a uint16 value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a uint24 value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a uint24 value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a uint32 value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a uint32 value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a uint40 value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a uint40 value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a uint8_array value.
[in] | len | length of the field to be decoded. |
[in] | p_encoded_data | Buffer where the encoded data is stored. |
[in] | p_decoded_val | pointer to the decoded value |
|
static |
Function for encoding a uint8_array value.
[in] | p_value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for checking if a pointer value is aligned to a 4 byte boundary.
[in] | p | Pointer value to be checked. |
|
static |
Function for decoding a uint16 value.
[in] | p_encoded_data | Buffer where the encoded data is stored. |
|
static |
Function for encoding a uint16 value.
[in] | value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a three-byte value.
[in] | p_encoded_data | Buffer where the encoded data is stored. |
|
static |
Function for encoding a three-byte value.
[in] | value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for decoding a uint32 value.
[in] | p_encoded_data | Buffer where the encoded data is stored. |
|
static |
Function for encoding a uint32 value.
[in] | value | Value to be encoded. |
[out] | p_encoded_data | Buffer where the encoded data is to be written. |
|
static |
Function for changing the value unit.
[in] | value | Value to be rescaled. |
[in] | old_unit_reversal | Reversal of the incoming unit. |
[in] | new_unit_reversal | Reversal of the desired unit. |