Subversion Repositories HomeAutomation

Rev

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