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=ef1464dcab714766f0addf4d6fb0261e04cec53b;hp=9df2b5c93ea086c8c0d2611d1f8cec4141e571d5;hb=edd0e551e6041f7596c880cdaef13dfa67eff6b5;hpb=5b95e754a4af80c7389486ee874ac07c166a0867 diff --git a/BaseTinyFirmware/GCC/statefunc.c b/BaseTinyFirmware/GCC/statefunc.c index 9df2b5c..ef1464d 100644 --- a/BaseTinyFirmware/GCC/statefunc.c +++ b/BaseTinyFirmware/GCC/statefunc.c @@ -103,7 +103,7 @@ unsigned char Initialize(unsigned char inp) // Clear on-chip EEPROM. for (page = 0; page < 4; page++) { for (i = 0; i < 32; i++) { - eeprom_write_byte(&BattEEPROM[page][i], 0); + eeprom_write_byte(&BattEEPROM[page][i], 0); } } @@ -113,13 +113,16 @@ unsigned char Initialize(unsigned char inp) ADC_Init(); Time_Init(); + // Enable interrupts + sei(); + // Attempt to get ADC-readings (also gets RID-data) from both batteries. for (i = 0; i < 2; i++) { EnableBattery(i); ADC_Wait(); BatteryStatusRefresh(); } - + DisableBatteries(); BattActive = 0; // We have to start somewhere.. @@ -166,7 +169,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++) { - if (eeprom_read_byte(&BattControl[i]) & BIT_BATTERY_ENABLED) { + if (eeprom_read_byte(&BattControl[i]) & BIT_BATTERY_ENABLED) { EnableBattery(i); ADC_Wait(); @@ -174,7 +177,7 @@ unsigned char BatteryControl(unsigned char inp) if (!BattData.Charged) { BatteryDataRefresh(); - return(ST_PREQUAL); + return(ST_PREQUAL); } } } @@ -246,7 +249,7 @@ void Doze(void) ADCS.Flag = FALSE; do { - } while (ADCS.Flag == FALSE); + } while (ADCS.Flag == FALSE); WDTCR = (1< check load and jumper J405 and J406. - if (abs(ADCS.IBAT) > 100) { + if (abs(adcs_IBAT_tmp) > 100) { PWM_Stop(); return(FALSE); } @@ -415,7 +430,7 @@ unsigned char JumperCheck(void) return(FALSE); } - // Wait for ADC conversions to complete + // Wait for ADC conversions to complete ADC_Wait(); } while (Time_Left(TIMER_GEN));