Toshihisa T
/
INA226TEST
INA226 Test Program. Using INA226 class library.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /* 00002 * Copyright (c) 2011 Toshihisa T 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 */ 00005 00006 #include "mbed.h" 00007 #include "INA226.hpp" 00008 00009 Serial debug(USBTX,USBRX); 00010 DigitalOut myled(LED1); 00011 I2C i2c(p28,p27); 00012 INA226 VCmonitor(i2c); 00013 00014 int main() { 00015 unsigned short val; 00016 double V,C; 00017 int count = 1; 00018 00019 debug.format(8,ParityNone,1); 00020 debug.baud(115200); 00021 debug.printf("VCmonitor INA226 TEST Program. (BUILD:[" __DATE__ "/" __TIME__ "])\n"); 00022 00023 if(!VCmonitor.isExist()){ 00024 debug.printf("VCmonitor NOT FOUND\n"); 00025 while(1){} 00026 } 00027 debug.printf("VCmonitor FOUND\n"); 00028 00029 val = 0; 00030 if(VCmonitor.rawRead(0x00,&val) != 0){ 00031 debug.printf("VCmonitor READ ERROR\n"); 00032 while(1){} 00033 } 00034 debug.printf("VCmonitor Reg 0x00 : 0x%04x\n",val); 00035 00036 VCmonitor.setCurrentCalibration(); 00037 00038 while(1) { 00039 if((VCmonitor.getVoltage(&V) == 0) && (VCmonitor.getCurrent(&C) == 0)){ 00040 debug.printf("%d,V,%f,C,%f\n",count,V,C); 00041 } 00042 myled = 1; 00043 wait(0.5); 00044 myled = 0; 00045 wait(0.5); 00046 count++; 00047 } 00048 }
Generated on Sun Jul 17 2022 20:40:16 by 1.7.2