INA226 Library

Dependents:   HYBRYD2018_IZU_ROCKET Hybrid_IZU2019 SWAN_IZU2019_v1 Hybrid_OB2021_MAIN

INA226.h

Committer:
zebrin1422
Date:
2017-07-10
Revision:
0:ad712ebc38d6
Child:
1:9c367d227582

File content as of revision 0:ad712ebc38d6:

#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