Loading...
Searching...
No Matches
arduino_board_analog.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Otto-von-Guericke-Universität Magdeburg
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
23#ifndef ARDUINO_BOARD_ANALOG_H
24#define ARDUINO_BOARD_ANALOG_H
25
26#include "periph/adc.h"
27#include "arduino_iomap.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#ifdef DOXYGEN
39#define ARDUINO_ANALOG_PIN_LAST /* board specific number */
40#endif /* DOXYGEN */
41
42/* A board may not have any analog pins. But if it has any, it MUST define
43 * ARDUINO_ANALOG_PIN_LAST. */
44#if !defined(ARDUINO_ANALOG_PIN_LAST) && (defined(ARDUINO_A0) || defined(ARDUINO_A1))
45# error "ARDUINO_PIN_LAST undefined despite analog pins available"
46#endif
47
48/* A board not having A0 and A1, but having e.g. A3 would also trigger this.
49 * Extend as needed when porting new boards. */
50#if defined(ARDUINO_ANALOG_PIN_LAST) && !defined(ARDUINO_A0) && !defined(ARDUINO_A1)
51# error "ARDUINO_PIN_LAST defined but no analog pins available"
52#endif
53
54#if defined(ARDUINO_ANALOG_PIN_LAST) || defined(DOXYGEN)
73static const adc_t arduino_analog_map[] = {
74#ifndef DOXYGEN
75#ifdef ARDUINO_A0
76 ARDUINO_A0,
77#elif ARDUINO_ANALOG_PIN_LAST > 0
79#endif
80#ifdef ARDUINO_A1
81 ARDUINO_A1,
82#elif ARDUINO_ANALOG_PIN_LAST > 1
84#endif
85#ifdef ARDUINO_A2
86 ARDUINO_A2,
87#elif ARDUINO_ANALOG_PIN_LAST > 2
89#endif
90#ifdef ARDUINO_A3
91 ARDUINO_A3,
92#elif ARDUINO_ANALOG_PIN_LAST > 3
94#endif
95#ifdef ARDUINO_A4
96 ARDUINO_A4,
97#elif ARDUINO_ANALOG_PIN_LAST > 4
99#endif
100#ifdef ARDUINO_A5
101 ARDUINO_A5,
102#elif ARDUINO_ANALOG_PIN_LAST > 5
103 ADC_UNDEF,
104#endif
105#ifdef ARDUINO_A6
106 ARDUINO_A6,
107#elif ARDUINO_ANALOG_PIN_LAST > 6
108 ADC_UNDEF,
109#endif
110#ifdef ARDUINO_A7
111 ARDUINO_A7,
112#elif ARDUINO_ANALOG_PIN_LAST > 7
113 ADC_UNDEF,
114#endif
115#ifdef ARDUINO_A8
116 ARDUINO_A8,
117#elif ARDUINO_ANALOG_PIN_LAST > 8
118 ADC_UNDEF,
119#endif
120#ifdef ARDUINO_A9
121 ARDUINO_A9,
122#elif ARDUINO_ANALOG_PIN_LAST > 9
123 ADC_UNDEF,
124#endif
125#ifdef ARDUINO_A10
126 ARDUINO_A10,
127#elif ARDUINO_ANALOG_PIN_LAST > 10
128 ADC_UNDEF,
129#endif
130#ifdef ARDUINO_A11
131 ARDUINO_A11,
132#elif ARDUINO_ANALOG_PIN_LAST > 11
133 ADC_UNDEF,
134#endif
135#ifdef ARDUINO_A12
136 ARDUINO_A12,
137#elif ARDUINO_ANALOG_PIN_LAST > 12
138 ADC_UNDEF,
139#endif
140#ifdef ARDUINO_A13
141 ARDUINO_A13,
142#elif ARDUINO_ANALOG_PIN_LAST > 13
143 ADC_UNDEF,
144#endif
145#ifdef ARDUINO_A14
146 ARDUINO_A14,
147#elif ARDUINO_ANALOG_PIN_LAST > 14
148 ADC_UNDEF,
149#endif
150#ifdef ARDUINO_A15
151 ARDUINO_A15,
152#elif ARDUINO_ANALOG_PIN_LAST > 15
153 ADC_UNDEF,
154#endif
155#endif /* DOXYGEN */
156};
157#endif /* defined(ARDUINO_ANALOG_PIN_LAST) */
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif /* ARDUINO_BOARD_ANALOG_H */
Low-level ADC peripheral driver interface definitions.
static const adc_t arduino_analog_map[]
Look-up table for the Arduino's analog pins.
#define ADC_UNDEF
Default ADC undefined value.
Definition adc.h:79
uint_fast8_t adc_t
Define default ADC type identifier.
Definition adc.h:72