Add a FIXME.
[bertos.git] / drv / adc.c
1 /**
2  * \file
3  * <!--
4  * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See README.devlib for information.
6  * -->
7  *
8  * \version $Id$
9  *
10  * \brief ADC driver (implementation)
11  *
12  * \version $Id$
13  * \author Francesco Sacchi <batt@develer.com>
14  */
15
16 /*#*
17  *#* $Log$
18  *#* Revision 1.3  2006/09/13 18:30:07  bernie
19  *#* Add a FIXME.
20  *#*
21  *#* Revision 1.2  2006/07/19 12:56:25  bernie
22  *#* Convert to new Doxygen style.
23  *#*
24  *#* Revision 1.1  2005/06/27 21:28:31  bernie
25  *#* Import ADC driver.
26  *#*
27  *#*/
28
29
30 #include <drv/adc.h>
31 #include <drv/timer.h>
32
33 // FIXME: move CPU specific part to adc_CPU.c
34 #include <hw_adc.h>
35
36 #include <cfg/debug.h>
37 #include <cfg/macros.h>
38 #include <cfg/compiler.h>
39
40 DB(bool adc_initialized = false;)
41
42 /**
43  * Read the ADC channel \a ch.
44  */
45 adcread_t adc_read(uint16_t ch)
46 {
47         ASSERT(ch <= (uint16_t)ADC_MUX_MAXCH);
48         ch = MIN(ch, (uint16_t)ADC_MUX_MAXCH);
49
50         adc_hw_select_ch(ch);
51
52         return(adc_hw_read());
53 }
54
55 /**
56  * Initialize the ADC hardware.
57  */
58 void adc_init(void)
59 {
60         cpuflags_t flags;
61         IRQ_SAVE_DISABLE(flags);
62
63         ADC_HW_INIT;
64         DB(adc_initialized = true;)
65         IRQ_RESTORE(flags);
66 }