Loading...
Searching...
No Matches
arduino_iomap.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Freie Universität Berlin
3 * SPDX-FileCopyrightText: 2016 Laurent Navet <laurent.navet@gmail.com>
4 * SPDX-FileCopyrightText: 2017 Thomas Perrot <thomas.perrot@tupi.fr>
5 * SPDX-License-Identifier: LGPL-2.1-only
6 */
7
8#pragma once
9
25
26#include "periph/adc.h"
27#include "periph/gpio.h"
28#include "periph/i2c.h"
29#include "periph/pwm.h"
30#include "periph/spi.h"
31#include "periph/uart.h"
32#include "periph_conf.h" /* For ADC_NUMOF */
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
42#define ARDUINO_UART_D0D1 UART_DEV(0)
44
52#define ARDUINO_SPI_ISP SPI_DEV(0)
54
62#ifndef BOARD_ARDUINO_NANO
63#define ARDUINO_I2C_UNO I2C_DEV(0)
64#else
65#define ARDUINO_I2C_NANO I2C_DEV(0)
66#endif
68
75
76/* Digital pins */
77#ifdef CPU_ATMEGA328P
78# define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 0)
79# define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 1)
80# define ARDUINO_PIN_2 GPIO_PIN(PORT_D, 2)
81# define ARDUINO_PIN_3 GPIO_PIN(PORT_D, 3)
82# define ARDUINO_PIN_4 GPIO_PIN(PORT_D, 4)
83# define ARDUINO_PIN_5 GPIO_PIN(PORT_D, 5)
84# define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 6)
85# define ARDUINO_PIN_7 GPIO_PIN(PORT_D, 7)
86# define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 0)
87# define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 1)
88# define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 2)
89# define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 3)
90# define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 4)
91# define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 5)
92/* Analog pins as digital pins: */
93# define ARDUINO_PIN_14 GPIO_PIN(PORT_C, 0)
94# define ARDUINO_PIN_15 GPIO_PIN(PORT_C, 1)
95# define ARDUINO_PIN_16 GPIO_PIN(PORT_C, 2)
96# define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 3)
97# define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 4)
98# define ARDUINO_PIN_19 GPIO_PIN(PORT_C, 5)
99
100# define ARDUINO_PIN_LAST 19
101
102/* Analog aliases */
103# define ARDUINO_PIN_A0 ARDUINO_PIN_14
104# define ARDUINO_PIN_A1 ARDUINO_PIN_15
105# define ARDUINO_PIN_A2 ARDUINO_PIN_16
106# define ARDUINO_PIN_A3 ARDUINO_PIN_17
107# define ARDUINO_PIN_A4 ARDUINO_PIN_18
108# define ARDUINO_PIN_A5 ARDUINO_PIN_19
109#endif
110
111#ifdef CPU_ATMEGA32U4
112/* Digital pins */
113# define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 2)
114# define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 3)
115# define ARDUINO_PIN_2 GPIO_PIN(PORT_D, 1)
116# define ARDUINO_PIN_3 GPIO_PIN(PORT_D, 0)
117# define ARDUINO_PIN_5 GPIO_PIN(PORT_C, 6)
118# define ARDUINO_PIN_7 GPIO_PIN(PORT_E, 6)
119# define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 7)
120# define ARDUINO_PIN_13 GPIO_PIN(PORT_C, 7)
121# define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 3)
122# define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 1)
123# define ARDUINO_PIN_16 GPIO_PIN(PORT_B, 2)
124# define ARDUINO_PIN_17 GPIO_PIN(PORT_B, 0)
125# define ARDUINO_PIN_30 GPIO_PIN(PORT_D, 5)
126
127/* Analog pins as digital pins: */
128# define ARDUINO_PIN_4 GPIO_PIN(PORT_D, 4)
129# define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 7)
130# define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 4)
131# define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 5)
132# define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 6)
133# define ARDUINO_PIN_12 GPIO_PIN(PORT_D, 6)
134# define ARDUINO_PIN_18 GPIO_PIN(PORT_F, 7)
135# define ARDUINO_PIN_19 GPIO_PIN(PORT_F, 6)
136# define ARDUINO_PIN_20 GPIO_PIN(PORT_F, 5)
137# define ARDUINO_PIN_21 GPIO_PIN(PORT_F, 4)
138# define ARDUINO_PIN_22 GPIO_PIN(PORT_F, 3)
139# define ARDUINO_PIN_23 GPIO_PIN(PORT_F, 2)
140
141# define ARDUINO_PIN_LAST 23
142
143/* Analog aliases */
144# define ARDUINO_PIN_A0 ARDUINO_PIN_18
145# define ARDUINO_PIN_A1 ARDUINO_PIN_19
146# define ARDUINO_PIN_A2 ARDUINO_PIN_20
147# define ARDUINO_PIN_A3 ARDUINO_PIN_21
148# define ARDUINO_PIN_A4 ARDUINO_PIN_22
149# define ARDUINO_PIN_A5 ARDUINO_PIN_23
150# define ARDUINO_PIN_A6 ARDUINO_PIN_4
151# define ARDUINO_PIN_A7 ARDUINO_PIN_6
152# define ARDUINO_PIN_A8 ARDUINO_PIN_8
153# define ARDUINO_PIN_A9 ARDUINO_PIN_9
154# define ARDUINO_PIN_A10 ARDUINO_PIN_10
155# define ARDUINO_PIN_A11 ARDUINO_PIN_12
156#endif
157
158#ifdef CPU_ATMEGA2560
159/* Digital pins */
160# define ARDUINO_PIN_0 GPIO_PIN(PORT_E, 0)
161# define ARDUINO_PIN_1 GPIO_PIN(PORT_E, 1)
162# define ARDUINO_PIN_2 GPIO_PIN(PORT_E, 4)
163# define ARDUINO_PIN_3 GPIO_PIN(PORT_E, 5)
164# define ARDUINO_PIN_4 GPIO_PIN(PORT_G, 5)
165# define ARDUINO_PIN_5 GPIO_PIN(PORT_E, 3)
166# define ARDUINO_PIN_6 GPIO_PIN(PORT_H, 3)
167# define ARDUINO_PIN_7 GPIO_PIN(PORT_H, 4)
168# define ARDUINO_PIN_8 GPIO_PIN(PORT_H, 5)
169# define ARDUINO_PIN_9 GPIO_PIN(PORT_H, 6)
170# define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 4)
171# define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 5)
172# define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 6)
173# define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 7)
174# define ARDUINO_PIN_14 GPIO_PIN(PORT_J, 1)
175# define ARDUINO_PIN_15 GPIO_PIN(PORT_J, 0)
176# define ARDUINO_PIN_16 GPIO_PIN(PORT_H, 1)
177# define ARDUINO_PIN_17 GPIO_PIN(PORT_H, 0)
178# define ARDUINO_PIN_18 GPIO_PIN(PORT_D, 3)
179# define ARDUINO_PIN_19 GPIO_PIN(PORT_D, 2)
180# define ARDUINO_PIN_20 GPIO_PIN(PORT_D, 1)
181# define ARDUINO_PIN_21 GPIO_PIN(PORT_D, 0)
182# define ARDUINO_PIN_22 GPIO_PIN(PORT_A, 0)
183# define ARDUINO_PIN_23 GPIO_PIN(PORT_A, 1)
184# define ARDUINO_PIN_24 GPIO_PIN(PORT_A, 2)
185# define ARDUINO_PIN_25 GPIO_PIN(PORT_A, 3)
186# define ARDUINO_PIN_26 GPIO_PIN(PORT_A, 4)
187# define ARDUINO_PIN_27 GPIO_PIN(PORT_A, 5)
188# define ARDUINO_PIN_28 GPIO_PIN(PORT_A, 6)
189# define ARDUINO_PIN_29 GPIO_PIN(PORT_A, 7)
190# define ARDUINO_PIN_30 GPIO_PIN(PORT_C, 7)
191# define ARDUINO_PIN_31 GPIO_PIN(PORT_C, 6)
192# define ARDUINO_PIN_32 GPIO_PIN(PORT_C, 5)
193# define ARDUINO_PIN_33 GPIO_PIN(PORT_C, 4)
194# define ARDUINO_PIN_34 GPIO_PIN(PORT_C, 3)
195# define ARDUINO_PIN_35 GPIO_PIN(PORT_C, 2)
196# define ARDUINO_PIN_36 GPIO_PIN(PORT_C, 1)
197# define ARDUINO_PIN_37 GPIO_PIN(PORT_E, 0)
198# define ARDUINO_PIN_38 GPIO_PIN(PORT_D, 7)
199# define ARDUINO_PIN_39 GPIO_PIN(PORT_G, 2)
200# define ARDUINO_PIN_40 GPIO_PIN(PORT_G, 1)
201# define ARDUINO_PIN_41 GPIO_PIN(PORT_G, 0)
202# define ARDUINO_PIN_42 GPIO_PIN(PORT_L, 7)
203# define ARDUINO_PIN_43 GPIO_PIN(PORT_L, 6)
204# define ARDUINO_PIN_44 GPIO_PIN(PORT_L, 5)
205# define ARDUINO_PIN_45 GPIO_PIN(PORT_L, 4)
206# define ARDUINO_PIN_46 GPIO_PIN(PORT_L, 3)
207# define ARDUINO_PIN_47 GPIO_PIN(PORT_L, 2)
208# define ARDUINO_PIN_48 GPIO_PIN(PORT_L, 1)
209# define ARDUINO_PIN_49 GPIO_PIN(PORT_L, 0)
210# define ARDUINO_PIN_50 GPIO_PIN(PORT_B, 3)
211# define ARDUINO_PIN_51 GPIO_PIN(PORT_B, 2)
212# define ARDUINO_PIN_52 GPIO_PIN(PORT_B, 1)
213# define ARDUINO_PIN_53 GPIO_PIN(PORT_B, 0)
214
215/* Analog pins as digital pins: */
216# define ARDUINO_PIN_54 GPIO_PIN(PORT_F, 0)
217# define ARDUINO_PIN_55 GPIO_PIN(PORT_F, 1)
218# define ARDUINO_PIN_56 GPIO_PIN(PORT_F, 2)
219# define ARDUINO_PIN_57 GPIO_PIN(PORT_F, 3)
220# define ARDUINO_PIN_58 GPIO_PIN(PORT_F, 4)
221# define ARDUINO_PIN_59 GPIO_PIN(PORT_F, 5)
222# define ARDUINO_PIN_60 GPIO_PIN(PORT_F, 6)
223# define ARDUINO_PIN_61 GPIO_PIN(PORT_F, 7)
224# define ARDUINO_PIN_62 GPIO_PIN(PORT_K, 0)
225# define ARDUINO_PIN_63 GPIO_PIN(PORT_K, 1)
226# define ARDUINO_PIN_64 GPIO_PIN(PORT_K, 2)
227# define ARDUINO_PIN_65 GPIO_PIN(PORT_K, 3)
228# define ARDUINO_PIN_66 GPIO_PIN(PORT_K, 4)
229# define ARDUINO_PIN_67 GPIO_PIN(PORT_K, 5)
230# define ARDUINO_PIN_68 GPIO_PIN(PORT_K, 6)
231# define ARDUINO_PIN_69 GPIO_PIN(PORT_K, 7)
232
233# define ARDUINO_PIN_LAST 69
234
235/* Analog aliases */
236# define ARDUINO_PIN_A0 ARDUINO_PIN_54
237# define ARDUINO_PIN_A1 ARDUINO_PIN_55
238# define ARDUINO_PIN_A2 ARDUINO_PIN_56
239# define ARDUINO_PIN_A3 ARDUINO_PIN_57
240# define ARDUINO_PIN_A4 ARDUINO_PIN_58
241# define ARDUINO_PIN_A5 ARDUINO_PIN_59
242# define ARDUINO_PIN_A6 ARDUINO_PIN_60
243# define ARDUINO_PIN_A7 ARDUINO_PIN_61
244# define ARDUINO_PIN_A8 ARDUINO_PIN_62
245# define ARDUINO_PIN_A9 ARDUINO_PIN_63
246# define ARDUINO_PIN_A10 ARDUINO_PIN_64
247# define ARDUINO_PIN_A11 ARDUINO_PIN_65
248# define ARDUINO_PIN_A12 ARDUINO_PIN_66
249# define ARDUINO_PIN_A13 ARDUINO_PIN_67
250# define ARDUINO_PIN_A14 ARDUINO_PIN_68
251# define ARDUINO_PIN_A15 ARDUINO_PIN_69
252#endif
253
254#if ADC_NUMOF >= 8
255# define ARDUINO_A0 ADC_LINE(0)
256# define ARDUINO_A1 ADC_LINE(1)
257# define ARDUINO_A2 ADC_LINE(2)
258# define ARDUINO_A3 ADC_LINE(3)
259# define ARDUINO_A4 ADC_LINE(4)
260# define ARDUINO_A5 ADC_LINE(5)
261# define ARDUINO_A6 ADC_LINE(6)
262# define ARDUINO_A7 ADC_LINE(7)
263#endif
264#if ADC_NUMOF >= 16
265# define ARDUINO_A8 ADC_LINE(8)
266# define ARDUINO_A9 ADC_LINE(9)
267# define ARDUINO_A10 ADC_LINE(10)
268# define ARDUINO_A11 ADC_LINE(11)
269# define ARDUINO_A12 ADC_LINE(12)
270# define ARDUINO_A13 ADC_LINE(13)
271# define ARDUINO_A14 ADC_LINE(14)
272# define ARDUINO_A15 ADC_LINE(15)
273#endif
274
275/* Either 8, 16 or 0 ADC lines are configured by all ATmega boards */
276#if ADC_NUMOF == 8
277# define ARDUINO_ANALOG_PIN_LAST 7
278#elif ADC_NUMOF == 16
279# define ARDUINO_ANALOG_PIN_LAST 15
280#endif
282
290#define ARDUINO_PWM_FREQU (490U)
291
292/* keep in sync with PWM config in boards/common/atmega/include/periph_conf_atmega_common.h */
293#if defined(CPU_ATMEGA328P)
294# define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0)
295# define ARDUINO_PIN_6_PWM_CHAN 0
296
297# define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0)
298# define ARDUINO_PIN_5_PWM_CHAN 1
299
300# define ARDUINO_PIN_11_PWM_DEV PWM_DEV(1)
301# define ARDUINO_PIN_11_PWM_CHAN 0
302
303# define ARDUINO_PIN_3_PWM_DEV PWM_DEV(1)
304# define ARDUINO_PIN_3_PWM_CHAN 1
305#elif defined(CPU_ATMEGA2560)
306# define ARDUINO_PIN_13_PWM_DEV PWM_DEV(0)
307# define ARDUINO_PIN_13_PWM_CHAN 0
308
309# define ARDUINO_PIN_4_PWM_DEV PWM_DEV(0)
310# define ARDUINO_PIN_4_PWM_CHAN 1
311
312# define ARDUINO_PIN_10_PWM_DEV PWM_DEV(1)
313# define ARDUINO_PIN_10_PWM_CHAN 0
314
315# define ARDUINO_PIN_9_PWM_DEV PWM_DEV(1)
316# define ARDUINO_PIN_9_PWM_CHAN 1
317#elif defined(CPU_ATMEGA32U4)
318# define ARDUINO_PIN_11_PWM_DEV PWM_DEV(0)
319# define ARDUINO_PIN_11_PWM_CHAN 0
320
321# define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0)
322# define ARDUINO_PIN_3_PWM_CHAN 1
323#endif
324
326
327#ifdef __cplusplus
328}
329#endif
330
Low-level ADC peripheral driver interface definitions.
Common configuration of MCU periphery for Arduino Atmega boards.
Low-level GPIO peripheral driver interface definitions.
Low-level I2C peripheral driver interface definition.
Low-level PWM peripheral driver interface definitions.
Low-level SPI peripheral driver interface definition.
Low-level UART peripheral driver interface definition.