adc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2015 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
55 #ifndef PERIPH_ADC_H
56 #define PERIPH_ADC_H
57 
58 #include <limits.h>
59 #include <stdint.h>
60 
61 #include "periph_cpu.h"
62 #include "periph_conf.h"
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
71 #ifndef HAVE_ADC_T
72 typedef unsigned int adc_t;
73 #endif
74 
78 #ifndef ADC_UNDEF
79 #define ADC_UNDEF (UINT_MAX)
80 #endif
81 
85 #ifndef ADC_LINE
86 #define ADC_LINE(x) (x)
87 #endif
88 
92 #ifndef HAVE_ADC_RES_T
93 typedef enum {
100 } adc_res_t;
101 #endif
102 
113 int adc_init(adc_t line);
114 
129 int32_t adc_sample(adc_t line, adc_res_t res);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* PERIPH_ADC_H */
136 
ADC_RES_6BIT
@ ADC_RES_6BIT
ADC resolution: 6 bit.
Definition: adc.h:94
adc_t
unsigned int adc_t
Define default ADC type identifier.
Definition: adc.h:72
ADC_RES_14BIT
@ ADC_RES_14BIT
ADC resolution: 14 bit.
Definition: adc.h:98
adc_res_t
adc_res_t
Possible ADC resolution settings.
Definition: adc.h:93
ADC_RES_16BIT
@ ADC_RES_16BIT
ADC resolution: 16 bit.
Definition: adc.h:99
ADC_RES_8BIT
@ ADC_RES_8BIT
ADC resolution: 8 bit.
Definition: adc.h:95
adc_init
int adc_init(adc_t line)
Initialize the given ADC line.
ADC_RES_10BIT
@ ADC_RES_10BIT
ADC resolution: 10 bit.
Definition: adc.h:96
adc_sample
int32_t adc_sample(adc_t line, adc_res_t res)
Sample a value from the given ADC line.
ADC_RES_12BIT
@ ADC_RES_12BIT
ADC resolution: 12 bit.
Definition: adc.h:97