Contiki-NG
adc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, ADVANSEE - http://www.advansee.com/
3  * Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30  * OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /**
33  * \addtogroup cc2538
34  * @{
35  *
36  * \defgroup cc2538-adc cc2538 ADC
37  *
38  * Driver for the cc2538 ADC controller
39  * @{
40  *
41  * \file
42  * Header file for the cc2538 ADC driver
43  */
44 #ifndef ADC_H_
45 #define ADC_H_
46 
47 #include "contiki.h"
48 #include "dev/soc-adc.h"
49 
50 #include <stdint.h>
51 /*---------------------------------------------------------------------------*/
52 /** \name ADC functions
53  * @{
54  */
55 
56 /** \brief Initializes the ADC controller */
57 void adc_init(void);
58 
59 /** \brief Performs a single conversion on a given ADC channel
60  * \param channel The channel used for the conversion: \c SOC_ADC_ADCCON_CH_x
61  * \param ref The reference voltage used for the conversion: \c SOC_ADC_ADCCON_REF_x
62  * \param div The decimation rate used for the conversion: \c SOC_ADC_ADCCON_DIV_x
63  * \return Signed 16-bit conversion result: 2's complement, ENOBs in MSBs
64  * \note PD[5:4] are not usable when the temperature sensor is selected.
65  */
66 int16_t adc_get(uint8_t channel, uint8_t ref, uint8_t div);
67 
68 /** @} */
69 
70 #endif /* ADC_H_ */
71 
72 /**
73  * @}
74  * @}
75  */
void adc_init(void)
Initializes the ADC controller.
Definition: adc.c:50
Header file with register declarations for the cc2538 ADC and H/W RNG.
int16_t adc_get(uint8_t channel, uint8_t ref, uint8_t div)
Performs a single conversion on a given ADC channel.
Definition: adc.c:57