Skip to content

Commit

Permalink
Added public functions to INA226.h
Browse files Browse the repository at this point in the history
  • Loading branch information
bjackson312006 committed Nov 4, 2024
1 parent 9e0b15a commit b4a1ce1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions general/include/INA226.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit b4a1ce1

Please sign in to comment.