arduino_iomap.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 
9 #pragma once
10 
24 #include "periph/gpio.h"
25 #include "periph/adc.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #define ARDUINO_UART_D0D1 UART_DEV(1)
45 /* D11/D12/D13 are on P1.13, P1.14, P1.15 */
46 #define ARDUINO_SPI_D11D12D13 SPI_DEV(0)
47 /* The ISP SPI bus is also connected to P1.13, P1.14, P1.15 */
48 #define ARDUINO_SPI_ISP SPI_DEV(0)
59 #define ARDUINO_I2C_UNO I2C_DEV(0)
66 #define ARDUINO_LED (24)
73 /* P3 header on the nRF52840DK */
74 #define ARDUINO_PIN_0 GPIO_PIN(1, 1)
75 #define ARDUINO_PIN_1 GPIO_PIN(1, 2)
76 #define ARDUINO_PIN_2 GPIO_PIN(1, 3)
77 #define ARDUINO_PIN_3 GPIO_PIN(1, 4)
78 #define ARDUINO_PIN_4 GPIO_PIN(1, 5)
79 #define ARDUINO_PIN_5 GPIO_PIN(1, 6)
80 #define ARDUINO_PIN_6 GPIO_PIN(1, 7)
81 #define ARDUINO_PIN_7 GPIO_PIN(1, 8)
82 
83 /* P4 header on the nRF52840DK */
84 #define ARDUINO_PIN_8 GPIO_PIN(1, 10)
85 #define ARDUINO_PIN_9 GPIO_PIN(1, 11)
86 #define ARDUINO_PIN_10 GPIO_PIN(1, 12)
87 #define ARDUINO_PIN_11 GPIO_PIN(1, 13)
88 #define ARDUINO_PIN_12 GPIO_PIN(1, 14)
89 #define ARDUINO_PIN_13 GPIO_PIN(1, 15)
90 /* SCL and SDA on this header are not available as digital pins in the
91  * Arduino world. It is P0.26 and P0.27 here, though. Also what would be
92  * AREF in the Arduino world is P0.02 here */
93 
94 /* P6 header on the nRF52840DK */
95 #define ARDUINO_PIN_14 GPIO_PIN(0, 10)
96 #define ARDUINO_PIN_15 GPIO_PIN(0, 9)
97 #define ARDUINO_PIN_16 GPIO_PIN(0, 8)
98 #define ARDUINO_PIN_17 GPIO_PIN(0, 7)
99 #define ARDUINO_PIN_18 GPIO_PIN(0, 6)
100 #define ARDUINO_PIN_19 GPIO_PIN(0, 5)
101 #define ARDUINO_PIN_20 GPIO_PIN(0, 1)
102 #define ARDUINO_PIN_21 GPIO_PIN(0, 0)
103 
104 /* P24 header on the nRF52840DK
105  * Note: The header is one column short on the right (missing a column of
106  * two 5V supply pins) and 8 columns on the left (missing D40 to D53
107  * and two GND on the leftmost column).
108  * Warning: Where D39 is expected a GND pin is sitting instead */
109 #define ARDUINO_PIN_22 GPIO_PIN(0, 11)
110 #define ARDUINO_PIN_23 GPIO_PIN(0, 12)
111 #define ARDUINO_PIN_24 GPIO_PIN(0, 13)
112 #define ARDUINO_PIN_25 GPIO_PIN(0, 14)
113 #define ARDUINO_PIN_26 GPIO_PIN(0, 15)
114 #define ARDUINO_PIN_27 GPIO_PIN(0, 16)
115 #define ARDUINO_PIN_28 GPIO_PIN(0, 17)
116 #define ARDUINO_PIN_29 GPIO_PIN(0, 18)
117 #define ARDUINO_PIN_30 GPIO_PIN(0, 19)
118 #define ARDUINO_PIN_31 GPIO_PIN(0, 20)
119 #define ARDUINO_PIN_32 GPIO_PIN(0, 21)
120 #define ARDUINO_PIN_33 GPIO_PIN(0, 22)
121 #define ARDUINO_PIN_34 GPIO_PIN(0, 23)
122 #define ARDUINO_PIN_35 GPIO_PIN(0, 24)
123 #define ARDUINO_PIN_36 GPIO_PIN(0, 25)
124 #define ARDUINO_PIN_37 GPIO_PIN(1, 0)
125 #define ARDUINO_PIN_38 GPIO_PIN(1, 9)
126 
127 /* P2 header on the nRF52840DK
128  * Note: This header only provides A0 - A5, but it should be two pins
129  * longer for full Arduino Mega compatibility */
130 #define ARDUINO_PIN_54 GPIO_PIN(0, 3)
131 #define ARDUINO_PIN_55 GPIO_PIN(0, 4)
132 #define ARDUINO_PIN_56 GPIO_PIN(0, 28)
133 #define ARDUINO_PIN_57 GPIO_PIN(0, 29)
134 #define ARDUINO_PIN_58 GPIO_PIN(0, 30)
135 #define ARDUINO_PIN_59 GPIO_PIN(0, 31)
136 
137 /* Note: There is no header for A8 - A15 present, which would be required
138  * for full Arduino Mega compatibility */
139 #define ARDUINO_PIN_LAST 59
146 #define ARDUINO_PIN_A0 ARDUINO_PIN_54
147 #define ARDUINO_PIN_A1 ARDUINO_PIN_55
148 #define ARDUINO_PIN_A2 ARDUINO_PIN_56
149 #define ARDUINO_PIN_A3 ARDUINO_PIN_57
150 #define ARDUINO_PIN_A4 ARDUINO_PIN_58
151 #define ARDUINO_PIN_A5 ARDUINO_PIN_59
158 /* The nRF52840 has a fixed ADC to GPIO mapping:
159  *
160  * nRF | MCU pin | Exposed as Arduino pin
161  * -----|-----------|-----------------------
162  * AIN0 | P0.02 | AREF
163  * AIN1 | P0.03 | A0 (D54)
164  * AIN2 | P0.04 | A1 (D55)
165  * AIN3 | P0.05 | - (D19)
166  * AIN4 | P0.28 | A2 (D56)
167  * AIN5 | P0.29 | A3 (D57)
168  * AIN6 | P0.30 | A4 (D48)
169  * AIN7 | P0.31 | A5 (D59)
170  */
171 #define ARDUINO_A0 ADC_LINE(1)
172 #define ARDUINO_A1 ADC_LINE(2)
173 #define ARDUINO_A2 ADC_LINE(4)
174 #define ARDUINO_A3 ADC_LINE(5)
175 #define ARDUINO_A4 ADC_LINE(6)
176 #define ARDUINO_A5 ADC_LINE(7)
177 
178 #define ARDUINO_ANALOG_PIN_LAST 5
181 #ifdef __cplusplus
182 }
183 #endif
184 
Low-level ADC peripheral driver interface definitions.
Low-level GPIO peripheral driver interface definitions.