powermonitor 2.0.0.0
Power Monitor Click Driver

API for configuring and manipulating Power Monitor Click driver. More...

Topics

 Power Monitor Registers List
 List of registers of Power Monitor Click driver.
 
 Power Monitor Registers Settings
 Settings for registers of Power Monitor Click driver.
 
 Power Monitor MikroBUS Map
 MikroBUS pin mapping of Power Monitor Click driver.
 

Functions

void powermonitor_cfg_setup (powermonitor_cfg_t *cfg)
 Power Monitor configuration object setup function.
 
err_t powermonitor_init (powermonitor_t *ctx, powermonitor_cfg_t *cfg)
 Power Monitor initialization function.
 
err_t powermonitor_default_cfg (powermonitor_t *ctx)
 Power Monitor default configuration function.
 
err_t powermonitor_generic_write (powermonitor_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 Power Monitor I2C writing function.
 
err_t powermonitor_generic_read (powermonitor_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 Power Monitor I2C reading function.
 
err_t powermonitor_soft_reset (powermonitor_t *ctx)
 Power Monitor software reset function.
 
err_t powermonitor_set_configuration (powermonitor_t *ctx, powermonitor_dev_cfg_t cfg_data)
 Power Monitor set configuration function.
 
err_t powermonitor_get_configuration (powermonitor_t *ctx, powermonitor_dev_cfg_t *cfg_data)
 Power Monitor get configuration function.
 
err_t powermonitor_set_adc_config (powermonitor_t *ctx, powermonitor_adc_cfg_t adc_cfg)
 Power Monitor set ADC configuration function.
 
err_t powermonitor_get_adc_configu (powermonitor_t *ctx, powermonitor_adc_cfg_t *adc_cfg)
 Power Monitor get ADC configuration function.
 
err_t powermonitor_set_bus_overvoltage_threshold (powermonitor_t *ctx, float bovl)
 Power Monitor set bus overvoltage threshold function.
 
err_t powermonitor_set_bus_undervoltage_threshold (powermonitor_t *ctx, float buvl)
 Power Monitor set bus undervoltage threshold function.
 
err_t powermonitor_set_shunt_overvoltage_threshold (powermonitor_t *ctx, float sovl)
 Power Monitor set shunt overvoltage threshold function.
 
err_t powermonitor_set_shunt_undervoltage_threshold (powermonitor_t *ctx, float suvl)
 Power Monitor set shunt undervoltage threshold function.
 
err_t powermonitor_get_vshunt (powermonitor_t *ctx, float *vshunt)
 Power Monitor get shunt voltage function.
 
err_t powermonitor_get_vbus (powermonitor_t *ctx, float *vbus)
 Power Monitor get bus voltage function.
 
err_t powermonitor_get_temperature (powermonitor_t *ctx, float *temperature)
 Power Monitor get temperature function.
 
err_t powermonitor_get_current (powermonitor_t *ctx, float *current)
 Power Monitor get current function.
 
err_t powermonitor_get_power (powermonitor_t *ctx, float *power)
 Power Monitor get power function.
 
err_t powermonitor_get_energy_data (powermonitor_t *ctx, uint8_t *energy_data)
 Power Monitor get energy data function.
 
err_t powermonitor_get_energy (powermonitor_t *ctx, float *energy)
 Power Monitor get energy function.
 
err_t powermonitor_get_id (powermonitor_t *ctx, uint8_t *manufacturer_id, uint16_t *die_id, uint8_t *rev_id)
 Power Monitor get device ID function.
 
err_t powermonitor_get_alert (powermonitor_t *ctx)
 Power Monitor get alert function.
 

Detailed Description

API for configuring and manipulating Power Monitor Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ powermonitor_cfg_setup()

void powermonitor_cfg_setup ( powermonitor_cfg_t * cfg)

Power Monitor configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See powermonitor_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ powermonitor_default_cfg()

err_t powermonitor_default_cfg ( powermonitor_t * ctx)

Power Monitor default configuration function.

This function executes a default configuration of Power Monitor click board.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ powermonitor_generic_read()

err_t powermonitor_generic_read ( powermonitor_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

Power Monitor I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_generic_write()

err_t powermonitor_generic_write ( powermonitor_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

Power Monitor I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_adc_configu()

err_t powermonitor_get_adc_configu ( powermonitor_t * ctx,
powermonitor_adc_cfg_t * adc_cfg )

Power Monitor get ADC configuration function.

This function get ADC configuration of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]adc_cfg: ADC configuration object.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_alert()

err_t powermonitor_get_alert ( powermonitor_t * ctx)

Power Monitor get alert function.

This function get alert state of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
Returns
  • 0 - Alert state active,
  • 1 - Alert state inactive.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_configuration()

err_t powermonitor_get_configuration ( powermonitor_t * ctx,
powermonitor_dev_cfg_t * cfg_data )

Power Monitor get configuration function.

This function get configuration of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]cfg_data: Settings object.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_current()

err_t powermonitor_get_current ( powermonitor_t * ctx,
float * current )

Power Monitor get current function.

This function get and calculate current output of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]current: Current output ( mA ).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_energy()

err_t powermonitor_get_energy ( powermonitor_t * ctx,
float * energy )

Power Monitor get energy function.

This function get and calculate energy output of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]energy: Energy output ( J ).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_energy_data()

err_t powermonitor_get_energy_data ( powermonitor_t * ctx,
uint8_t * energy_data )

Power Monitor get energy data function.

This function read energy data of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]energy_data: Pointer to the memory location where the data is stored.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_id()

err_t powermonitor_get_id ( powermonitor_t * ctx,
uint8_t * manufacturer_id,
uint16_t * die_id,
uint8_t * rev_id )

Power Monitor get device ID function.

This function get device ID of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]manufacturer_id: Reads back TI in ASCII.
[out]die_id: Stores the device identification bits.
[out]rev_id: Device revision identification.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_power()

err_t powermonitor_get_power ( powermonitor_t * ctx,
float * power )

Power Monitor get power function.

This function get and calculate power output of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]power: Power output ( W ).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_temperature()

err_t powermonitor_get_temperature ( powermonitor_t * ctx,
float * temperature )

Power Monitor get temperature function.

This function get temperature measurement of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]temperature: Temperature ( degree Celsius ).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_vbus()

err_t powermonitor_get_vbus ( powermonitor_t * ctx,
float * vbus )

Power Monitor get bus voltage function.

This function get bus voltage measurement of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]vbus: Bus voltage output ( mV ).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_get_vshunt()

err_t powermonitor_get_vshunt ( powermonitor_t * ctx,
float * vshunt )

Power Monitor get shunt voltage function.

This function get shunt voltage measurement of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[out]vshunt: Differential voltage measured ( mV ).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_init()

err_t powermonitor_init ( powermonitor_t * ctx,
powermonitor_cfg_t * cfg )

Power Monitor initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See powermonitor_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_set_adc_config()

err_t powermonitor_set_adc_config ( powermonitor_t * ctx,
powermonitor_adc_cfg_t adc_cfg )

Power Monitor set ADC configuration function.

This function performs ADC configuration of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]adc_cfg: ADC configuration object.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_set_bus_overvoltage_threshold()

err_t powermonitor_set_bus_overvoltage_threshold ( powermonitor_t * ctx,
float bovl )

Power Monitor set bus overvoltage threshold function.

This function sets the bus overvoltage threshold for comparison of the value to detect Bus Overvoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]bovl: Overvoltage threshold for comparison ( 0 mV - 102400 mV) .
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_set_bus_undervoltage_threshold()

err_t powermonitor_set_bus_undervoltage_threshold ( powermonitor_t * ctx,
float buvl )

Power Monitor set bus undervoltage threshold function.

This function sets the bus undervoltage threshold for comparison of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]buvl: Undervoltage threshold for comparison ( 0 mV - 102400 mV) .
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_set_configuration()

err_t powermonitor_set_configuration ( powermonitor_t * ctx,
powermonitor_dev_cfg_t cfg_data )

Power Monitor set configuration function.

This function performs configuration of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]cfg_data: Settings object.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_set_shunt_overvoltage_threshold()

err_t powermonitor_set_shunt_overvoltage_threshold ( powermonitor_t * ctx,
float sovl )

Power Monitor set shunt overvoltage threshold function.

This function sets the shunt overvoltage threshold for comparison of the value to detect Bus Overvoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]sovl: Overvoltage threshold for comparison ( ADCRANGE = 0 : 0 mV - 327.680 mV; ADCRANGE = 1 : 0 mV - 81.920 mV ) .
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_set_shunt_undervoltage_threshold()

err_t powermonitor_set_shunt_undervoltage_threshold ( powermonitor_t * ctx,
float suvl )

Power Monitor set shunt undervoltage threshold function.

This function sets the shunt undervoltage threshold for comparison of the value to detect Bus Undervoltage of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
[in]suvl: Undervoltage threshold for comparison ( ADCRANGE = 0 : 0 mV - 327.680 mV; ADCRANGE = 1 : 0 mV - 81.920 mV ) .
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ powermonitor_soft_reset()

err_t powermonitor_soft_reset ( powermonitor_t * ctx)

Power Monitor software reset function.

This function executes a software reset of the INA228 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor on the Power Monitor click board™.

Parameters
[in]ctx: Click context object. See powermonitor_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.