arduino_board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freie Universität Berlin
3  * 2017 Thomas Perrot <thomas.perrot@tupi.fr>
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
22 #ifndef ARDUINO_BOARD_H
23 #define ARDUINO_BOARD_H
24 
25 #include "arduino_pinmap.h"
26 #include "periph/pwm.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 #define ARDUINO_LED (13)
36 
40 static const gpio_t arduino_pinmap[] = {
41  ARDUINO_PIN_0,
42  ARDUINO_PIN_1,
43  ARDUINO_PIN_2,
44  ARDUINO_PIN_3,
45  ARDUINO_PIN_4,
46  ARDUINO_PIN_5,
47  ARDUINO_PIN_6,
48  ARDUINO_PIN_7,
49  ARDUINO_PIN_8,
50  ARDUINO_PIN_9,
51  ARDUINO_PIN_10,
52  ARDUINO_PIN_11,
53  ARDUINO_PIN_12,
54  ARDUINO_PIN_13,
55  ARDUINO_PIN_14,
56  ARDUINO_PIN_15,
57  ARDUINO_PIN_16,
58  ARDUINO_PIN_17,
59  ARDUINO_PIN_18,
60  ARDUINO_PIN_19,
61 #if defined(CPU_ATMEGA2560) || defined(CPU_ATMEGA32U4)
62  ARDUINO_PIN_20,
63  ARDUINO_PIN_21,
64  ARDUINO_PIN_22,
65  ARDUINO_PIN_23,
66 #endif
67 #ifdef CPU_ATMEGA2560
68  ARDUINO_PIN_24,
69  ARDUINO_PIN_25,
70  ARDUINO_PIN_26,
71  ARDUINO_PIN_27,
72  ARDUINO_PIN_28,
73  ARDUINO_PIN_29,
74 #endif
75 #if defined(CPU_ATMEGA2560) || defined(CPU_ATMEGA32U4)
76  ARDUINO_PIN_30,
77 #endif
78 #ifdef CPU_ATMEGA2560
79  ARDUINO_PIN_31,
80  ARDUINO_PIN_32,
81  ARDUINO_PIN_33,
82  ARDUINO_PIN_34,
83  ARDUINO_PIN_35,
84  ARDUINO_PIN_36,
85  ARDUINO_PIN_37,
86  ARDUINO_PIN_38,
87  ARDUINO_PIN_39,
88  ARDUINO_PIN_40,
89  ARDUINO_PIN_41,
90  ARDUINO_PIN_42,
91  ARDUINO_PIN_43,
92  ARDUINO_PIN_44,
93  ARDUINO_PIN_45,
94  ARDUINO_PIN_46,
95  ARDUINO_PIN_47,
96  ARDUINO_PIN_48,
97  ARDUINO_PIN_49,
98  ARDUINO_PIN_50,
99  ARDUINO_PIN_51,
100  ARDUINO_PIN_52,
101  ARDUINO_PIN_53,
102  ARDUINO_PIN_54,
103  ARDUINO_PIN_55,
104  ARDUINO_PIN_56,
105  ARDUINO_PIN_57,
106  ARDUINO_PIN_58,
107  ARDUINO_PIN_59,
108  ARDUINO_PIN_60,
109  ARDUINO_PIN_61,
110  ARDUINO_PIN_62,
111  ARDUINO_PIN_63,
112  ARDUINO_PIN_64,
113  ARDUINO_PIN_65,
114  ARDUINO_PIN_66,
115  ARDUINO_PIN_67,
116  ARDUINO_PIN_68,
117  ARDUINO_PIN_69
118 #endif
119 };
120 
124 static const adc_t arduino_analog_map[] = {
125  ARDUINO_A0,
126  ARDUINO_A1,
127  ARDUINO_A2,
128  ARDUINO_A3,
129  ARDUINO_A4,
130  ARDUINO_A5,
131  ARDUINO_A6,
132  ARDUINO_A7,
133 #ifdef CPU_ATMEGA2560
134  ARDUINO_A8,
135  ARDUINO_A9,
136  ARDUINO_A10,
137  ARDUINO_A11,
138  ARDUINO_A12,
139  ARDUINO_A13,
140  ARDUINO_A14,
141  ARDUINO_A15,
142 #endif
143 };
144 
148 #define ARDUINO_PWM_FREQU (490U)
149 
153 static const arduino_pwm_t arduino_pwm_list[] = {
154 #if defined(CPU_ATMEGA2560)
155  { .pin = 13, .dev = PWM_DEV(0), .chan = 0 },
156  { .pin = 4, .dev = PWM_DEV(0), .chan = 1 },
157 #elif defined(CPU_ATMEGA32U4)
158  { .pin = 11, .dev = PWM_DEV(0), .chan = 0 },
159  { .pin = 3, .dev = PWM_DEV(0), .chan = 1 },
160 #else /* CPU_ATMEGA328p */
161  { .pin = 6, .dev = PWM_DEV(0), .chan = 0 },
162  { .pin = 5, .dev = PWM_DEV(0), .chan = 1 },
163 #endif
164 #if defined(CPU_ATMEGA2560)
165  { .pin = 10, .dev = PWM_DEV(1), .chan = 0 },
166  { .pin = 9, .dev = PWM_DEV(1), .chan = 1 },
167 #else /* CPU_ATMEGA328p */
168  { .pin = 11, .dev = PWM_DEV(1), .chan = 0 },
169  { .pin = 3, .dev = PWM_DEV(1), .chan = 1 },
170 #endif
171 };
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif /* ARDUINO_BOARD_H */
178 
arduino_pinmap.h
Mapping from MCU pins to Arduino pins for Arduino Atmega boards.
adc_t
unsigned int adc_t
Define default ADC type identifier.
Definition: adc.h:72
PWM_DEV
#define PWM_DEV(x)
Default PWM access macro.
Definition: pwm.h:78
arduino_analog_map
static const adc_t arduino_analog_map[]
Look-up table for the Arduino's analog pins.
Definition: arduino_board.h:124
arduino_pwm_list
static const arduino_pwm_t arduino_pwm_list[]
List of PWM GPIO mappings.
Definition: arduino_board.h:153
pwm.h
Low-level PWM peripheral driver interface definitions.
arduino_pinmap
static const gpio_t arduino_pinmap[]
Look-up table for the Arduino's digital pins.
Definition: arduino_board.h:40