Common functions for nPM device drivers. More...
Macros | |
#define | NPMX_CHECK(module_enabled) (module_enabled) |
Macro for checking if the specified identifier is defined and it has a non-zero value. | |
#define | NPMX_REG_TO_ADDR(x) ((uint16_t)(size_t)(&(x))) |
Macro for getting peripheral register address. | |
#define | NPMX_TASK_TRIGGER 1U |
Trigger value for all tasks. | |
#define | NPMX_INVALID_ENUM_VALUE UINT_MAX |
Invalid enum value. | |
Typedefs | |
typedef void(* | npmx_callback_t) (npmx_instance_t *p_pm, npmx_callback_type_t type, uint8_t mask) |
Definition of pointer to type of function used as a callback. | |
Enumerations | |
enum | npmx_callback_type_t { NPMX_CALLBACK_TYPE_EVENT_ADC , NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_TEMP , NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_STATUS , NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_BAT , NPMX_CALLBACK_TYPE_EVENT_SHIPHOLD , NPMX_CALLBACK_TYPE_EVENT_VBUSIN_VOLTAGE , NPMX_CALLBACK_TYPE_EVENT_VBUSIN_THERMAL_USB , NPMX_CALLBACK_TYPE_EVENT_EVENTSGPIOSET , NPMX_CALLBACK_TYPE_RSTCAUSE , NPMX_CALLBACK_TYPE_CHARGER_ERROR , NPMX_CALLBACK_TYPE_SENSOR_ERROR , NPMX_CALLBACK_TYPE_COUNT , NPMX_CALLBACK_TYPE_INVALID = UINT_MAX } |
All possible callback types to be registered. More... | |
Functions | |
const char * | npmx_callback_to_str (npmx_callback_type_t type) |
Function for getting the callback name. | |
const char * | npmx_callback_bit_to_str (npmx_callback_type_t type, uint8_t bit) |
Function for getting a name of a callback bit. | |
int32_t | npmx_common_div_round_closest (int32_t number, int32_t divisor) |
Function for integer dividing of a number. | |
int32_t | npmx_common_round_get (float variable) |
Function for getting the result of rounding of a number. | |
float | npmx_common_fabs_get (float variable) |
Function for getting the absolute value of a floating point number. | |
float | npmx_common_exp_get (float variable) |
Function for getting the exponent of a number. | |
float | npmx_common_ln_get (float variable) |
Function for getting the natural logarithm of a number. | |
Common functions for nPM device drivers.
#define NPMX_CHECK | ( | module_enabled | ) | (module_enabled) |
Macro for checking if the specified identifier is defined and it has a non-zero value.
Normally, preprocessors treat all undefined identifiers as having the value of zero. However, some tools, like static code analyzers, can issue a warning when such identifier is evaluated. This macro gives the possibility to suppress such warnings only in places where this macro is used for evaluation, not in the whole analyzed code.
typedef void(* npmx_callback_t) (npmx_instance_t *p_pm, npmx_callback_type_t type, uint8_t mask) |
Definition of pointer to type of function used as a callback.
[in] | p_pm | Pointer to the npmx instance. |
[in] | type | Callback type npmx_callback_type_t. |
[in] | mask | Mask of events. |
enum npmx_callback_type_t |
All possible callback types to be registered.
const char * npmx_callback_bit_to_str | ( | npmx_callback_type_t | type, |
uint8_t | bit ) |
Function for getting a name of a callback bit.
[in] | type | The specified callback type. |
[in] | bit | The bit in callback register. |
const char * npmx_callback_to_str | ( | npmx_callback_type_t | type | ) |
Function for getting the callback name.
[in] | type | The specified callback type. |
int32_t npmx_common_div_round_closest | ( | int32_t | number, |
int32_t | divisor ) |
Function for integer dividing of a number.
[in] | number | Number to be divided and rounded. |
[in] | divisor | Divisor of the number. |
float npmx_common_exp_get | ( | float | variable | ) |
Function for getting the exponent of a number.
[in] | variable | Input number. |
float npmx_common_fabs_get | ( | float | variable | ) |
Function for getting the absolute value of a floating point number.
[in] | variable | Input number. |
float npmx_common_ln_get | ( | float | variable | ) |
Function for getting the natural logarithm of a number.
From: https://gist.github.com/LingDong-/7e4c4cae5cbbc44400a05fba65f06f23
[in] | variable | Input number. |
int32_t npmx_common_round_get | ( | float | variable | ) |
Function for getting the result of rounding of a number.
[in] | variable | Input number. |