47#define MAXIMUM_EXPECTED_CURRENT 5.0
48#define CURRENT_LSB_MINIMUM (MAXIMUM_EXPECTED_CURRENT / 2048.0)
49#define CURRENT_LSB (CURRENT_LSB_MINIMUM * 1.0)
50#define BUS_VOLTAGE_LSB 0.025
51#define SHUNT_VOLTAGE_81_92mv_LSB 0.04
52#define SHUNT_VOLTAGE_20_48mv_LSB 0.01
53#define POWER_LSB (CURRENT_LSB*0.032)
55#define CONFIGURATION_REGISTER 0x00
56#define SHUNT_VOLTAGE_REGISTER 0x01
57#define BUS_VOLTAGE_REGISTER 0x02
58#define POWER_REGISTER 0x03
59#define CURRENT_REGISTER 0x04
60#define CALIBRATION_REGISTER 0x05
61#define MASK_ENABLE_REGISTER 0x06
62#define ALERT_LIMIT_REGISTER 0x07
63#define MANUFACTURERID_REGISTER 0x3E
64#define DEVICEID_REGISTER 0x3F
135 uint16_t
LEN:1,
APOL:1,
OVF:1,
CVRF:1,
AFF:1,
MemError:1,
RESERVED:4,
CNVR:1,
POL:1,
BUL:1,
BOL:1,
SUL:1,
SOL:1;
struct ina234 INA234
Class (struct) that stores variables for interacting with INA234.
ErrorType INA234_getErrors(INA234 *self)
Get the error flags of INA234. NOTE: This function will reset the alert pin if it was in the latch mo...
Definition ina234.c:628
float INA234_getPower(INA234 *self)
Read the power from INA234.
Definition ina234.c:587
Status INA234_init(INA234 *self, uint8_t I2C_ADDR, I2C_HandleTypeDef *hi2c, float ShuntResistor, ADCRange adc_range, NumSamples numer_of_adc_samples, ConvTime vbus_conversion_time, ConvTime vshunt_conversion_time, Mode mode)
Initialize the INA234 with the given config.
Definition ina234.c:101
float INA234_getShuntVoltage(INA234 *self)
Read the shunt voltage from INA234.
Definition ina234.c:575
Mode
Definition ina234.h:69
@ MODE_SHUTDOWN
Definition ina234.h:69
@ MODE_SHUTDOWN2
Definition ina234.h:69
@ MODE_CONTINUOUS_BUS
Definition ina234.h:69
@ MODE_CONTINUOUS_BOTH_SHUNT_BUS
Definition ina234.h:69
@ MODE_SINGLESHOT_BUS
Definition ina234.h:69
@ MODE_SINGLESHOT_SUNT
Definition ina234.h:69
@ MODE_SINGLESHOT_BOTH_SHUNT_BUS
Definition ina234.h:69
@ MODE_CONTINUOUS_SHUNT
Definition ina234.h:69
Mode INA234_getMode(INA234 *self)
Set the operating mode.
Definition ina234.c:495
AlertSource INA234_getAlertSource(INA234 *self)
Get the alert source. This function is usefull when you enabled both of the alert functions and data ...
Definition ina234.c:613
Status INA234_resetAlert(INA234 *self)
Reset the alert pin. This function is useful when set the alert pin to latch mode.
Definition ina234.c:648
Status
Definition ina234.h:70
@ STATUS_OK
Definition ina234.h:70
@ STATUS_TimeOut
Definition ina234.h:70
ConvTime INA234_getVShuntConversionTime(INA234 *self)
Get the VShunt convertion period.
Definition ina234.c:478
AlertOn
Definition ina234.h:71
@ ALERT_BUS_OVER_LIMIT
Definition ina234.h:71
@ ALERT_POWER_OVER_LIMIT
Definition ina234.h:71
@ ALERT_SHUNT_UNDER_LIMIT
Definition ina234.h:71
@ ALERT_BUS_UNDER_LIMIT
Definition ina234.h:71
@ ALERT_NONE
Definition ina234.h:71
@ ALERT_SHUNT_OVER_LIMIT
Definition ina234.h:71
float INA234_getCurrent(INA234 *self)
Read the current from INA234.
Definition ina234.c:551
Status INA234_setNumberOfADCSamples(INA234 *self, NumSamples numer_of_adc_samples)
Set the number of ADC samples to calculate the average.
Definition ina234.c:315
uint16_t INA234_getDevID(INA234 *self)
Get the device ID.
Definition ina234.c:527
Status INA234_setVBusConversionTime(INA234 *self, ConvTime vbus_conversion_time)
Set the VBus convertion period.
Definition ina234.c:345
AlertLatch
Definition ina234.h:73
@ ALERT_TRANSPARENT
Definition ina234.h:73
@ ALERT_LATCHED
Definition ina234.h:73
uint8_t INA234_isDataReady(INA234 *self)
Check if the conversion is done or not. NOTE: This function will reset the alert pin if it was in the...
Definition ina234.c:600
float INA234_getBusVoltage(INA234 *self)
Read the bus voltage from INA234.
Definition ina234.c:563
Status __INA234_readTwoBytes(INA234 *self, uint8_t MemAddress)
Read two bytes (a 16bit register) from INA234 and stores in the ina234::_reg::raw_data.
Definition ina234.c:236
ConvTime INA234_getVBusConversionTime(INA234 *self)
Get the VBus convertion period.
Definition ina234.c:460
ErrorType
Definition ina234.h:76
@ ERROR_OVF
Definition ina234.h:76
@ ERROR_BOTH_MEMORY_OVF
Definition ina234.h:76
@ ERROR_NONE
Definition ina234.h:76
@ ERROR_MEMORY
Definition ina234.h:76
ADCRange INA234_getADCRange(INA234 *self)
Get the ADC full scale range of INA234.
Definition ina234.c:424
Status INA234_setADCRange(INA234 *self, ADCRange adc_range)
Set the ADC full scale range of INA234.
Definition ina234.c:285
AlertSource
Definition ina234.h:75
@ ALERT_DATA_READY
Definition ina234.h:75
@ ALERT_LIMIT_REACHED
Definition ina234.h:75
Status __INA234_writeTwoBytes(INA234 *self, uint8_t MemAddress)
Write two bytes (a 16bit register) to INA234 from the ina234::_reg::raw_data.
Definition ina234.c:260
void INA234_readAll(INA234 *self)
Read all of the measured values: Shunt voltage, bus voltage, power, and current. Then store the value...
Definition ina234.c:538
Status INA234_setMode(INA234 *self, Mode mode)
Set the operating mode.
Definition ina234.c:404
ConvTime
Definition ina234.h:68
@ CTIME_8244us
Definition ina234.h:68
@ CTIME_588us
Definition ina234.h:68
@ CTIME_2116us
Definition ina234.h:68
@ CTIME_4156us
Definition ina234.h:68
@ CTIME_1100us
Definition ina234.h:68
@ CTIME_332us
Definition ina234.h:68
@ CTIME_204us
Definition ina234.h:68
@ CTIME_140us
Definition ina234.h:68
NumSamples INA234_getNumberOfADCSamples(INA234 *self)
Get the number of ADC samples to calculate the average.
Definition ina234.c:442
Status INA234_setVShuntConversionTime(INA234 *self, ConvTime vshunt_conversion_time)
Set the VShunt convertion period.
Definition ina234.c:375
AlertPolarity
Definition ina234.h:72
@ ALERT_ACTIVE_LOW
Definition ina234.h:72
@ ALERT_ACTIVE_HIGH
Definition ina234.h:72
uint16_t INA234_getManID(INA234 *self)
Get the manufacturer ID.
Definition ina234.c:516
ADCRange
Definition ina234.h:66
@ RANGE_20_48mV
Definition ina234.h:66
@ RANGE_81_92mV
Definition ina234.h:66
NumSamples
Definition ina234.h:67
@ NADC_1024
Definition ina234.h:67
@ NADC_16
Definition ina234.h:67
@ NADC_256
Definition ina234.h:67
@ NADC_1
Definition ina234.h:67
@ NADC_128
Definition ina234.h:67
@ NADC_64
Definition ina234.h:67
@ NADC_4
Definition ina234.h:67
@ NADC_512
Definition ina234.h:67
void INA234_SoftResetAll(INA234 *self)
Send a reset command to all of the INA234s on the bus.
Definition ina234.c:504
AlertConvReady
Definition ina234.h:74
@ ALERT_CONV_DISABLE
Definition ina234.h:74
@ ALERT_CONV_ENABLE
Definition ina234.h:74
Status INA234_alert_init(INA234 *self, AlertOn alert_on, AlertPolarity alert_polarity, AlertLatch alert_latch, AlertConvReady alert_conv_ready, float alert_limit)
Initialize the alert functionality of INA234 with the given configurations.
Definition ina234.c:176
int16_t LIMIT
Definition ina234.h:139
uint16_t RESERVED2
Definition ina234.h:119
uint16_t RESERVED
Definition ina234.h:119
uint16_t VBUS
Definition ina234.h:119
uint16_t SHUNT_CAL
Definition ina234.h:131
uint16_t RESERVED
Definition ina234.h:131
uint16_t VBUSCT
Definition ina234.h:111
uint16_t ACDRANGE
Definition ina234.h:111
uint16_t RESERVED
Definition ina234.h:111
uint16_t VSHCT
Definition ina234.h:111
uint16_t MODE
Definition ina234.h:111
uint16_t RST
Definition ina234.h:111
uint16_t AVG
Definition ina234.h:111
int16_t CURRENT
Definition ina234.h:127
int16_t RESERVED
Definition ina234.h:127
uint16_t DIEID
Definition ina234.h:147
uint16_t RESERVED
Definition ina234.h:147
uint16_t MANUFACTURE_ID
Definition ina234.h:143
uint16_t LEN
Definition ina234.h:135
uint16_t BOL
Definition ina234.h:135
uint16_t APOL
Definition ina234.h:135
uint16_t SOL
Definition ina234.h:135
uint16_t AFF
Definition ina234.h:135
uint16_t MemError
Definition ina234.h:135
uint16_t OVF
Definition ina234.h:135
uint16_t RESERVED
Definition ina234.h:135
uint16_t POL
Definition ina234.h:135
uint16_t CNVR
Definition ina234.h:135
uint16_t BUL
Definition ina234.h:135
uint16_t SUL
Definition ina234.h:135
uint16_t CVRF
Definition ina234.h:135
uint16_t POWER
Definition ina234.h:123
int16_t VSHUNT
Definition ina234.h:115
int16_t RESERVED
Definition ina234.h:115
Class (struct) that stores variables for interacting with INA234.
Definition ina234.h:81
Mode mode
Definition ina234.h:91
AlertLatch alert_latch
Definition ina234.h:97
NumSamples number_of_adc_samples
Definition ina234.h:88
float ShuntResistor
Definition ina234.h:92
AlertConvReady alert_conv_ready
Definition ina234.h:98
float BusVoltage
Definition ina234.h:103
ConvTime vshunt_conversion_time
Definition ina234.h:90
AlertOn alert_on
Definition ina234.h:95
AlertPolarity alert_polarity
Definition ina234.h:96
I2C_HandleTypeDef * hi2c
Definition ina234.h:83
ConvTime vbus_conversion_time
Definition ina234.h:89
float ShuntVoltage
Definition ina234.h:102
uint8_t I2C_ADDR
Definition ina234.h:84
float alert_limit
Definition ina234.h:99
int32_t alert_limit_int
Definition ina234.h:100
float Current
Definition ina234.h:105
float Power
Definition ina234.h:104
ADCRange adc_range
Definition ina234.h:87
struct ina234::_reg::_manufacture_id_register manufacture_id_register
uint8_t raw_data[2]
Definition ina234.h:108
struct ina234::_reg::_mask_enable_register mask_enable_register
struct ina234::_reg::_bus_voltage_register bus_voltage_register
struct ina234::_reg::_shunt_voltage_register shunt_voltage_register
struct ina234::_reg::_devide_id_register devide_id_register
struct ina234::_reg::_config_register config_register
struct ina234::_reg::_current_register current_register
struct ina234::_reg::_alert_limit_register alert_limit_register
struct ina234::_reg::_power_register power_register
struct ina234::_reg::_calibration_register calibration_register