2008-03-14 Martin Thomas <mthomas@rhrk.uni-kl.de>
[avr_bc100.git] / BaseTinyFirmware / GCC / ADC.h
1 /* This file has been prepared for Doxygen automatic documentation generation.*/\r
2 /*! \file *********************************************************************\r
3  *\r
4  * \brief\r
5  *      Headerfile for ADC.c\r
6  *\r
7  *      Contains definitions for ADC setup, and minimum supply voltage.\r
8  *\r
9  * \par Application note:\r
10  *      AVR458: Charging Li-Ion Batteries with BC100\r
11  *\r
12  * \par Documentation:\r
13  *      For comprehensive code documentation, supported compilers, compiler\r
14  *      settings and supported devices see readme.html\r
15  *\r
16  * \author\r
17  *      Atmel Corporation: http://www.atmel.com \n\r
18  *      Support email: avr@atmel.com \n\r
19  *      Original author: \n\r
20  *\r
21  * $Name$\r
22  * $Revision: 2261 $\r
23  * $RCSfile$\r
24  * $URL: http://svn.norway.atmel.com/AppsAVR8/avr458_Charging_Li-Ion_Batteries_with_BC100/tag/20070904_release_1.0/code/IAR/ADC.h $\r
25  * $Date: 2007-08-10 09:28:35 +0200 (fr, 10 aug 2007) $\n\r
26  ******************************************************************************/\r
27 \r
28 #ifndef ADC_H\r
29 #define ADC_H\r
30 \r
31 #include <avr/eeprom.h>\r
32 \r
33 //******************************************************************************\r
34 // ADC setup\r
35 //******************************************************************************\r
36 // 8MHz / (25x128) = 2500 samples/s/ch\r
37 #define ADC_PRESCALER     0x07\r
38 /*!< \brief Prescaling of ADC clock.\r
39  *\r
40  * The ADC will run at 8 MHz (system clock) divided by 128\r
41  * (prescaler), and every sample will takes approximately 25 ticks:\r
42  * Sample rate = 8 MHz / (128 * 25 cycles/sample) = 2.5 k samples/sec\r
43  */\r
44 \r
45 \r
46 //******************************************************************************\r
47 // Minimum supply voltage\r
48 //******************************************************************************\r
49 //! Minimum supply voltage (at TP101 = VIN+), in mV.\r
50 #define VIN_MIN               4400\r
51 \r
52 \r
53 //******************************************************************************\r
54 // Global variables\r
55 //******************************************************************************\r
56 extern unsigned char EEMEM VBAT_RANGE;\r
57 extern volatile ADC_Status_t ADCS;\r
58 \r
59 \r
60 //******************************************************************************\r
61 // Function prototypes\r
62 //******************************************************************************\r
63 unsigned int ScaleU(unsigned char setting, unsigned int data);\r
64 unsigned int ScaleI(unsigned char setting, unsigned int data);\r
65 void ADC_Wait(void);\r
66 void ADC_Init(void);\r
67 \r
68 #endif // ADC_H\r
69 \r