00001
00052 #include <stdint.h>
00053
00054
00055
00057 #define SYSTEM_CLK_Hz 1000000
00058
00060 #define BANDGAP_WAIT_us 20
00061
00063 #define BANDGAP_ADJ_DELAY 20*SYSTEM_CLK_Hz/1000000
00064
00065 #define SUCCESS 0
00066 #define FAILED -1
00067 #define CALIB_ROOM 25 // Not absolute calibration value, only mode.
00068 #define CALIB_HOT 70 // Not absolute calibration value, only mode.
00069
00071 #define VADC_SCALE_BITS 14
00072
00073
00074 #define NO_CELLS 2
00075 #define NO_VADC 2
00076 #define NO_VADC_CHANNELS 5
00077
00078 #define TOP_CELL 2
00079 #define BOTTOM_CELL 1
00080
00081 #define FIRST_VADC_MEAS 4
00082 #define LAST_VADC_MEAS 6
00083
00084
00085 #define VPTAT 0
00086 #define VADC0 1
00087 #define VADC1 2
00088 #define CELL1 3
00089 #define CELL2 4
00090
00091
00092
00093 #ifndef module_vadc_usage
00094
00095 extern uint16_t cell_v[NO_CELLS];
00096 extern uint16_t vadc_v[NO_VADC];
00097 extern uint16_t bg_temp;
00098 extern uint8_t vadc_scan_complete;
00099 #endif
00100
00101
00102
00103
00104 void InitCoeff(void);
00105 int8_t InitBandgap(void);
00106 void StartVADCScan(void);
00107 void CalculateADCResults(void);
00108 int8_t CalibrateVREF(void);
00109 int16_t MeasureVADCerror(void);