INA226 Library
Dependents: HYBRYD2018_IZU_ROCKET Hybrid_IZU2019 SWAN_IZU2019_v1 Hybrid_OB2021_MAIN
Diff: INA226.h
- Revision:
- 0:ad712ebc38d6
- Child:
- 1:9c367d227582
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/INA226.h Mon Jul 10 10:50:39 2017 +0000 @@ -0,0 +1,56 @@ +#ifndef INA226 +#define INA226 + +#define SLV_WRITE 0b10000000 +#define SLV_READ 0b10000001 + +#define check_reg 0xFF +#define Ctrl_reg 0x00 +#define V_shunt_reg 0x01 +#define V_bus_reg 0x02 +#define power_reg 0x03 +#define current_reg 0x04 +#define cal_reg 0x05 + +//I2C i2c(PB_7, PB_6); // sda, scl +//Serial pc(USBTX, USBRX); //tx, rx + +/** +* @bref INA226 Class +* @author Seiya Maemura +*/ + + +class myINA226 +{ +public: + + + myINA226(I2C &i2cBus); + + void set_callibretion(unsigned int val = 0x0AAA); + + int Connection_check(); + + void setup(int i); + + void get_Voltage_current(float *V_bus, float *current); + + void get_Shunt_voltage(float *V_shunt); + + void get_Bus_voltage(float *V_bus); + + void get_current(float *current); + + void get_power(float *power); + + +private: + + I2C *i2c; + float vlotage,current; + unsigned int val[4]; + char *cal,buff[4],reg,check[2]; +}; + +#endif \ No newline at end of file