Subversion Repositories HomeAutomation

Rev

Rev 1416 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
785 arune 1
/**
2
 * @defgroup adc ADC driver
3
 * @code #include <drivers/adc/adc.h> @endcode
4
 *
5
 * @brief Simple low level ADC driver.
6
 *
7
 * This driver is a simple ADC implementation.
8
 *
9
 *
10
 * @author  Erik Larsson
11
 * @author  Anders Runeson
793 noddan 12
 * @author  Martin Norden
13
 * @date    2008-05-11
785 arune 14
 */
15
 
16
/**@{*/
17
 
18
#ifndef ADC_H_
19
#define ADC_H_
20
 
1468 arune 21
#if !defined(__AVR_ATmega88__) && !defined(__AVR_ATmega168__) && !defined(__AVR_ATmega168P__) && !defined(__AVR_ATmega328P__)
1415 arune 22
#error only tested on ATmega88/168/328
785 arune 23
#endif
24
 
1296 arune 25
#define ADC_NUM_CHANNELS 8
26
 
27
#ifndef ADC_INTERRUPTED      
28
#define ADC_INTERRUPTED 0
29
#endif
30
 
785 arune 31
/*-----------------------------------------------
32
 * Includes
33
 * ---------------------------------------------*/
34
#include <stdlib.h>
35
#include <inttypes.h>
36
 
37
/*-----------------------------------------------
38
 * Functions
39
 * ---------------------------------------------*/
40
 
41
/**
42
 * @brief Initialize ADC.
43
 *
794 noddan 44
 * Initializes the ADC-unit on the AVR. The voltage reference is set to Avcc.
785 arune 45
 *
46
 */
47
uint8_t ADC_Init(void);
48
 
49
/**
50
 * @brief Get an ADC value.
51
 *
52
 * Starts an ADC conversion and returns the result right adjusted, 10 bits.
794 noddan 53
 * If the channel is changed it does a dummy-read first to prevent garbage data.
785 arune 54
 *
794 noddan 55
 * @param channel
793 noddan 56
 *      Channel to get ADC data from
785 arune 57
 * @retval
58
 *      The ADC data
59
 */
60
uint16_t ADC_Get(uint8_t channel);
61
 
62
/**@}*/
63
#endif