INA226 Library

Dependents:   HYBRYD2018_IZU_ROCKET Hybrid_IZU2019 SWAN_IZU2019_v1 Hybrid_OB2021_MAIN

INA226.h

Committer:
zebrin1422
Date:
2017-07-11
Revision:
1:9c367d227582
Parent:
0:ad712ebc38d6
Child:
2:eccb118370eb

File content as of revision 1:9c367d227582:

#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);
        
        float get_Shunt_voltage();
        
        float get_Bus_voltage();
        
        float get_current();
        
        float get_power();
        
        
private: 

        I2C *i2c;
        float vlotage,current;
        unsigned int val[4];
        char *cal,buff[4],reg,check[2];
};

#endif