COMMON
- group npmx_common
Common functions for nPM device drivers.
Defines
-
NPMX_CHECK(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.
-
NPMX_REG_TO_ADDR(x)
Macro for getting peripheral register address.
-
NPMX_TASK_TRIGGER
Trigger value for all tasks.
-
NPMX_INVALID_ENUM_VALUE
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.
- Param p_pm:
[in] Pointer to the npmx instance.
- Param type:
[in] Callback type npmx_callback_type_t.
- Param mask:
[in] Mask of events.
Enums
-
enum npmx_callback_type_t
All possible callback types to be registered.
Values:
-
enumerator NPMX_CALLBACK_TYPE_EVENT_ADC
Callback run when EVENTSADCSET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_TEMP
Callback run when EVENTSBCHARGER0SET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_STATUS
Callback run when EVENTSBCHARGER1SET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_BAT
Callback run when EVENTSBCHARGER2SET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_SHIPHOLD
Callback run when EVENTSSHPHLDSET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_VBUSIN_VOLTAGE
Callback run when EVENTSVBUSIN0SET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_VBUSIN_THERMAL_USB
Callback run when EVENTSVBUSIN1SET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_EVENTSGPIOSET
Callback run when EVENTSGPIOSET register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_RSTCAUSE
Callback run when RSTCAUSE register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_CHARGER_ERROR
Callback run when CHARGERERRREASON or BCHGERRREASON register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_SENSOR_ERROR
Callback run when CHARGERERRSENSOR or BCHGERRSENSOR register is not empty.
-
enumerator NPMX_CALLBACK_TYPE_COUNT
Callbacks count.
-
enumerator NPMX_CALLBACK_TYPE_INVALID
Invalid callback type.
-
enumerator NPMX_CALLBACK_TYPE_EVENT_ADC
Functions
-
const char *npmx_callback_to_str(npmx_callback_type_t type)
Function for getting the callback name.
- Parameters:
type – [in] The specified callback type.
- Returns:
Pointer to 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.
- Parameters:
type – [in] The specified callback type.
bit – [in] The bit in callback register.
- Returns:
Pointer to the bit name.
-
int32_t npmx_common_div_round_closest(int32_t number, int32_t divisor)
Function for integer dividing of a number.
- Parameters:
number – [in] Number to be divided and rounded.
divisor – [in] Divisor of the number.
- Returns:
Divided and rounded integer.
-
int32_t npmx_common_round_get(float variable)
Function for getting the result of rounding of a number.
- Parameters:
variable – [in] Input number.
- Returns:
Result of rounding.
-
float npmx_common_fabs_get(float variable)
Function for getting the absolute value of a floating point number.
- Parameters:
variable – [in] Input number.
- Returns:
The absolute value.
-
float npmx_common_exp_get(float variable)
Function for getting the exponent of a number.
Note
From: https://stackoverflow.com/questions/70382318/ex-without-math-h Based on Maclaurin series.
- Parameters:
variable – [in] Input number.
- Returns:
The exponent value.
-
float npmx_common_ln_get(float variable)
Function for getting the natural logarithm of a number.
From: https://gist.github.com/LingDong-/7e4c4cae5cbbc44400a05fba65f06f23
- Parameters:
variable – [in] Input number.
- Returns:
The natural logarithm value.
-
NPMX_CHECK(module_enabled)