MAVRK Embedded Software 0.91
Software Libraries for the MAVRK motherboard and related components
Functions | Variables

INA226_Current_Power_Monitor.c File Reference

Performs. More...

#include "MAVRK_Arch.h"
#include "stdef.h"
#include "MAVRK_Common.h"
#include "F5438_PMUBAT_Modular_EVM_IO.h"
#include "MAVRK_Return_Error_Codes.h"
#include "I2C_Functions.h"
#include "UART_State_Machine.h"
#include "INA226_Current_Power_Monitor.h"

Functions

unsigned char mvk_Reset_INA226 (void)
 Resets the INA226 component.
unsigned char mvk_Set_INA226_ADC_Averaging_Number_Of_Samples (unsigned int number_of_samples)
 Sets the number of ADC samples taken before averaging result.
unsigned char mvk_Get_INA226_ADC_Averaging_Number_Of_Samples (unsigned int *number_of_samples)
 Gets the number of ADC samples taken before averaging result.
unsigned char mvk_Set_INA226_Bus_Voltage_Conversion_Time (unsigned int conversion_time)
 Sets the conversion time for the Bus Voltage.
unsigned char mvk_Get_INA226_Bus_Voltage_Conversion_Time (unsigned int *conversion_time)
 Gets the conversion time for the Bus Voltage.
unsigned char mvk_Set_INA226_Shunt_Voltage_Conversion_Time (unsigned int conversion_time)
 Sets the conversion time for the Shunt Voltage.
unsigned char mvk_Get_INA226_Shunt_Voltage_Conversion_Time (unsigned int *conversion_time)
 Gets the conversion time for the Shunt Voltage.
unsigned char mvk_Set_INA226_Operating_Mode (unsigned int operating_mode)
 Sets the INA226 operating mode.
unsigned char mvk_Get_INA226_Operating_Mode (unsigned int *operating_mode)
 Gets the INA226 operating mode.
unsigned char mvk_Get_INA226_Shunt_Voltage (signed int *shunt_voltage_microvolts)
 Gets the INA226 Shunt voltage.
unsigned char mvk_Get_INA226_Bus_Voltage (unsigned int *bus_voltage_millivolts)
 Reads the INA226 Bus voltage.
unsigned char mvk_Get_INA226_Power (unsigned int *power_milliwatts)
 Gets the INA226 Power.
unsigned char mvk_Get_INA226_Current (signed int *shunt_current)
 Gets the INA226 current .
unsigned char mvk_Set_INA226_Calibration (unsigned int calibration)
 Sets the INA226 calibration.
unsigned char mvk_Get_INA226_Calibration (unsigned int *calibration)
 Gets the INA226 calibration.
unsigned char mvk_Set_INA226_Alert_Function_State (unsigned char alert_function, unsigned char alert_state)
 Sets the alert state of the selected alert function.
unsigned char mvk_Get_INA226_Alert_Function_State (unsigned char alert_function, unsigned char *alert_state)
 Gets the alert state of the selected alert function.
unsigned char mvk_Set_INA226_Alert_Limit_Value (signed int alert_limit_value)
 Sets the The alert limit value used to compare to the INA226 register associated with selected and enabled Alert Function.
unsigned char mvk_Get_INA226_Alert_Limit_Value (signed int *alert_limit_value)
 Gets the alert limit value used to compare to the INA226 register associated with selected and enabled Alert Function.
unsigned char mvk_Set_INA226_Alert_Latch_Enable (unsigned char alert_latch_enable)
 Sets the INA226 Alert output pin and flag behavior, either remaining latched until read, or transparently cleared by hardware.
unsigned char mvk_Get_INA226_Alert_Latch_Enable (unsigned char *alert_latch_enable)
 Gets the INA226 Alert output pin and flag behavior, either remaining latched until read, or transparently cleared by hardware.
unsigned char mvk_Set_INA226_Alert_Output_Pin_Polarity (unsigned char alert_output_pin_polarity)
 Sets the INA226 Alert output pin polarity when.
unsigned char mvk_Get_INA226_Alert_Output_Pin_Polarity (unsigned char *alert_output_pin_polarity)
 Gets the INA226 Alert output pin polarity when.
unsigned char mvk_Get_INA226_Math_Overflow_Flag (unsigned char *math_overflow_flag)
 Gets the INA226 Math Overflow Flag.
unsigned char mvk_Get_INA226_Conversion_Ready_Flag (unsigned char *conversion_ready_flag)
 Gets the INA226 Math Overflow Flag.
unsigned char mvk_Get_INA226_Alert_Function_Flag (unsigned char *alert_function_flag)
 Gets the INA226 Alert Function Flag.

Variables

volatile unsigned int INA226_Configuration
volatile
INA226_Configuration_register_type
INA226_Configuration_register = (INA226_Configuration_register_type*) &INA226_Configuration
volatile unsigned int INA226_Alert_Configuration
volatile
INA226_Alert_Configuration_register_type
INA226_Alert_Configuration_register = (INA226_Alert_Configuration_register_type*) &INA226_Alert_Configuration

Detailed Description

Performs.

Author:
Ron Crea
Date:
December 2011

Initializes and Sends Command Interface packets to the Batterm

Note:
Prototypes for functions in this file are located in the INA226_Current_Power_Monitor.h header file located in the mavrk_embedded\Modular_EVM_Libraries\Components\INA226_Template directory
See also:
For Support: https://e2e.ti.com/support/development_tools/mavrk/default.aspx

Function Documentation

unsigned char mvk_Get_INA226_ADC_Averaging_Number_Of_Samples ( unsigned int *  number_of_samples)

Gets the number of ADC samples taken before averaging result.

The number of ADC samples taken applies to averaging BUS and Shunt Voltage

Parameters:
[out]number_of_samples- INA226_1_SAMPLE_AVERAGED, INA226_4_SAMPLES_AVERAGED, INA226_16_SAMPLES_AVERAGED, INA226_64_SAMPLES_AVERAGED, INA226_128_SAMPLES_AVERAGED, INA226_256_SAMPLES_AVERAGED, INA226_512_SAMPLES_AVERAGED, INA226_1024_SAMPLES_AVERAGED
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Alert_Function_Flag ( unsigned char *  alert_function_flag)

Gets the INA226 Alert Function Flag.

While only one Alert Function can be monitored at the Alert pin at a time, the Conversion Ready can also be enabled to assert the Alert pin. Reading the Alert Function Flag following an alert allows the user to determine if the Alert Function was the source of the Alert. When the Alert Latch Enable bit is set to Latch mode, the Alert Function Flag clears only when the Mask/Enable Register is read. When the Alert Latch Enable bit is set to Transparent mode, the Alert Function Flag is cleared following the next conversion that does not result in an Alert condition.

Parameters:
[out]alert_function_flag- CLEAR, SET
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Alert_Function_State ( unsigned char  alert_function,
unsigned char *  alert_state 
)

Gets the alert state of the selected alert function.

Parameters:
[in]alert_function- INA226_SHUNT_VOLTAGE_OVER_VOLTAGE, INA226_SHUNT_VOLTAGE_UNDER_VOLTAGE, INA226_BUS_VOLTAGE_OVER_VOLTAGE, INA226_BUS_VOLTAGE_UNDER_VOLTAGE, INA226_POWER_OVER_LIMIT, INA226_CONVERSION_READY,
[out]alert_state- INA226_ALERT_ENABLED, INA226_ALERT_DISABLED
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Alert_Latch_Enable ( unsigned char *  alert_latch_enable)

Gets the INA226 Alert output pin and flag behavior, either remaining latched until read, or transparently cleared by hardware.

When the Alert Latch Enable bit is set to Transparent mode, the Alert pin and Flag bits will reset to their idle states when the fault has been cleared. When the Alert Latch Enable bit is set to Latch mode, the Alert pin and Flag bits will remain active following a fault until the Mask/Enable Register has been read.

Parameters:
[out]alert_latch_enable- INA226_ALERT_LATCH_TRANSPARENT(Default), INA226_ALERT_LATCH_ENABLED
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Alert_Limit_Value ( signed int *  alert_limit_value)

Gets the alert limit value used to compare to the INA226 register associated with selected and enabled Alert Function.

Parameters:
[out]alert_limit_value- Pointer to Alert Function
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Alert_Output_Pin_Polarity ( unsigned char *  alert_output_pin_polarity)

Gets the INA226 Alert output pin polarity when.

Parameters:
[out]alert_output_pin_polarity- INA226_ALERT_ACTIVE_LOW, INA226_ALERT_ACTIVE_HIGH
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Bus_Voltage ( unsigned int *  bus_voltage_millivolts)

Reads the INA226 Bus voltage.

This command reads and returns the INA226 Bus Voltage

Parameters:
[out]bus_voltage_millivolts- Bus voltage in units of mV
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Bus_Voltage_Conversion_Time ( unsigned int *  conversion_time)

Gets the conversion time for the Bus Voltage.

This command gets the conversion time for the bus voltage measurement.

Parameters:
[out]conversion_time- INA226_BUS_VOL_CONVERT_TIME_140US, INA226_BUS_VOL_CONVERT_TIME_204US, INA226_BUS_VOL_CONVERT_TIME_332US, INA226_BUS_VOL_CONVERT_TIME_588US, INA226_BUS_VOL_CONVERT_TIME_1_1MS, INA226_BUS_VOL_CONVERT_TIME_2_116MS, INA226_BUS_VOL_CONVERT_TIME_4_156MS, INA226_BUS_VOL_CONVERT_TIME_8_244MS
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Calibration ( unsigned int *  calibration)

Gets the INA226 calibration.

This command sets the INA226 calibration

Parameters:
[out]calibrationSee INA226 for explanation of value
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Conversion_Ready_Flag ( unsigned char *  conversion_ready_flag)

Gets the INA226 Math Overflow Flag.

Although the INA226 can be read at any time, and the data from the last conversion is available, the Conversion Ready bit is provided to help coordinate one-shot or triggered conversions. The Conversion Ready Flag is set after all conversions, averaging, and multiplications are complete. The Conversion Ready Flag clears by reading the Alert Configuration Register or by writing to the INA226 Configuration Register (except for Power-Down or Disable selections)

Parameters:
[out]conversion_ready_flag- CLEAR, SET
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Current ( signed int *  shunt_current)

Gets the INA226 current .

This command reads and returns the INA226 calculated r. The INA226 internally calculates Current using the formula (Shunt Voltage x Calibration Register)/4096

Parameters:
[out]shunt_current- shunt current in mA units
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Math_Overflow_Flag ( unsigned char *  math_overflow_flag)

Gets the INA226 Math Overflow Flag.

The Math Overflow Flag is SET('1') if an arithmetic operation within the INA226 resulted in an overflow error. It indicates that current and power data may be invalid.

Parameters:
[out]math_overflow_flag- CLEAR, SET
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Operating_Mode ( unsigned int *  operating_mode)

Gets the INA226 operating mode.

This command gets and returns the INA226 operating mode

Parameters:
[out]operating_mode- INA226_POWER_DOWN INA226_SHUNT_VOLTAGE_TRIGGERED INA226_BUS_VOLTAGE_TRIGGERED INA226_SHUNT_AND_BUS_TRIGGERED INA226_ADC_DISABLED INA226_SHUNT_VOLTAGE_CONTINUOUS INA226_BUS_VOLTAGE_CONTINUOUS INA226_SHUNT_AND_BUS_CONTINUOUS(default)
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Power ( unsigned int *  power_milliwatts)

Gets the INA226 Power.

This command reads and returns the INA226 calculated Power. The INA226 internally calculates Power using the formula (Current x Bus Voltage)/5000

Parameters:
[out]power_milliwatts- power in mW units
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Shunt_Voltage ( signed int *  shunt_voltage_microvolts)

Gets the INA226 Shunt voltage.

This command reads and returns the INA226 Shunt Voltage

Parameters:
[out]shunt_voltage_microvolts- shunt voltage in uV units
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Get_INA226_Shunt_Voltage_Conversion_Time ( unsigned int *  conversion_time)

Gets the conversion time for the Shunt Voltage.

This command gets the conversion time for the shunt voltage measurement.

Parameters:
[out]conversion_time- INA226_SHUNT_VOL_CONVERT_TIME_140US, INA226_SHUNT_VOL_CONVERT_TIME_204US, INA226_SHUNT_VOL_CONVERT_TIME_332US, INA226_SHUNT_VOL_CONVERT_TIME_588US, INA226_SHUNT_VOL_CONVERT_TIME_1_1MS, INA226_SHUNT_VOL_CONVERT_TIME_2_116MS, INA226_SHUNT_VOL_CONVERT_TIME_4_156MS, INA226_SHUNT_VOL_CONVERT_TIME_8_244MS
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Reset_INA226 ( void  )

Resets the INA226 component.

This command performs the same as Power On Reset(POR)

Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_ADC_Averaging_Number_Of_Samples ( unsigned int  number_of_samples)

Sets the number of ADC samples taken before averaging result.

The number of ADC samples taken applies to averaging BUS and Shunt Voltage

Parameters:
[in]number_of_samples- INA226_1_SAMPLE_AVERAGED, INA226_4_SAMPLES_AVERAGED, INA226_16_SAMPLES_AVERAGED, INA226_64_SAMPLES_AVERAGED, INA226_128_SAMPLES_AVERAGED, INA226_256_SAMPLES_AVERAGED, INA226_512_SAMPLES_AVERAGED, INA226_1024_SAMPLES_AVERAGED
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Alert_Function_State ( unsigned char  alert_function,
unsigned char  alert_state 
)

Sets the alert state of the selected alert function.

The INA226 has a single Alert Limit register, 07h, that allows the Alert pin to be programmed to respond to a single user-defined event or to a conversion ready notification if desired. The Mask/Enable Register allows the user to select from one of the five available functions to monitor and/or set the conversion ready bit to control the response of the Alert pin. Based on the function being monitored, the user would then enter a value into the Alert Limit Register to set the corresponding threshold value that asserts the Alert pin. The Alert pin allows for one of several available alert functions to be monitored to determine if a user-defined threshold has been exceeded. The five alert functions that can be monitored are: • Shunt Voltage Over Limit (SOL) • Shunt Voltage Under Limit (SUL) • Bus Voltage Over Limit (BOL) • Bus Voltage Under Limit (BUL) • Power Over Limit (POL)

The Conversion Ready state of the device can also be monitored at the Alert pin to inform the user when the device has completed the previous conversion and is ready to begin a new conversion. Conversion Ready can be monitored at the Alert pin along with one of the alert functions. If an alert function and the Conversion Ready are both enabled to be monitored at the Alert pin, after the Alert pin is asserted, the Alert Configuration register must be read following the alert to determine the source of the alert. By reading the Conversion Ready Flag, and the Alert Function Flag, the source of the alert can be determined. If the conversion ready feature is not desired, and the Conversion Ready Alert is not SET, the Alert pin only responds to an exceeded alert limit based on the alert function enabled.

Parameters:
[in]alert_function- INA226_SHUNT_VOLTAGE_OVER_VOLTAGE, INA226_SHUNT_VOLTAGE_UNDER_VOLTAGE, INA226_BUS_VOLTAGE_OVER_VOLTAGE, INA226_BUS_VOLTAGE_UNDER_VOLTAGE, INA226_POWER_OVER_LIMIT, INA226_CONVERSION_READY,
[in]alert_state- INA226_ALERT_ENABLED, INA226_ALERT_DISABLED
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Alert_Latch_Enable ( unsigned char  alert_latch_enable)

Sets the INA226 Alert output pin and flag behavior, either remaining latched until read, or transparently cleared by hardware.

When the Alert Latch Enable bit is set to Transparent mode, the Alert pin and Flag bits will reset to their idle states when the fault has been cleared. When the Alert Latch Enable bit is set to Latch mode, the Alert pin and Flag bits will remain active following a fault until the Mask/Enable Register has been read.

Parameters:
[in]alert_latch_enable- INA226_ALERT_LATCH_TRANSPARENT(Default), INA226_ALERT_LATCH_ENABLED
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Alert_Limit_Value ( signed int  alert_limit_value)

Sets the The alert limit value used to compare to the INA226 register associated with selected and enabled Alert Function.

Parameters:
[in]alert_limit_value- Value of alert limit (Value type and units depend on selected and enabled Alert Function)
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Alert_Output_Pin_Polarity ( unsigned char  alert_output_pin_polarity)

Sets the INA226 Alert output pin polarity when.

Parameters:
[in]alert_output_pin_polarity- INA226_ALERT_ACTIVE_LOW, INA226_ALERT_ACTIVE_HIGH
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Bus_Voltage_Conversion_Time ( unsigned int  conversion_time)

Sets the conversion time for the Bus Voltage.

This command sets the conversion time for the bus voltage measurement.

Parameters:
[in]conversion_time- INA226_BUS_VOL_CONVERT_TIME_140US, INA226_BUS_VOL_CONVERT_TIME_204US, INA226_BUS_VOL_CONVERT_TIME_332US, INA226_BUS_VOL_CONVERT_TIME_588US, INA226_BUS_VOL_CONVERT_TIME_1_1MS, INA226_BUS_VOL_CONVERT_TIME_2_116MS, INA226_BUS_VOL_CONVERT_TIME_4_156MS, INA226_BUS_VOL_CONVERT_TIME_8_244MS
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Calibration ( unsigned int  calibration)

Sets the INA226 calibration.

This command sets the INA226 calibration value. The is value is calulated by using two equations 1.) Current_LSB = Maximum Expected Current / 2^15 (two to the fifthteenth) 2.) CAL_Value = 0.00512/(Current_LSB * Rshunt)

Parameters:
[in]calibrationSee INA226 data sheet for explanation of value
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Operating_Mode ( unsigned int  operating_mode)

Sets the INA226 operating mode.

This command sets the INA226 operating mode

Parameters:
[in]operating_mode- INA226_POWER_DOWN, INA226_SHUNT_VOLTAGE_TRIGGERED INA226_BUS_VOLTAGE_TRIGGERED INA226_SHUNT_AND_BUS_TRIGGERED INA226_ADC_DISABLED INA226_SHUNT_VOLTAGE_CONTINUOUS INA226_BUS_VOLTAGE_CONTINUOUS INA226_SHUNT_AND_BUS_CONTINUOUS(default)
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)
unsigned char mvk_Set_INA226_Shunt_Voltage_Conversion_Time ( unsigned int  conversion_time)

Sets the conversion time for the Shunt Voltage.

This command sets the conversion time for the shunt voltage measurement.

Parameters:
[in]conversion_time- INA226_SHUNT_VOL_CONVERT_TIME_140US, INA226_SHUNT_VOL_CONVERT_TIME_204US, INA226_SHUNT_VOL_CONVERT_TIME_332US, INA226_SHUNT_VOL_CONVERT_TIME_588US, INA226_SHUNT_VOL_CONVERT_TIME_1_1MS, INA226_SHUNT_VOL_CONVERT_TIME_2_116MS, INA226_SHUNT_VOL_CONVERT_TIME_4_156MS, INA226_SHUNT_VOL_CONVERT_TIME_8_244MS
Returns:
I2C_OPERATION_SUCCESSFUL - Message successfully completed
I2C_OPERATION_FAILED - Message unsuccessful
I2C_DEVICE_NOT_CONFIGURED - I2C devices settings not configured for specified device slot
REQUESTED_BUS_IN_USE - I2C_Bus is already in use (May happen if I2C_..() functions are called from within interrupts)

Variable Documentation

volatile unsigned int INA226_Alert_Configuration
volatile unsigned int INA226_Configuration
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines