ADC

group npmx_adc

Analog-to-Digital Converter (ADC) peripheral driver.

Enums

enum npmx_adc_task_t

ADC tasks.

Values:

enumerator NPMX_ADC_TASK_SINGLE_SHOT_VBAT

VBAT single-shot measurement trigger.

enumerator NPMX_ADC_TASK_SINGLE_SHOT_NTC

Battery NTC single-shot measurement trigger.

enumerator NPMX_ADC_TASK_SINGLE_SHOT_DIE_TEMP

Internal die temperature single-shot measurement trigger.

enumerator NPMX_ADC_TASK_SINGLE_SHOT_VSYS

VSYS voltage single-shot measurement trigger.

enumerator NPMX_ADC_TASK_SINGLE_SHOT_VBUS

VBUS (7 Volt range) single-shot measurement trigger.

enumerator NPMX_ADC_TASK_DELAYED_MEAS_VBAT

VBAT delay measurement trigger.

enumerator NPMX_ADC_TASK_UPDATE_AUTO_INTERVAL

Update intervals for NTC and die temperature auto measurements trigger.

enumerator NPMX_ADC_TASK_COUNT

ADC tasks count.

enum npmx_adc_meas_t

Possible measurements that can be read from ADC.

Values:

enumerator NPMX_ADC_MEAS_VBAT

VBAT measurement (in millivolts).

enumerator NPMX_ADC_MEAS_BAT_TEMP

Battery temperature (in millidegrees Celsius). For proper temperature calculations, a thermistor type and NTC beta value should be set with the npmx_adc_config_set function.

enumerator NPMX_ADC_MEAS_DIE_TEMP

Internal die temperature measurement (in millidegrees Celsius).

enumerator NPMX_ADC_MEAS_VSYS

VSYS voltage measurement (in millivolts).

enumerator NPMX_ADC_MEAS_VBUS

VBUS (7 Volt range) measurement (in millivolts).

enumerator NPMX_ADC_MEAS_VBAT0

VBAT0 from burst mode measurement (in millivolts).

enumerator NPMX_ADC_MEAS_VBAT1

VBAT1 from burst mode measurement (in millivolts).

enumerator NPMX_ADC_MEAS_VBAT2_IBAT

Measurement of either VBAT2 in burst mode or IBAT (respectively in millivolts or milliamperes).

enumerator NPMX_ADC_MEAS_VBAT3_VBUS

Measurement of either VBAT3 in burst mode or VBUS (both in millivolts).

enumerator NPMX_ADC_MEAS_COUNT

ADC requests maximum count.

enumerator NPMX_ADC_MEAS_INVALID

Invalid ADC measurement.

enum npmx_adc_ntc_type_t

Battery NTC type. Should be checked in battery documentation.

Values:

enumerator NPMX_ADC_NTC_TYPE_HI_Z

No resistor.

enumerator NPMX_ADC_NTC_TYPE_10_K

NTC10K.

enumerator NPMX_ADC_NTC_TYPE_47_K

NTC47K.

enumerator NPMX_ADC_NTC_TYPE_100_K

NTC100K.

enumerator NPMX_ADC_NTC_TYPE_COUNT

NTC types count.

enumerator NPMX_ADC_NTC_TYPE_MAX

Maximum resistance.

enumerator NPMX_ADC_NTC_TYPE_INVALID

Invalid battery NTC type.

enum npmx_adc_ntc_meas_interval_t

Intervals of automatic measurements of NTC during charging.

Values:

enumerator NPMX_ADC_NTC_MEAS_INTERVAL_4_MS

Interval equal to 4 ms.

enumerator NPMX_ADC_NTC_MEAS_INTERVAL_64_MS

Interval equal to 64 ms.

enumerator NPMX_ADC_NTC_MEAS_INTERVAL_128_MS

Interval equal to 128 ms.

enumerator NPMX_ADC_NTC_MEAS_INTERVAL_1024_MS

Interval equal to 1024 ms.

enumerator NPMX_ADC_NTC_MEAS_INTERVAL_COUNT

Interval values count.

enumerator NPMX_ADC_NTC_MEAS_INTERVAL_MAX

Maximum interval value.

enumerator NPMX_ADC_NTC_MEAS_INTERVAL_INVALID

Invalid interval value.

enum npmx_adc_die_temp_meas_interval_t

Intervals of automatic measurements of die temperature during charging.

Values:

enumerator NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_4_MS

Interval equal to 4 ms.

enumerator NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_8_MS

Interval equal to 8 ms.

enumerator NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_16_MS

Interval equal to 16 ms.

enumerator NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_32_MS

Interval equal to 32 ms.

enumerator NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_COUNT

Interval values count.

enumerator NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_MAX

Maximum interval value.

enumerator NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_INVALID

Invalid interval value.

enum npmx_adc_ibat_meas_current_t

Battery charging current.

Values:

enumerator NPMX_ADC_IBAT_MEAS_CURRENT_TRICKLE

10% charge (Trickle).

enumerator NPMX_ADC_IBAT_MEAS_CURRENT_LOWTEMP

50% charge (Low Temp).

enumerator NPMX_ADC_IBAT_MEAS_CURRENT_RFU

10% charge (default, RFU).

enumerator NPMX_ADC_IBAT_MEAS_CURRENT_FAST

100% charge (Fast).

enumerator NPMX_ADC_IBAT_MEAS_CURRENT_MAX

Maximum current value.

enumerator NPMX_ADC_IBAT_MEAS_CURRENT_INVALID

Invalid current value.

Functions

npmx_adc_t *npmx_adc_get(npmx_instance_t *p_pmic, uint8_t idx)

Function for returning ADC instance based on index.

Parameters:
  • p_pmic[in] Pointer to the PMIC instance.

  • idx[in] Index of the ADC instance.

Returns:

Pointer to the ADC instance.

npmx_adc_ntc_type_t npmx_adc_ntc_type_convert(uint32_t resistance)

Function for converting resistance in ohms to npmx_adc_ntc_type_t enumeration.

Parameters:
Returns:

Result of conversion. NPMX_ADC_NTC_TYPE_INVALID if given resistance is not represented in enumeration.

bool npmx_adc_ntc_type_convert_to_ohms(npmx_adc_ntc_type_t battery_ntc, uint32_t *p_val)

Function for converting the value from NTC enumeration type to resistance.

Parameters:
  • battery_ntc[in] Battery NTC type.

  • p_val[out] Pointer to the variable that stores the conversion result.

Return values:
  • true – Conversion is valid.

  • false – Conversion is invalid - an invalid argument was passed to the function.

npmx_adc_ntc_meas_interval_t npmx_adc_ntc_meas_interval_convert(uint32_t time)

Function for converting time in milliseconds to npmx_adc_ntc_meas_interval_t enumeration.

Parameters:
Returns:

Result of conversion. NPMX_ADC_NTC_MEAS_INTERVAL_INVALID if given time is not represented in enumeration.

bool npmx_adc_ntc_meas_interval_convert_to_ms(npmx_adc_ntc_meas_interval_t enum_value, uint32_t *p_val)

Function for converting npmx_adc_ntc_meas_interval_t enumeration to milliseconds.

Parameters:
  • enum_value[in] Time defined as npmx_adc_ntc_meas_interval_t enumeration to be converted into milliseconds.

  • p_val[out] Pointer to the variable that stores the conversion result.

Return values:
  • true – Conversion is valid.

  • false – Conversion is invalid - an invalid argument was passed to the function.

npmx_adc_die_temp_meas_interval_t npmx_adc_die_temp_meas_interval_convert(uint32_t time)

Function for converting time in milliseconds to npmx_adc_die_temp_meas_interval_t enumeration.

Parameters:
Returns:

Result of conversion. NPMX_ADC_DIE_TEMP_MEAS_INTERVAL_INVALID if given time is not represented in enumeration.

bool npmx_adc_die_temp_meas_interval_convert_to_ms(npmx_adc_die_temp_meas_interval_t enum_value, uint32_t *p_val)

Function for converting npmx_adc_die_temp_meas_interval_t enumeration to milliseconds.

Parameters:
  • enum_value[in] Time defined as npmx_adc_die_temp_meas_interval_t enumeration to be converted into milliseconds.

  • p_val[out] Pointer to the variable that stores the conversion result.

Return values:
  • true – Conversion is valid.

  • false – Conversion is invalid - an invalid argument was passed to the function.

const char *const npmx_adc_ntc_type_map_to_string(npmx_adc_ntc_type_t enum_value)

Function for mapping npmx_adc_ntc_type_t enumeration values to string.

Parameters:
Returns:

Result of conversion.

npmx_error_t npmx_adc_task_trigger(npmx_adc_t const *p_instance, npmx_adc_task_t task)

Function for activating the specified ADC task.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • task[in] Task to be activated.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_config_set(npmx_adc_t *p_instance, npmx_adc_config_t const *p_config)

Function for setting the configuration for ADC.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_config[in] Pointer to the configuration of the ADC to be applied.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_config_get(npmx_adc_t *p_instance, npmx_adc_config_t *p_config)

Function for reading the ADC configuration.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_config[out] Pointer to the ADC configuration structure.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ntc_config_set(npmx_adc_t *p_instance, npmx_adc_ntc_config_t const *p_config)

Function for configuring a battery NTC thermistor.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_config[in] Pointer to the battery NTC thermistor configuration structure.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ntc_config_get(npmx_adc_t *p_instance, npmx_adc_ntc_config_t *p_config)

Function for getting a configuration of the battery NTC thermistor.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_config[out] Pointer to the battery NTC thermistor configuration structure.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ntc_resistance_get(npmx_adc_t const *p_instance, uint32_t *p_resistance)

Function for getting the nominal NTC resistance.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_resistance[out] Pointer to the nominal NTC resistance value in ohms.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_meas_check(npmx_adc_t const *p_instance, npmx_adc_meas_t meas, bool *p_ready)

Function for checking if measured value is ready to be read.

Note

This function should not be used when interrupt for measurement is enabled.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • meas[in] Measurement value to be checked.

  • p_ready[out] Pointer to variable for check value.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_meas_get(npmx_adc_t const *p_instance, npmx_adc_meas_t meas, int32_t *p_value)

Function for getting measured value.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • meas[in] Measurement value to be read.

  • p_value[out] Pointer to variable for read value.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_INVALID_PARAM – Not possible to calculate value for given npmx_adc_meas_t.

  • NPMX_ERROR_IO – Error using IO bus line.

  • NPMX_ERROR_INVALID_MEAS – Invalid measurement for given npmx_adc_meas_t.

npmx_error_t npmx_adc_meas_all_get(npmx_adc_t const *p_instance, npmx_adc_meas_all_t *p_values)

Function for getting all measured values.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_values[out] Pointer to structure with read values.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ntc_meas_interval_set(npmx_adc_t *p_instance, npmx_adc_ntc_meas_interval_t interval)

Function for setting the NTC measurement interval during charging.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • interval[in] Interval value.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ntc_meas_interval_get(npmx_adc_t *p_instance, npmx_adc_ntc_meas_interval_t *p_interval)

Function for getting NTC auto measurement interval during charging.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_interval[out] Pointer to interval for NTC auto measurement during charging.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_die_temp_meas_interval_set(npmx_adc_t *p_instance, npmx_adc_die_temp_meas_interval_t interval)

Function for setting the die temperature measurement interval during charging.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • interval[in] Interval value.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_die_temp_meas_interval_get(npmx_adc_t *p_instance, npmx_adc_die_temp_meas_interval_t *p_interval)

Function for getting die temperature auto measurement interval during charging.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_interval[out] Pointer to interval for die temperature auto measurement during charging.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_vbat_meas_delay_set(npmx_adc_t const *p_instance, uint8_t delay)

Function for setting the delay of battery voltage measurement after going into sleep mode.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • delay[in] Delay value in ms, min 2, max 255.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_vbat_meas_delay_get(npmx_adc_t const *p_instance, uint8_t *p_delay)

Function for getting the delay of battery voltage measurement after going into sleep mode.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_delay[out] Pointer to read delay value.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ibat_meas_status_get(npmx_adc_t const *p_instance, npmx_adc_ibat_meas_status_t *p_ibat_meas_status)

Function for getting the battery current measurement status.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_ibat_meas_status[out] Pointer to the IBAT measurement status structure.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ibat_meas_enable_set(npmx_adc_t const *p_instance, bool enable)

Function for setting the auto measurement of battery current.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • enable[in] True if auto IBAT measurement is to be enabled, false otherwise.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_adc_ibat_meas_enable_check(npmx_adc_t const *p_instance, bool *p_enable)

Function for checking whether auto measurement of battery current is enabled.

Parameters:
  • p_instance[in] Pointer to the ADC instance.

  • p_enable[out] Pointer to the auto IBAT measurement variable. True if auto measurement is enabled, false otherwise.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

struct npmx_adc_t
#include <npmx_adc.h>

Data structure of the Analog-to-Digital Converter (ADC) driver instance.

Public Members

npmx_instance_t *p_pmic

Pointer to the PMIC instance.

bool burst

True if burst measurement is enabled, false otherwise.

uint32_t ntc_beta

Battery NTC beta value.

struct npmx_adc_config_t
#include <npmx_adc.h>

Configuration structure for ADC.

Public Members

bool vbat_auto

Enable VBAT auto measurement every 1 second.

bool vbat_burst

Enable VBAT Burst mode VBAT0, VBAT1, VBAT2, VBAT3.

struct npmx_adc_meas_all_t
#include <npmx_adc.h>

Structure for all measurements readings.

Public Members

int32_t values[NPMX_ADC_MEAS_COUNT]

Table for all measurements readings.

struct npmx_adc_ibat_meas_status_t
#include <npmx_adc.h>

Structure for the battery current measurement status.

Public Members

npmx_adc_ibat_meas_current_t charge_current

Charging current type.

bool charging

True if battery is being charged, false if battery is discharging.

struct npmx_adc_ntc_config_t
#include <npmx_adc.h>

Configuration structure for battery NTC thermistor.

Public Members

npmx_adc_ntc_type_t type

Battery NTC type.

uint32_t beta

Battery NTC beta value.