00001 /* This file has been prepared for Doxygen automatic documentation generation.*/ 00055 #include "vadc_usage.h" 00056 #include "ATmega8HVA_16HVA_signature.h" 00057 #include <ioavr.h> 00058 #include <inavr.h> 00059 00060 00061 void main (void) 00062 { 00063 uint8_t status; 00064 00065 // Load coefficients needed for calcualations from the signature row. 00066 InitCoeff(); 00067 00068 /* Initialize band-gap reference to factory calibration. Calibration might 00069 * either have been done only at a HOT temperature, or also at room 00070 * temperature for complete calibration. Loading of HOT calibration _must_ 00071 * be done before running CalibrateVREF() function. 00072 */ 00073 status = InitBandgap(); 00074 00075 // Check if calibration was only done at HOT temperaure. 00076 if( status == CALIB_HOT ){ 00077 if(CalibrateVREF()){ 00078 // Eternal loop if calibration failed. 00079 do {} while (1); 00080 } 00081 }else{ 00082 // Check if calibration was also done at room temperature. 00083 if(status != CALIB_ROOM){ 00084 // Eternal loop if device was not calibrated at all. 00085 do {} while (1); 00086 } 00087 } 00088 00089 /* Voltage ADC measurements and calculations. Results are stored in global 00090 * variables; \ref cell_v[NO_CELLS], adc and \ref bg_temp. 00091 */ 00092 do { 00093 StartVADCScan(); 00094 do{} while (!vadc_scan_complete); 00095 CalculateADCResults(); 00096 } while(1); 00097 } 00098 00099
1.5.5