Subversion Repositories HomeAutomation

Rev

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

  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
  12.  * @author  Martin Norden
  13.  * @date    2008-05-11
  14.  */
  15.  
  16. /**@{*/
  17.  
  18. #ifndef ADC_H_
  19. #define ADC_H_
  20.  
  21. #if !defined(__AVR_ATmega88__) && !defined(__AVR_ATmega168__) && !defined(__AVR_ATmega168P__) && !defined(__AVR_ATmega328P__)
  22. #error only tested on ATmega88/168/328
  23. #endif
  24.  
  25. #define ADC_NUM_CHANNELS 8
  26.  
  27. #ifndef ADC_INTERRUPTED      
  28. #define ADC_INTERRUPTED 0
  29. #endif
  30.  
  31. /*-----------------------------------------------
  32.  * Includes
  33.  * ---------------------------------------------*/
  34. #include <stdlib.h>
  35. #include <inttypes.h>
  36.  
  37. /*-----------------------------------------------
  38.  * Functions
  39.  * ---------------------------------------------*/
  40.  
  41. /**
  42.  * @brief Initialize ADC.
  43.  *
  44.  * Initializes the ADC-unit on the AVR. The voltage reference is set to Avcc.
  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.
  53.  * If the channel is changed it does a dummy-read first to prevent garbage data.
  54.  *
  55.  * @param channel
  56.  *      Channel to get ADC data from
  57.  * @retval
  58.  *      The ADC data
  59.  */
  60. uint16_t ADC_Get(uint8_t channel);
  61.  
  62. /**@}*/
  63. #endif
  64.