X-Git-Url: http://git.kpe.io/?p=avr_bc100.git;a=blobdiff_plain;f=BaseTinyFirmware%2FIAR%2Fstatefunc.c;fp=BaseTinyFirmware%2FIAR%2Fstatefunc.c;h=e4d5ff64c174469735dfc6378a7a4f84c7ee49cc;hp=9dbdde18c4cf8c6bcc5a93b03471ea840d4f048d;hb=65612c4c7df34cdae10f9427ace6fd9e9e430d05;hpb=89173ec9cd6f33843bf27c45be0f2f9be3f5f0ce;ds=sidebyside diff --git a/BaseTinyFirmware/IAR/statefunc.c b/BaseTinyFirmware/IAR/statefunc.c index 9dbdde1..e4d5ff6 100644 --- a/BaseTinyFirmware/IAR/statefunc.c +++ b/BaseTinyFirmware/IAR/statefunc.c @@ -115,7 +115,7 @@ unsigned char Initialize(unsigned char inp) Time_Init(); // Attempt to get ADC-readings (also gets RID-data) from both batteries. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { EnableBattery(i); ADC_Wait(); BatteryStatusRefresh(); @@ -166,7 +166,7 @@ unsigned char BatteryControl(unsigned char inp) // Get ADC-readings, try to read EPROM, and start prequalification // of any uncharged battery. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { if (BattControl[i].Enabled) { EnableBattery(i); ADC_Wait(); @@ -220,11 +220,13 @@ unsigned char Sleep(unsigned char inp) // If any batteries need charging, go to ST_BATCON. // Otherwise, keep sleeping. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { EnableBattery(i); ADC_Wait(); - if ((BatteryStatusRefresh()) && (!BattData.Charged)) { - return(ST_BATCON); + if ( BatteryStatusRefresh() ) { + if ( !BattData.Charged ) { + return(ST_BATCON); + } } } @@ -275,6 +277,7 @@ void Doze(void) __sleep(); // Go to sleep, wake up by WDT. } else { + // stay awake if PB6 is pulled low by master do { } while ( !(WatchdogFlag) ); }