/**
* \file
*
*
* \defgroup adc Generic ADC driver
* \ingroup drivers
* \{
* \brief Analog to Digital Converter driver (ADC).
*
* Configuration file: cfg_adc.h
*
* \author Francesco Sacchi
*
* $WIZ$ module_name = "adc"
* $WIZ$ module_configuration = "bertos/cfg/cfg_adc.h"
* $WIZ$ module_supports = "not atmega103"
*/
#ifndef DRV_ADC_H
#define DRV_ADC_H
#include
#include
#include
#include CPU_HEADER(adc)
/** Type for ADC return value. */
typedef uint16_t adcread_t;
/** Type for channel */
typedef uint8_t adc_ch_t;
#define adc_bits() ADC_BITS
adcread_t adc_read(adc_ch_t ch);
void adc_init(void);
/**
* Macro used to convert data from adc range (0...(2 ^ADC_BITS - 1)) to
* \a y1 ... \a y2 range.
* \note \a y1, \a y2 can be negative, and put in ascending or descending order as well.
* \note \a data and \a y2 are evaluated only once, \a y1 twice.
*/
#define ADC_RANGECONV(data, y1, y2) (((((int32_t)(data)) * ((y2) - (y1))) / ((1 << ADC_BITS) - 1)) + (y1))
/** \} */ //defgroup adc
#endif /* DRV_ADC_H */