Subversion Repositories HomeAutomation

Rev

Rev 788 | Rev 794 | Go to most recent revision | 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__)
  22. #error only tested on ATmega88/168
  23. #endif
  24.  
  25. /*-----------------------------------------------
  26.  * Includes
  27.  * ---------------------------------------------*/
  28. #include <stdlib.h>
  29. #include <inttypes.h>
  30.  
  31. /*-----------------------------------------------
  32.  * Defines
  33.  * ---------------------------------------------*/
  34.  
  35. /*
  36.  * NOTE!! ADCHAN is not neccessary anymore since channels are implemented!
  37.  *
  38.  * Define which ADC that will be used, ADC0 to ADC7.
  39.  * If using ATmega88/168 PDIP ADC7 wont be aviable, only on TFQP.
  40.  * (syntax: ADCx where x is the number och the ADC used)
  41.  *
  42.  * This should be defined in your application config.inc
  43.  */
  44. //#define ADCHAN ADC5
  45.  
  46.  
  47. /*-----------------------------------------------
  48.  * Functions
  49.  * ---------------------------------------------*/
  50.  
  51. /**
  52.  * @brief Initialize ADC.
  53.  *
  54.  * Initializes the ADC channel specified by ADCHAN, currently this driver
  55.  * have the ability to enable only one ADC channel. The voltage reference
  56.  * is set to Avcc.
  57.  *
  58.  */
  59. uint8_t ADC_Init(void);
  60.  
  61. /**
  62.  * @brief Get an ADC value.
  63.  *
  64.  * Starts an ADC conversion and returns the result right adjusted, 10 bits.
  65.  *
  66.   * @param channel
  67.  *      Channel to get ADC data from
  68.  * @retval
  69.  *      The ADC data
  70.  */
  71. uint16_t ADC_Get(uint8_t channel);
  72.  
  73. /**@}*/
  74. #endif
  75.