Skip to content

File syn_powermon.c

FileList > sensor > syn_powermon.c

Go to the source code of this file

Generic Power & Current Monitor Driver (INA219, INA226, INA3221).

  • #include "syn_powermon.h"
  • #include "../util/syn_assert.h"
  • #include <string.h>

Public Functions

Type Name
void syn_powermon_feed_raw (SYN_PowerMon * pm, uint16_t raw_bus_v, float raw_shunt_mv)
Feed raw I2C register samples (bus voltage & shunt voltage).
float syn_powermon_get_bus_voltage (const SYN_PowerMon * pm)
Get measured bus voltage in Volts.
float syn_powermon_get_current_ma (const SYN_PowerMon * pm)
Get measured current in Milliamps.
float syn_powermon_get_power_mw (const SYN_PowerMon * pm)
Get calculated power in Milliwatts.
SYN_Status syn_powermon_init (SYN_PowerMon * pm, SYN_GPIO_Pin scl, SYN_GPIO_Pin sda, uint8_t i2c_addr, float shunt_resistor_ohms, SYN_PowerMonType type)
Initialize Power Monitor IC.

Public Functions Documentation

function syn_powermon_feed_raw

Feed raw I2C register samples (bus voltage & shunt voltage).

void syn_powermon_feed_raw (
    SYN_PowerMon * pm,
    uint16_t raw_bus_v,
    float raw_shunt_mv
) 

Parameters:

  • pm Power monitor context.
  • raw_bus_v Raw bus voltage register value.
  • raw_shunt_mv Raw shunt voltage in millivolts.

function syn_powermon_get_bus_voltage

Get measured bus voltage in Volts.

float syn_powermon_get_bus_voltage (
    const SYN_PowerMon * pm
) 

Parameters:

  • pm Power monitor context.

Returns:

Voltage in Volts.


function syn_powermon_get_current_ma

Get measured current in Milliamps.

float syn_powermon_get_current_ma (
    const SYN_PowerMon * pm
) 

Parameters:

  • pm Power monitor context.

Returns:

Current in mA.


function syn_powermon_get_power_mw

Get calculated power in Milliwatts.

float syn_powermon_get_power_mw (
    const SYN_PowerMon * pm
) 

Parameters:

  • pm Power monitor context.

Returns:

Power in mW.


function syn_powermon_init

Initialize Power Monitor IC.

SYN_Status syn_powermon_init (
    SYN_PowerMon * pm,
    SYN_GPIO_Pin scl,
    SYN_GPIO_Pin sda,
    uint8_t i2c_addr,
    float shunt_resistor_ohms,
    SYN_PowerMonType type
) 

Parameters:

  • pm Power monitor context.
  • scl I2C SCL GPIO pin.
  • sda I2C SDA GPIO pin.
  • i2c_addr I2C slave address (e.g. 0x40 or 0x41).
  • shunt_resistor_ohms Shunt resistor value in Ohms (e.g. 0.1f).
  • type IC type (INA219 or INA226).

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/sensor/syn_powermon.c