Device driver for Texas Instruments INA3221 three-channel ,high-side current and bus voltage monitor. More...
Device driver for Texas Instruments INA3221 three-channel ,high-side current and bus voltage monitor.
Files | |
| file | ina3221_defines.h |
| Internal definitions for Texas Instruments INA3221 three-channel, high-side current and bus voltage monitor. | |
| file | ina3221_internal.h |
| Functions to convert register values of INA3221 to actual voltage values and vice versa. | |
| file | ina3221_params.h |
| Driver configuration parameters for Texas Instruments INA3221 three-channel, high-side current and bus voltage monitor. | |
| file | ina3221_regs.h |
| Register definitions for Texas Instruments INA3221 three-channel, high-side current and bus voltage monitor. | |
| file | ina3221.h |
| Device driver interface for Texas Instruments INA3221 three-channel ,high-side current and bus voltage monitor. | |
Data Structures | |
| struct | ina3221_params_t |
| INA3221 device parameters. More... | |
| struct | ina3221_t |
| INA3221 device handle struct. More... | |
Macros | |
| #define | INA3221_NUM_CH (3) |
| Number of channels. | |
| #define | INA3221_NUM_ALERTS (4) |
| Number of alerts. | |
| #define | INA3221_MODE_MASK (0x0007) |
| Device operation mode bit mask. | |
| #define | INA3221_CONV_TIME_SADC_MASK (0x0038) |
| ADC shunt voltage conversion times bit mask. | |
| #define | INA3221_CONV_TIME_BADC_MASK (0x01C0) |
| ADC bus voltage conversion times bit mask. | |
| #define | INA3221_NUM_SAMPLES_MASK (0x0E00) |
| Number of samples to calculate average shunt/bus voltage value bit mask. | |
| #define | INA3221_ENABLE_CH_MASK |
| Enable channel bit mask. More... | |
| #define | INA3221_ENABLE_SUM_CH_MASK |
| Enable shunt voltage sum calculation channel bit mask. More... | |
| #define | INA3221_ENABLE_LATCH_MASK |
| Enable latch bit mask. More... | |
| #define | INA3221_DEFCONFIG (0x7127) |
| Default configuration register value. | |
| #define | INA3221_RESET (0x8000) |
| Reset configuration register value. | |
| #define | INA3221_FLAG_CRIT_ALERT_CH1 (0x0200) |
| Critical alert channel 1 flag. | |
| #define | INA3221_FLAG_CRIT_ALERT_CH2 (0x0100) |
| Critical alert channel 2 flag. | |
| #define | INA3221_FLAG_CRIT_ALERT_CH3 (0x0080) |
| Critical alert channel 3 flag. | |
| #define | INA3221_FLAG_SHUNT_SUM_ALERT (0x0040) |
| Alert channel sum flag. | |
| #define | INA3221_FLAG_WARN_ALERT_CH1 (0x0020) |
| Warning alert channel 1 flag. | |
| #define | INA3221_FLAG_WARN_ALERT_CH2 (0x0010) |
| Warning alert channel 2 flag. | |
| #define | INA3221_FLAG_WARN_ALERT_CH3 (0x0008) |
| Warning alert channel 3 flag. | |
| #define | INA3221_FLAG_POWER_VALID (0x0004) |
| Power valid flag. | |
| #define | INA3221_FLAG_TIMING_CONTROL (0x0002) |
| Timing Control flag. | |
| #define | INA3221_FLAG_CONV_READY (0x0001) |
| Conversion ready flag. | |
| #define | INA3221_FLAGS_MASK |
| Flags bit mask. More... | |
| #define | INA3221_TRIGGER_SHUNT(dev) ina3221_set_mode(dev, INA3221_MODE_TRIGGER_SHUNT_ONLY) |
| Set operation mode to INA3221_MODE_TRIGGER_SHUNT_ONLY to trigger shunt voltage measurement. More... | |
| #define | INA3221_TRIGGER_BUS(dev) ina3221_set_mode(dev, INA3221_MODE_TRIGGER_BUS_ONLY) |
| Set operation mode to INA3221_MODE_TRIGGER_BUS_ONLY to trigger bus voltage measurement. More... | |
| #define | INA3221_TRIGGER_SHUNT_AND_BUS(dev) ina3221_set_mode(dev, INA3221_MODE_TRIGGER_SHUNT_BUS) |
| Set operation mode to INA3221_MODE_TRIGGER_SHUNT_BUS to trigger shunt and bus voltage measurement. More... | |
Typedefs | |
| typedef void(* | ina3221_alert_cb_t) (void *arg) |
| INA3221 alert callback for alert pins CRT, WRN, TC, PV. | |
| typedef enum ina3221_ret_val | ina3221_ret_val_t |
| Return codes. | |
| typedef enum ina3221_dev_addr | ina3221_dav_addr_t |
| I2C device addresses. | |
| typedef enum ina3221_channel | ina3221_channel_t |
| Channel flags. | |
| typedef enum ina3221_alert | ina3221_alert_t |
| Alert indices. | |
| typedef enum ina3221_mode | ina3221_mode_t |
| Device operation modes. | |
| typedef enum ina3221_conv_time_shunt_adc | ina3221_conv_time_shunt_adc_t |
| ADC shunt voltage conversion times. | |
| typedef enum ina3221_conv_time_bus_adc | ina3221_conv_time_bus_adc_t |
| ADC bus voltage conversion times. | |
| typedef enum ina3221_num_samples | ina3221_num_samples_t |
| Number of samples to calculate average shunt/bus voltage value. | |
| typedef enum ina3221_enable_ch | ina3221_enable_ch_t |
| Enable channel flags. | |
| typedef enum ina3221_channel_state | ina3221_channel_state_t |
| Channel state enabled/disabled. | |
| typedef enum ina3221_enable_sum_ch | ina3221_enable_sum_ch_t |
| Enable shunt voltage sum calculation channel flags. | |
| typedef enum ina3221_enable_latch | ina3221_enable_latch_t |
| Enable latch flags. | |
Functions | |
| int | ina3221_reset (ina3221_t *dev) |
| Reset device, i.e. More... | |
| int | ina3221_init (ina3221_t *dev, const ina3221_params_t *params) |
| Initialize device. More... | |
| int | _ina3221_enable_alert (ina3221_t *dev, ina3221_alert_t alert, ina3221_alert_cb_t cb, void *arg) |
Enable alert callback and argument for alert alert. More... | |
| static int | ina3221_enable_warning_alert (ina3221_t *dev, ina3221_alert_cb_t cb, void *arg) |
| Wrapper around. More... | |
| static int | ina3221_enable_critical_alert (ina3221_t *dev, ina3221_alert_cb_t cb, void *arg) |
| Wrapper around. More... | |
| static int | ina3221_enable_timing_control_alert (ina3221_t *dev, ina3221_alert_cb_t cb, void *arg) |
| Wrapper around. More... | |
| static int | ina3221_enable_power_valid_alert (ina3221_t *dev, ina3221_alert_cb_t cb, void *arg) |
| Wrapper around. More... | |
| int | _ina3221_disable_alert (ina3221_t *dev, ina3221_alert_t alert) |
Disable alert callback and argument for alert alert. More... | |
| static int | ina3221_disable_warning_alert (ina3221_t *dev) |
| Wrapper around. More... | |
| static int | ina3221_disable_critical_alert (ina3221_t *dev) |
| Wrapper around. More... | |
| static int | ina3221_disable_timing_control_alert (ina3221_t *dev) |
| Wrapper around. More... | |
| static int | ina3221_disable_power_valid_alert (ina3221_t *dev) |
| Wrapper around. More... | |
| int | _ina3221_set_config (ina3221_t *dev, uint16_t cfg) |
| Write configuration register value to configuration register. More... | |
| static int | ina3221_set_config (ina3221_t *dev, ina3221_enable_ch_t chs, ina3221_num_samples_t ns, ina3221_conv_time_bus_adc_t ctbadc, ina3221_conv_time_shunt_adc_t ctsadc, ina3221_mode_t mode) |
| Wrapper around. More... | |
| int | _ina3221_get_config (const ina3221_t *dev, uint16_t *cfg) |
| Read currently saved configuration register value. More... | |
| static int | ina3221_get_config (const ina3221_t *dev, ina3221_enable_ch_t *chs, ina3221_num_samples_t *ns, ina3221_conv_time_bus_adc_t *ctbadc, ina3221_conv_time_shunt_adc_t *ctsadc, ina3221_mode_t *mode) |
| Wrapper around. More... | |
| int | _ina3221_set_enable_channel (ina3221_t *dev, ina3221_enable_ch_t ech) |
| Enable channels. More... | |
| static int | ina3221_set_channel_state (ina3221_t *dev, ina3221_channel_state_t ch1, ina3221_channel_state_t ch2, ina3221_channel_state_t ch3) |
| Wrapper around. More... | |
| int | _ina3221_get_enable_channel (const ina3221_t *dev, ina3221_enable_ch_t *ech) |
| Read which channels are currently enabled. More... | |
| static int | ina3221_get_channel_state (const ina3221_t *dev, ina3221_channel_state_t *ch1, ina3221_channel_state_t *ch2, ina3221_channel_state_t *ch3) |
| Wrapper around _ina3221_get_enable_channel. More... | |
| int | ina3221_set_num_samples (ina3221_t *dev, ina3221_num_samples_t ns) |
| Update number of samples and write to configuration register. More... | |
| int | ina3221_get_num_samples (const ina3221_t *dev, ina3221_num_samples_t *ns) |
| Read currently applied number of samples. More... | |
| int | ina3221_set_conv_time_bus_adc (ina3221_t *dev, ina3221_conv_time_bus_adc_t ctb) |
| Update conversion time of bus voltage ADC and write to configuration register. More... | |
| int | ina3221_get_conv_time_bus_adc (const ina3221_t *dev, ina3221_conv_time_bus_adc_t *ctb) |
| Read currently applied bus voltage ADC conversion time. More... | |
| int | ina3221_set_conv_time_shunt_adc (ina3221_t *dev, ina3221_conv_time_shunt_adc_t cts) |
| Update conversion time of shunt voltage ADC and write to configuration register. More... | |
| int | ina3221_get_conv_time_shunt_adc (const ina3221_t *dev, ina3221_conv_time_shunt_adc_t *cts) |
| Read currently applied shunt voltage ADC conversion time. More... | |
| int | ina3221_set_mode (ina3221_t *dev, ina3221_mode_t mode) |
| Update device operation mode. More... | |
| int | ina3221_get_mode (const ina3221_t *dev, ina3221_mode_t *mode) |
| Read currently applied device operation mode. More... | |
| int | _ina3221_set_enable_sum_channel (const ina3221_t *dev, ina3221_enable_sum_ch_t esch) |
| Enable channels for shunt voltage sum calculation. More... | |
| static int | ina3221_set_enable_sum_channel (const ina3221_t *dev, ina3221_channel_state_t ch1, ina3221_channel_state_t ch2, ina3221_channel_state_t ch3) |
| Wrapper around. More... | |
| int | _ina3221_get_enable_sum_channel (const ina3221_t *dev, ina3221_enable_sum_ch_t *esch) |
| Read enabled channels for shunt voltage sum calculation. More... | |
| static int | ina3221_get_enable_sum_channel (const ina3221_t *dev, ina3221_channel_state_t *ch1, ina3221_channel_state_t *ch2, ina3221_channel_state_t *ch3) |
| Wrapper for. More... | |
| int | ina3221_set_latch (const ina3221_t *dev, ina3221_enable_latch_t latch) |
| Enable latches for critical/warning alert pins. More... | |
| int | ina3221_get_latch (const ina3221_t *dev, ina3221_enable_latch_t *latch) |
| Read enabled latches for critical/warning alert pins. More... | |
| int | ina3221_set_crit_alert_limit (const ina3221_t *dev, ina3221_channel_t ch, int32_t in_uv) |
Set critical shunt voltage alert limit to in_uv for each channel in ch. More... | |
| int | ina3221_get_crit_alert_limit (const ina3221_t *dev, ina3221_channel_t ch, int32_t *out_uv) |
Read critical shunt voltage alert limit for each channel in ch. More... | |
| int | ina3221_set_warn_alert_limit (const ina3221_t *dev, ina3221_channel_t ch, int32_t in_uv) |
Set warning shunt voltage alert limit to in_uv for each channel in ch. More... | |
| int | ina3221_get_warn_alert_limit (const ina3221_t *dev, ina3221_channel_t ch, int32_t *out_uv) |
Read warning shunt voltage alert limit for each channel in ch. More... | |
| int | ina3221_set_shunt_voltage_sum_alert_limit (const ina3221_t *dev, int32_t in_uv) |
Set shunt voltage sum alert limit to in_uv. More... | |
| int | ina3221_get_shunt_voltage_sum_alert_limit (const ina3221_t *dev, int32_t *out_uv) |
| Read shunt voltage sum alert limit. More... | |
| int | ina3221_set_power_valid_upper_limit (const ina3221_t *dev, int32_t in_mv) |
Set bus voltage power valid upper limit to in_mv. More... | |
| int | ina3221_get_power_valid_upper_limit (const ina3221_t *dev, int32_t *out_mv) |
| Read bus voltage power valid upper limit. More... | |
| int | ina3221_set_power_valid_lower_limit (const ina3221_t *dev, int32_t in_mv) |
Set bus voltage power valid lower limit to in_mv. More... | |
| int | ina3221_get_power_valid_lower_limit (const ina3221_t *dev, int32_t *out_mv) |
| Read bus voltage power valid lower limit. More... | |
| int | ina3221_read_flags (const ina3221_t *dev, uint16_t *flags) |
| Read status flags. More... | |
| int | ina3221_read_shunt_sum_uv (const ina3221_t *dev, int32_t *out_uv, uint16_t *flags) |
| Read sum of shunt voltages. More... | |
| int | ina3221_read_shunt_uv (const ina3221_t *dev, ina3221_channel_t ch, int32_t *out_uv, uint16_t *flags) |
Read shunt voltages for each channel in ch. More... | |
| int | ina3221_read_bus_mv (const ina3221_t *dev, ina3221_channel_t ch, int16_t *out_mv, uint16_t *flags) |
Read bus voltages for each channel in ch. More... | |
| int | ina3221_calculate_current_ua (const ina3221_t *dev, ina3221_channel_t ch, int32_t *in_uv, int32_t *out_ma) |
Calculate current for each channel in ch. More... | |
| int | ina3221_calculate_power_uw (int16_t *in_mv, int32_t *in_ua, uint8_t num, int32_t *out_mw) |
| Calculate power from bus voltage and current values. More... | |
| void | ina3221_ch_align (ina3221_channel_t ch, const void *in_res, void *out_res, size_t res_val_size) |
Align in_res to the number of channels For example: ch = (INA3221_CH1 | INA3221_CH3) in_res = {value_ch1, value_ch3}, then out_res will be {value_ch1, 0, value_ch3}. More... | |
| #define INA3221_ENABLE_CH_MASK |
Enable channel bit mask.
| #define INA3221_ENABLE_LATCH_MASK |
Enable latch bit mask.
| #define INA3221_ENABLE_SUM_CH_MASK |
Enable shunt voltage sum calculation channel bit mask.
| #define INA3221_FLAGS_MASK |
Flags bit mask.
| #define INA3221_TRIGGER_BUS | ( | dev | ) | ina3221_set_mode(dev, INA3221_MODE_TRIGGER_BUS_ONLY) |
| #define INA3221_TRIGGER_SHUNT | ( | dev | ) | ina3221_set_mode(dev, INA3221_MODE_TRIGGER_SHUNT_ONLY) |
| #define INA3221_TRIGGER_SHUNT_AND_BUS | ( | dev | ) | ina3221_set_mode(dev, INA3221_MODE_TRIGGER_SHUNT_BUS) |
| enum ina3221_alert |
| enum ina3221_channel |
ADC bus voltage conversion times.
ADC shunt voltage conversion times.
| enum ina3221_dev_addr |
| enum ina3221_enable_ch |
| enum ina3221_enable_latch |
| enum ina3221_mode |
Device operation modes.
| enum ina3221_num_samples |
| enum ina3221_ret_val |
| int _ina3221_disable_alert | ( | ina3221_t * | dev, |
| ina3221_alert_t | alert | ||
| ) |
Disable alert callback and argument for alert alert.
| [in,out] | dev | Device handle |
| [in] | alert | Alert index |
alert was out of bounds | int _ina3221_enable_alert | ( | ina3221_t * | dev, |
| ina3221_alert_t | alert, | ||
| ina3221_alert_cb_t | cb, | ||
| void * | arg | ||
| ) |
Enable alert callback and argument for alert alert.
| [in,out] | dev | Device handle |
| [in] | alert | Alert index |
| [in] | cb | Alert callback |
| [in] | arg | Alert callback argument |
alert was out of bounds | int _ina3221_get_config | ( | const ina3221_t * | dev, |
| uint16_t * | cfg | ||
| ) |
Read currently saved configuration register value.
| [in] | dev | Device handle |
| [out] | cfg | Pointer to configuration register output value in host byte order |
| int _ina3221_get_enable_channel | ( | const ina3221_t * | dev, |
| ina3221_enable_ch_t * | ech | ||
| ) |
Read which channels are currently enabled.
| [in] | dev | Device handle |
| [out] | ech | Pointer to enabled channels output variable |
| int _ina3221_get_enable_sum_channel | ( | const ina3221_t * | dev, |
| ina3221_enable_sum_ch_t * | esch | ||
| ) |
Read enabled channels for shunt voltage sum calculation.
| [in] | dev | Device handle |
| [out] | esch | Pointer to enabled channels for shunt voltage sum calculation output variable |
| int _ina3221_set_config | ( | ina3221_t * | dev, |
| uint16_t | cfg | ||
| ) |
Write configuration register value to configuration register.
| [in,out] | dev | Device handle |
| [in] | cfg | Configuration register value in host byte order |
| int _ina3221_set_enable_channel | ( | ina3221_t * | dev, |
| ina3221_enable_ch_t | ech | ||
| ) |
Enable channels.
| [in,out] | dev | Device handle |
| [in] | ech | Channel enable flags |
| int _ina3221_set_enable_sum_channel | ( | const ina3221_t * | dev, |
| ina3221_enable_sum_ch_t | esch | ||
| ) |
Enable channels for shunt voltage sum calculation.
| [in] | dev | Device handle |
| [in] | esch | Enable channel shunt voltage sum flags in host byte order |
| int ina3221_calculate_current_ua | ( | const ina3221_t * | dev, |
| ina3221_channel_t | ch, | ||
| int32_t * | in_uv, | ||
| int32_t * | out_ma | ||
| ) |
Calculate current for each channel in ch.
| [in] | dev | Device handle |
| [in] | ch | Channel flags |
| [in] | in_uv | Array of input shunt voltage values |
| [out] | out_ma | Array of output current values |
| int ina3221_calculate_power_uw | ( | int16_t * | in_mv, |
| int32_t * | in_ua, | ||
| uint8_t | num, | ||
| int32_t * | out_mw | ||
| ) |
Calculate power from bus voltage and current values.
| [in] | in_mv | Array of input bus voltage values in mV |
| [in] | in_ua | Array of input current values in uA |
| [in] | num | Number of values in in_mv |
| [out] | out_mw | Array of output power values in uW |
num is greater than INA3221_NUM_CH | void ina3221_ch_align | ( | ina3221_channel_t | ch, |
| const void * | in_res, | ||
| void * | out_res, | ||
| size_t | res_val_size | ||
| ) |
Align in_res to the number of channels For example: ch = (INA3221_CH1 | INA3221_CH3) in_res = {value_ch1, value_ch3}, then out_res will be {value_ch1, 0, value_ch3}.
| [in] | ch | Channel flags |
| [in] | in_res | Output of e.g. |
| [out] | out_res | Channel aligned result |
| [in] | res_val_size | Size of a value in in_res in bytes |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
| [in] | cb | Alert callback |
| [in] | arg | Alert callback argument |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
| [in] | cb | Alert callback |
| [in] | arg | Alert callback argument |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
| [in] | cb | Alert callback |
| [in] | arg | Alert callback argument |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
| [in] | cb | Alert callback |
| [in] | arg | Alert callback argument |
|
inlinestatic |
Wrapper around _ina3221_get_enable_channel.
| [in] | dev | Device handle |
| [out] | ch1 | Pointer to channel 1 state variable |
| [out] | ch2 | Pointer to channel 2 state variable |
| [out] | ch3 | Pointer to channel 3 state variable |
|
inlinestatic |
Wrapper around.
| [in] | dev | Device handle |
| [out] | chs | Pointer to enabled channels variable |
| [out] | ns | Pointer to number of samples variable |
| [out] | ctbadc | Pointer to conversion time bus adc variable |
| [out] | ctsadc | Pointer to conversion time shunt adc variable |
| [out] | mode | Pointer to measurement mode variable |
| int ina3221_get_conv_time_bus_adc | ( | const ina3221_t * | dev, |
| ina3221_conv_time_bus_adc_t * | ctb | ||
| ) |
Read currently applied bus voltage ADC conversion time.
| [in] | dev | Device handle |
| [out] | ctb | Pointer to bus voltage ADC conversion time output variable |
| int ina3221_get_conv_time_shunt_adc | ( | const ina3221_t * | dev, |
| ina3221_conv_time_shunt_adc_t * | cts | ||
| ) |
Read currently applied shunt voltage ADC conversion time.
| [in] | dev | Device handle |
| [out] | cts | Pointer to shunt voltage ADC conversion time output variable |
| int ina3221_get_crit_alert_limit | ( | const ina3221_t * | dev, |
| ina3221_channel_t | ch, | ||
| int32_t * | out_uv | ||
| ) |
Read critical shunt voltage alert limit for each channel in ch.
The function exits on the first channel whose critical alert limit could not be read.
| [in] | dev | Device handle |
| [in] | ch | Channel flags |
| [out] | out_uv | Output array of shunt voltage alert limits in uV |
|
inlinestatic |
Wrapper for.
| [in] | dev | Device handle |
| [out] | ch1 | Pointer to channel 1 state variable for sum voltage drop calculation |
| [out] | ch2 | Pointer to channel 2 state variable for sum voltage drop calculation |
| [out] | ch3 | Pointer to channel 3 state variable for sum voltage drop calculation |
| int ina3221_get_latch | ( | const ina3221_t * | dev, |
| ina3221_enable_latch_t * | latch | ||
| ) |
Read enabled latches for critical/warning alert pins.
| [in] | dev | Device handle |
| [in] | latch | Pointer to latch flags output variable |
| int ina3221_get_mode | ( | const ina3221_t * | dev, |
| ina3221_mode_t * | mode | ||
| ) |
Read currently applied device operation mode.
| [in] | dev | Device handle |
| [out] | mode | Pointer to device operation mode output variable |
| int ina3221_get_num_samples | ( | const ina3221_t * | dev, |
| ina3221_num_samples_t * | ns | ||
| ) |
Read currently applied number of samples.
| [in] | dev | Device handle |
| [out] | ns | Pointer to number of samples output variable |
| int ina3221_get_power_valid_lower_limit | ( | const ina3221_t * | dev, |
| int32_t * | out_mv | ||
| ) |
Read bus voltage power valid lower limit.
| [in] | dev | Device handle |
| [out] | out_mv | Pointer to bus voltage power valid lower limit output variable |
| int ina3221_get_power_valid_upper_limit | ( | const ina3221_t * | dev, |
| int32_t * | out_mv | ||
| ) |
Read bus voltage power valid upper limit.
| [in] | dev | Device handle |
| [out] | out_mv | Pointer to bus voltage power valid upper limit output variable |
| int ina3221_get_shunt_voltage_sum_alert_limit | ( | const ina3221_t * | dev, |
| int32_t * | out_uv | ||
| ) |
Read shunt voltage sum alert limit.
| [in] | dev | Device handle |
| [out] | out_uv | Pointer to sum voltage sum alert limit output variable |
| int ina3221_get_warn_alert_limit | ( | const ina3221_t * | dev, |
| ina3221_channel_t | ch, | ||
| int32_t * | out_uv | ||
| ) |
Read warning shunt voltage alert limit for each channel in ch.
The function exits on the first channel whose warning alert limit could not be read.
| [in] | dev | Device handle |
| [in] | ch | Channel flags |
| [out] | out_uv | Output array of shunt voltage alert limits in uV |
| int ina3221_init | ( | ina3221_t * | dev, |
| const ina3221_params_t * | params | ||
| ) |
Initialize device.
| [out] | dev | Device handle |
| [in] | params | Device parameters |
| int ina3221_read_bus_mv | ( | const ina3221_t * | dev, |
| ina3221_channel_t | ch, | ||
| int16_t * | out_mv, | ||
| uint16_t * | flags | ||
| ) |
Read bus voltages for each channel in ch.
The function exits on the first channel whose bus voltage could not be read
| [in] | dev | Device handle |
| [in] | ch | Channel flags |
| [out] | out_mv | Array of output bus voltage values in mV |
| [out] | flags | Pointer to flags output variable, may be NULL |
| int ina3221_read_flags | ( | const ina3221_t * | dev, |
| uint16_t * | flags | ||
| ) |
Read status flags.
| [in] | dev | Device handle |
| [out] | flags | Pointer to flags output variable |
| int ina3221_read_shunt_sum_uv | ( | const ina3221_t * | dev, |
| int32_t * | out_uv, | ||
| uint16_t * | flags | ||
| ) |
Read sum of shunt voltages.
| [in] | dev | Device handle |
| [out] | out_uv | Pointer to shunt voltage sum output variable |
| [out] | flags | Pointer to flags output variable, may be NULL |
| int ina3221_read_shunt_uv | ( | const ina3221_t * | dev, |
| ina3221_channel_t | ch, | ||
| int32_t * | out_uv, | ||
| uint16_t * | flags | ||
| ) |
Read shunt voltages for each channel in ch.
The function exits on the first channel whose shunt voltage could not be read
| [in] | dev | Device handle |
| [in] | ch | Channel flags |
| [out] | out_uv | Array of output shunt voltage values in uV |
| [out] | flags | Pointer to flags output variable, may be NULL |
| int ina3221_reset | ( | ina3221_t * | dev | ) |
Reset device, i.e.
apply default configuration
| [in,out] | dev | Device handle |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
| [in] | ch1 | Channel 1 state |
| [in] | ch2 | Channel 2 state |
| [in] | ch3 | Channel 3 state |
|
inlinestatic |
Wrapper around.
| [in,out] | dev | Device handle |
| [in] | chs | Channel enable flags |
| [in] | ns | Number of samples |
| [in] | ctbadc | Conversion time for bus voltage ADC |
| [in] | ctsadc | Conversion time for shunt voltage ADC |
| [in] | mode | Device operation mode |
| int ina3221_set_conv_time_bus_adc | ( | ina3221_t * | dev, |
| ina3221_conv_time_bus_adc_t | ctb | ||
| ) |
Update conversion time of bus voltage ADC and write to configuration register.
| [in,out] | dev | Device handle |
| [in] | ctb | Bus voltage conversion time |
| int ina3221_set_conv_time_shunt_adc | ( | ina3221_t * | dev, |
| ina3221_conv_time_shunt_adc_t | cts | ||
| ) |
Update conversion time of shunt voltage ADC and write to configuration register.
| [in,out] | dev | Device handle |
| [in] | cts | Shunt voltage conversion time value |
| int ina3221_set_crit_alert_limit | ( | const ina3221_t * | dev, |
| ina3221_channel_t | ch, | ||
| int32_t | in_uv | ||
| ) |
Set critical shunt voltage alert limit to in_uv for each channel in ch.
The function exits on the first channel that could not be updated.
| [in] | dev | Device handle |
| [in] | ch | Channel flags |
| [in] | in_uv | Critical shunt voltage limit in uv |
in_uv was not in [INA3221_MIN_SHUNT_UV; INA3221_MAX_SHUNT_UV]
|
inlinestatic |
Wrapper around.
| [in] | dev | Device handle |
| [in] | ch1 | Channel 1 state for sum voltage drop calculation |
| [in] | ch2 | Channel 2 state for sum voltage drop calculation |
| [in] | ch3 | Channel 3 state for sum voltage drop calculation |
| int ina3221_set_latch | ( | const ina3221_t * | dev, |
| ina3221_enable_latch_t | latch | ||
| ) |
Enable latches for critical/warning alert pins.
| [in] | dev | Device handle |
| [in] | latch | Enable latch flags |
| int ina3221_set_mode | ( | ina3221_t * | dev, |
| ina3221_mode_t | mode | ||
| ) |
Update device operation mode.
| [in,out] | dev | Device handle |
| [in] | mode | Operation mode value in host byte order |
| int ina3221_set_num_samples | ( | ina3221_t * | dev, |
| ina3221_num_samples_t | ns | ||
| ) |
Update number of samples and write to configuration register.
| [in,out] | dev | Device handle |
| [in] | ns | Number of samples |
| int ina3221_set_power_valid_lower_limit | ( | const ina3221_t * | dev, |
| int32_t | in_mv | ||
| ) |
Set bus voltage power valid lower limit to in_mv.
| [in] | dev | Device handle |
| [in] | in_mv | bus voltage power valid lower limit in mV |
in_mv was not in [INA3221_MIN_BUS_MV; INA3221_MAX_BUS_MV] | int ina3221_set_power_valid_upper_limit | ( | const ina3221_t * | dev, |
| int32_t | in_mv | ||
| ) |
Set bus voltage power valid upper limit to in_mv.
| [in] | dev | Device handle |
| [in] | in_mv | bus voltage power valid upper limit in mv |
in_mv was not in [INA3221_MIN_BUS_MV; INA3221_MAX_BUS_MV] | int ina3221_set_shunt_voltage_sum_alert_limit | ( | const ina3221_t * | dev, |
| int32_t | in_uv | ||
| ) |
Set shunt voltage sum alert limit to in_uv.
| [in] | dev | Device handle |
| [in] | in_uv | shunt voltage sum limit in uv |
in_uv was not in [INA3221_MIN_SHUNT_SUM_UV; INA3221_MAX_SHUNT_SUM_UV] | int ina3221_set_warn_alert_limit | ( | const ina3221_t * | dev, |
| ina3221_channel_t | ch, | ||
| int32_t | in_uv | ||
| ) |
Set warning shunt voltage alert limit to in_uv for each channel in ch.
The function exits on the first channel that could not be updated.
| [in] | dev | Device handle |
| [in] | ch | Channel flags |
| [in] | in_uv | Warning shunt voltage limit in uV in host byte order |
in_uv was not in [INA3221_MIN_SHUNT_UV; INA3221_MAX_SHUNT_UV]