npmx  1.0.0
 
Loading...
Searching...
No Matches
COMMON

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.
 

Detailed Description

Common functions for nPM device drivers.

Macro Definition Documentation

◆ NPMX_CHECK

#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 Documentation

◆ npmx_callback_t

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.

Parameters
[in]p_pmPointer to the npmx instance.
[in]typeCallback type npmx_callback_type_t.
[in]maskMask of events.

Enumeration Type Documentation

◆ npmx_callback_type_t

All possible callback types to be registered.

Enumerator
NPMX_CALLBACK_TYPE_EVENT_ADC 

Callback run when EVENTSADCSET register is not empty.

NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_TEMP 

Callback run when EVENTSBCHARGER0SET register is not empty.

NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_STATUS 

Callback run when EVENTSBCHARGER1SET register is not empty.

NPMX_CALLBACK_TYPE_EVENT_BAT_CHAR_BAT 

Callback run when EVENTSBCHARGER2SET register is not empty.

NPMX_CALLBACK_TYPE_EVENT_SHIPHOLD 

Callback run when EVENTSSHPHLDSET register is not empty.

NPMX_CALLBACK_TYPE_EVENT_VBUSIN_VOLTAGE 

Callback run when EVENTSVBUSIN0SET register is not empty.

NPMX_CALLBACK_TYPE_EVENT_VBUSIN_THERMAL_USB 

Callback run when EVENTSVBUSIN1SET register is not empty.

NPMX_CALLBACK_TYPE_EVENT_EVENTSGPIOSET 

Callback run when EVENTSGPIOSET register is not empty.

NPMX_CALLBACK_TYPE_RSTCAUSE 

Callback run when RSTCAUSE register is not empty.

NPMX_CALLBACK_TYPE_CHARGER_ERROR 

Callback run when CHARGERERRREASON or BCHGERRREASON register is not empty.

NPMX_CALLBACK_TYPE_SENSOR_ERROR 

Callback run when CHARGERERRSENSOR or BCHGERRSENSOR register is not empty.

NPMX_CALLBACK_TYPE_COUNT 

Callbacks count.

NPMX_CALLBACK_TYPE_INVALID 

Invalid callback type.

Function Documentation

◆ npmx_callback_bit_to_str()

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
[in]typeThe specified callback type.
[in]bitThe bit in callback register.
Returns
Pointer to the bit name.

◆ npmx_callback_to_str()

const char * npmx_callback_to_str ( npmx_callback_type_t type)

Function for getting the callback name.

Parameters
[in]typeThe specified callback type.
Returns
Pointer to the callback name.

◆ npmx_common_div_round_closest()

int32_t npmx_common_div_round_closest ( int32_t number,
int32_t divisor )

Function for integer dividing of a number.

Parameters
[in]numberNumber to be divided and rounded.
[in]divisorDivisor of the number.
Returns
Divided and rounded integer.

◆ npmx_common_exp_get()

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
[in]variableInput number.
Returns
The exponent value.

◆ npmx_common_fabs_get()

float npmx_common_fabs_get ( float variable)

Function for getting the absolute value of a floating point number.

Parameters
[in]variableInput number.
Returns
The absolute value.

◆ npmx_common_ln_get()

float npmx_common_ln_get ( float variable)

Function for getting the natural logarithm of a number.

From: https://gist.github.com/LingDong-/7e4c4cae5cbbc44400a05fba65f06f23

Parameters
[in]variableInput number.
Returns
The natural logarithm value.

◆ npmx_common_round_get()

int32_t npmx_common_round_get ( float variable)

Function for getting the result of rounding of a number.

Parameters
[in]variableInput number.
Returns
Result of rounding.