BLE_Nano nRF51 Central heart rate
Utility Functions and Definitions
Various types and definitions available to all applications. More...
Data Structures | |
struct | uint8_array_t |
Byte array type. More... | |
Typedefs | |
typedef uint8_t | uint16_le_t [2] |
type for holding an encoded (i.e. | |
typedef uint8_t | uint32_le_t [4] |
Type for holding an encoded (i.e. | |
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. | |
static __INLINE uint8_t | uint16_encode (uint16_t value, uint8_t *p_encoded_data) |
Function for encoding a uint16 value. | |
static __INLINE uint8_t | uint24_encode (uint32_t value, uint8_t *p_encoded_data) |
Function for encoding a three-byte value. | |
static __INLINE uint8_t | uint32_encode (uint32_t value, uint8_t *p_encoded_data) |
Function for encoding a uint32 value. | |
static __INLINE uint8_t | uint48_encode (uint64_t value, uint8_t *p_encoded_data) |
Function for encoding a uint48 value. | |
static __INLINE uint16_t | uint16_decode (const uint8_t *p_encoded_data) |
Function for decoding a uint16 value. | |
static __INLINE uint16_t | uint16_big_decode (const uint8_t *p_encoded_data) |
Function for decoding a uint16 value in big-endian format. | |
static __INLINE uint32_t | uint24_decode (const uint8_t *p_encoded_data) |
Function for decoding a three-byte value. | |
static __INLINE uint32_t | uint32_decode (const uint8_t *p_encoded_data) |
Function for decoding a uint32 value. | |
static __INLINE uint32_t | uint32_big_decode (const uint8_t *p_encoded_data) |
Function for decoding a uint32 value in big-endian format. | |
static __INLINE uint8_t | uint32_big_encode (uint32_t value, uint8_t *p_encoded_data) |
Function for encoding a uint32 value in big-endian format. | |
static __INLINE uint64_t | uint48_decode (const uint8_t *p_encoded_data) |
Function for decoding a uint48 value. | |
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. | |
static __INLINE bool | is_word_aligned (void const *p) |
Function for checking if a pointer value is aligned to a 4 byte boundary. | |
static __INLINE bool | is_address_from_stack (void *ptr) |
Function for checking if provided address is located in stack space. |
Detailed Description
Various types and definitions available to all applications.
Typedef Documentation
typedef uint8_t uint16_le_t[2] |
type for holding an encoded (i.e.
little endian) 16 bit unsigned integer.
Definition at line 142 of file app_util.h.
typedef uint8_t uint32_le_t[4] |
Type for holding an encoded (i.e.
little endian) 32 bit unsigned integer.
Definition at line 145 of file app_util.h.
Enumeration Type Documentation
anonymous enum |
- Enumerator:
UNIT_0_625_MS Number of microseconds in 0.625 milliseconds.
UNIT_1_25_MS Number of microseconds in 1.25 milliseconds.
UNIT_10_MS Number of microseconds in 10 milliseconds.
Definition at line 49 of file app_util.h.
Function Documentation
static __INLINE uint8_t battery_level_in_percent | ( | const uint16_t | mvolts ) | [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:
- Section 1: 3.0V - 2.9V = 100% - 42% (58% drop on 100 mV)
- Section 2: 2.9V - 2.74V = 42% - 18% (24% drop on 160 mV)
- Section 3: 2.74V - 2.44V = 18% - 6% (12% drop on 300 mV)
- Section 4: 2.44V - 2.1V = 6% - 0% (6% drop on 340 mV)
These numbers are by no means accurate. Temperature and load in the actual application is not accounted for!
- Parameters:
-
[in] mvolts The voltage in mV
- Returns:
- Battery level in percent.
Definition at line 428 of file app_util.h.
static __INLINE bool is_address_from_stack | ( | void * | ptr ) | [static] |
Function for checking if provided address is located in stack space.
- Parameters:
-
[in] ptr Pointer to be checked.
- Returns:
- true if address is in stack space, false otherwise.
Definition at line 478 of file app_util.h.
static __INLINE bool is_word_aligned | ( | void const * | p ) | [static] |
Function for checking if a pointer value is aligned to a 4 byte boundary.
- Parameters:
-
[in] p Pointer value to be checked.
- Returns:
- TRUE if pointer is aligned to a 4 byte boundary, FALSE otherwise.
Definition at line 466 of file app_util.h.
static __INLINE uint16_t uint16_big_decode | ( | const uint8_t * | p_encoded_data ) | [static] |
Function for decoding a uint16 value in big-endian format.
- Parameters:
-
[in] p_encoded_data Buffer where the encoded data is stored.
- Returns:
- Decoded value.
Definition at line 325 of file app_util.h.
static __INLINE uint16_t uint16_decode | ( | const uint8_t * | p_encoded_data ) | [static] |
Function for decoding a uint16 value.
- Parameters:
-
[in] p_encoded_data Buffer where the encoded data is stored.
- Returns:
- Decoded value.
Definition at line 313 of file app_util.h.
static __INLINE uint8_t uint16_encode | ( | uint16_t | value, |
uint8_t * | p_encoded_data | ||
) | [static] |
Function for encoding a uint16 value.
- Parameters:
-
[in] value Value to be encoded. [out] p_encoded_data Buffer where the encoded data is to be written.
- Returns:
- Number of bytes written.
Definition at line 251 of file app_util.h.
static __INLINE uint32_t uint24_decode | ( | const uint8_t * | p_encoded_data ) | [static] |
Function for decoding a three-byte value.
- Parameters:
-
[in] p_encoded_data Buffer where the encoded data is stored.
- Returns:
- Decoded value (uint32_t).
Definition at line 337 of file app_util.h.
static __INLINE uint8_t uint24_encode | ( | uint32_t | value, |
uint8_t * | p_encoded_data | ||
) | [static] |
Function for encoding a three-byte value.
- Parameters:
-
[in] value Value to be encoded. [out] p_encoded_data Buffer where the encoded data is to be written.
- Returns:
- Number of bytes written.
Definition at line 265 of file app_util.h.
static __INLINE uint32_t uint32_big_decode | ( | const uint8_t * | p_encoded_data ) | [static] |
Function for decoding a uint32 value in big-endian format.
- Parameters:
-
[in] p_encoded_data Buffer where the encoded data is stored.
- Returns:
- Decoded value.
Definition at line 364 of file app_util.h.
static __INLINE uint8_t uint32_big_encode | ( | uint32_t | value, |
uint8_t * | p_encoded_data | ||
) | [static] |
Function for encoding a uint32 value in big-endian format.
- Parameters:
-
[in] value Value to be encoded. [out] p_encoded_data Buffer where the encoded data will be written.
- Returns:
- Number of bytes written.
Definition at line 379 of file app_util.h.
static __INLINE uint32_t uint32_decode | ( | const uint8_t * | p_encoded_data ) | [static] |
Function for decoding a uint32 value.
- Parameters:
-
[in] p_encoded_data Buffer where the encoded data is stored.
- Returns:
- Decoded value.
Definition at line 350 of file app_util.h.
static __INLINE uint8_t uint32_encode | ( | uint32_t | value, |
uint8_t * | p_encoded_data | ||
) | [static] |
Function for encoding a uint32 value.
- Parameters:
-
[in] value Value to be encoded. [out] p_encoded_data Buffer where the encoded data is to be written.
- Returns:
- Number of bytes written.
Definition at line 280 of file app_util.h.
static __INLINE uint64_t uint48_decode | ( | const uint8_t * | p_encoded_data ) | [static] |
Function for decoding a uint48 value.
- Parameters:
-
[in] p_encoded_data Buffer where the encoded data is stored.
- Returns:
- Decoded value. (uint64_t)
Definition at line 398 of file app_util.h.
static __INLINE uint8_t uint48_encode | ( | uint64_t | value, |
uint8_t * | p_encoded_data | ||
) | [static] |
Function for encoding a uint48 value.
- Parameters:
-
[in] value Value to be encoded. [out] p_encoded_data Buffer where the encoded data is to be written.
- Returns:
- Number of bytes written.
Definition at line 296 of file app_util.h.
static __INLINE uint64_t value_rescale | ( | uint32_t | value, |
uint32_t | old_unit_reversal, | ||
uint16_t | new_unit_reversal | ||
) | [static] |
Function for changing the value unit.
- Parameters:
-
[in] value Value to be rescaled. [in] old_unit_reversal Reversal of the incoming unit. [in] new_unit_reversal Reversal of the desired unit.
- Returns:
- Number of bytes written.
Definition at line 239 of file app_util.h.
Generated on Wed Jul 13 2022 07:07:19 by 1.7.2