X-Git-Url: http://git.kpe.io/?p=avr_bc100.git;a=blobdiff_plain;f=BaseTinyFirmware%2FGCC%2Fstatefunc.c;fp=BaseTinyFirmware%2FGCC%2Fstatefunc.c;h=e0e265901ee3cb064da476f907b735a96c16e890;hp=9fc0ae5ae08669aecee4f6b6dfa13b1d2c4117c3;hb=65612c4c7df34cdae10f9427ace6fd9e9e430d05;hpb=89173ec9cd6f33843bf27c45be0f2f9be3f5f0ce diff --git a/BaseTinyFirmware/GCC/statefunc.c b/BaseTinyFirmware/GCC/statefunc.c index 9fc0ae5..e0e2659 100644 --- a/BaseTinyFirmware/GCC/statefunc.c +++ b/BaseTinyFirmware/GCC/statefunc.c @@ -123,7 +123,7 @@ unsigned char Initialize(unsigned char inp) sei(); // 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(); @@ -174,7 +174,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 (eeprom_read_byte(&BattControl[i]) & BIT_BATTERY_ENABLED) { EnableBattery(i); ADC_Wait(); @@ -228,11 +228,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); + } } } @@ -282,6 +284,7 @@ void Doze(void) sleep_cpu(); // Go to sleep, wake up by WDT. } else { + // stay awake if PB6 is pulled low by master do { } while ( !(WatchdogFlag) ); }