From ec28fcd9f905358759eea98161f451567135d17e Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 27 Aug 2023 22:31:09 +0200 Subject: new driver blinkenlights --- driver_fw/ina226.c | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 driver_fw/ina226.c (limited to 'driver_fw/ina226.c') diff --git a/driver_fw/ina226.c b/driver_fw/ina226.c deleted file mode 100644 index c740125..0000000 --- a/driver_fw/ina226.c +++ /dev/null @@ -1,27 +0,0 @@ - -#include "global.h" -#include "i2c.h" -#include "ina226.h" - -void ina226_init() { - /* FIXME plug in final values for I meas backchannel */ - uint16_t config = INA226_CONFIG_AVG_1 | INA226_CONFIG_VBUSCT_204u | INA226_CONFIG_VSHCT_4m156 | - INA226_CONFIG_MODE_SHUNT | INA226_CONFIG_MODE_BUS | INA226_CONFIG_MODE_CONT; - ina226_write_reg(INA226_REG_CONFIG, config); - - ina226_write_reg(INA226_REG_CAL, INA226_CAL); -} - -void ina226_write_reg(uint8_t reg, uint16_t val) { - uint8_t buf[3] = { reg, val>>8, val&0xff }; - i2c_transmit(INA226_I2C_PERIPH, buf, sizeof(buf), INA226_I2C_ADDR, I2C_GENSTOP_YES); -} - -uint16_t ina226_read_reg(uint8_t reg) { - uint8_t buf2[1] = { reg }; - i2c_transmit(INA226_I2C_PERIPH, buf2, sizeof(buf2), INA226_I2C_ADDR, I2C_GENSTOP_NO); - uint8_t rx[2]; - i2c_receive(INA226_I2C_PERIPH, rx, sizeof(rx), INA226_I2C_ADDR); - return (rx[0]<<8) | rx[1]; -} - -- cgit