From b4a1ce17dd488fc59334604520e7bb6ff7e65cb9 Mon Sep 17 00:00:00 2001 From: bjackson312006 Date: Mon, 4 Nov 2024 11:30:29 -0500 Subject: [PATCH] Added public functions to INA226.h --- general/include/INA226.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/general/include/INA226.h b/general/include/INA226.h index 251bd69..f586d36 100644 --- a/general/include/INA226.h +++ b/general/include/INA226.h @@ -36,3 +36,39 @@ typedef struct { ReadPtr read; float current_lsb; } ina226_t; + +void ina226_init(ina226_t *ina, WritePtr write, ReadPtr read, + uint16_t dev_addr); + +int ina226_read_reg(ina226_t *ina, uint8_t reg, uint16_t *data); + +int ina226_write_reg(ina226_t *ina, uint8_t reg, uint16_t *data); + +// Writes calibration register. r_shunt in ohms, max_current in amps +int ina226_calibrate(ina226_t *ina, float r_shunt, float max_current); + +// Reads current in amps +int ina226_read_current(ina226_t *ina, float *data); + +// Reads power in watts +int ina226_read_power(ina226_t *ina, float *data); + +// Reads shunt voltage in volts +int ina226_read_shunt_voltage(ina226_t *ina, float *data); + +// Reads bus voltage in volts +int ina226_read_bus_voltage(ina226_t *ina, float *data); + +// Sets configuration register bits 0-11 (operating mode, shunt voltage conversion time, bus voltage conversion time, and averaging mode) +// See datasheet for settings +int ina226_configure(ina226_t *ina, uint8_t mode, uint8_t vshct, uint8_t vbusct, + uint8_t avg); + +// Resets all registers to default values +int ina226_reset(ina226_t ina); + +// Reads manufacturer id register +int ina226_read_manufacturer_id(ina226_t ina, uint16_t *data); + +// Reads die id +int ina226_read_die_id(ina226_t ina, uint16_t *data); \ No newline at end of file