ltc2944_team
/
Nucleo_2944_test3
Pgm de test
Fork of NBoard_RTC_1338 by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 00002 #include "mbed.h" 00003 #include "LTC2944.h" 00004 #include "C12832.h" 00005 00006 00007 Serial pc(USBTX, USBRX); // I/O terminal PC 00008 00009 LTC2944 j(PB_9,PB_8); 00010 C12832 lcd(D11, D13, D12, D7, D10); 00011 00012 DigitalIn Alert(PC_8); 00013 //InterruptIn Alert(PC_8); 00014 //DigitalOut L1(LED1); 00015 Ticker lecture; 00016 char alertflag=0; 00017 char jflag=0; 00018 00019 void lect_j(void) 00020 { 00021 jflag=1; 00022 } 00023 void razAlert() 00024 { 00025 alertflag=1; 00026 00027 } 00028 int main() 00029 { 00030 lcd.cls(); 00031 lcd.locate(0,3); 00032 lcd.printf("mbed "); 00033 // L1=0; 00034 // Alert.fall(&razAlert); 00035 lecture.attach(&lect_j,2); 00036 pc.printf("Hello\n"); 00037 j.setRsense(15.0); 00038 j.setMode(3); //automatic 00039 j.setPrescaler(7); // 4096 00040 j.setImin(-0.1); 00041 j.setImax(0.1); 00042 00043 while(1) { 00044 00045 // L1=!Alert; 00046 if(jflag) { 00047 float voltage=j.getVoltage(); 00048 float current=j.getCurrent(); 00049 unsigned short charge=j.getAccumulatedCharge(); 00050 pc.printf("voltage %7.3f \n",voltage); 00051 pc.printf("curent %7.3f \n",current); 00052 pc.printf("charge %x \n",charge); 00053 00054 lcd.locate(0,3); 00055 lcd.printf("V : %7.3f",voltage); 00056 lcd.locate(0,11); 00057 lcd.printf("I : %7.3f",current); 00058 lcd.locate(0,20); 00059 lcd.printf("C : %5d",charge); 00060 if(!Alert) { 00061 if(alertflag) { 00062 00063 //wait(2); 00064 unsigned char x=j.alertResponse(); 00065 pc.printf("response %x \n",x); 00066 x=j.getStatus(); 00067 pc.printf("status %x \n",x); 00068 00069 00070 } 00071 00072 } 00073 jflag=0; 00074 00075 } 00076 } 00077 }
Generated on Mon Sep 26 2022 11:16:24 by 1.7.2