-
Notifications
You must be signed in to change notification settings - Fork 1
/
pins_arduino.h
274 lines (236 loc) · 6.7 KB
/
pins_arduino.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <avr/pgmspace.h>
/*
MIGHTYCORE STANDARD PINOUT
ATmega8535, ATmega16, ATmega32, ATmega164,
ATmega324, ATmega644, ATmega1284
+---\/---+
LED (D 0) PB0 1| |40 PA0 (A 0 / D24)
(D 1) PB1 2| |39 PA1 (A 1 / D25)
INT2 (D 2) PB2 3| |38 PA2 (A 2 / D26)
PWM (D 3) PB3 4| |37 PA3 (A 3 / D27)
PWM* /SS (D 4) PB4 5| |36 PA4 (A 4 / D28)
MOSI (D 5) PB5 6| |35 PA5 (A 5 / D29)
PWM** /MISO (D 6) PB6 7| |34 PA6 (A 6 / D30)
PWM** /SCK (D 7) PB7 8| |33 PA7 (A 7 / D31)
RST 9| |32 AREF
VCC 10| |31 GND
GND 11| |30 AVCC
XTAL2 12| |29 PC7 (D 23)
XTAL1 13| |28 PC6 (D 22)
RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
(RX1)/INT0 (D 10) PD2 16| |25 PC3 (D 19) TMS
(TX1)/INT1 (D 11) PD3 17| |24 PC2 (D 18) TCK
PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
PWM* (D 14) PD6 20| |21 PD7 (D 15) PWM
+--------+
PWM: ATmega8535/16/32/164/324/644/1284
PWM*: ATmega164/324/644/1284
PWM**: ATmega1284
PCINT ONLY ON ATmega164/324/644/1284
PCINT15-8: D7-0 : bit 1
PCINT31-24: D15-8 : bit 3
PCINT23-16: D23-16 : bit 2
PCINT7-0: D31-24 : bit 0
*/
#define STANDARD_PINOUT
#define NUM_DIGITAL_PINS 32
#define NUM_ANALOG_INPUTS 8
#define analogInputToDigitalPin(p) ((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1)
#define analogPinToChannel(p) ((p) < NUM_ANALOG_INPUTS ? (p) : (p) >= 24 ? (p) - 24 : -1)
#define digitalPinToInterrupt(p) ((p) == 2 ? 2 : ((p) == 10 ? 0 : ((p) == 11 ? 1 : NOT_AN_INTERRUPT)))
#if defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__)
#define digitalPinHasPWM(p) ((p) == 3 || (p) == 12 || (p) == 13 || (p) == 15)
#elif defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324A__) || \
defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644__) || \
defined(__AVR_ATmega644P__)
#define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15)
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
#define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 6 || (p) == 7 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15)
#endif
static const uint8_t LED = 0;
#define LED_BUILTIN 0
static const uint8_t SS = 4;
static const uint8_t MOSI = 5;
static const uint8_t MISO = 6;
static const uint8_t SCK = 7;
static const uint8_t SDA = 17;
static const uint8_t SCL = 16;
static const uint8_t A0 = 24;
static const uint8_t A1 = 25;
static const uint8_t A2 = 26;
static const uint8_t A3 = 27;
static const uint8_t A4 = 28;
static const uint8_t A5 = 29;
static const uint8_t A6 = 30;
static const uint8_t A7 = 31;
#if defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324A__) || \
defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644__) || \
defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
#define digitalPinToPCICR(p) (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
#define digitalPinToPCICRbit(p) ( (p) <= 7 ? 1 : (p) <= 15 ? 3 : (p) <= 23 ? 2 : 0 )
#define digitalPinToPCMSK(p) ( (p) <= 7 ? &PCMSK1 : (p) <= 15 ? &PCMSK3 : (p) <= 23 ? &PCMSK2 : &PCMSK0 )
#define digitalPinToPCMSKbit(p) ((p) % 8)
#endif
#if defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324A__) || \
defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__)
/**** Needed to get the SD library to work.
Missing definitions in the iom164.h/iom324.h file ****/
#define SPR0 0
#define SPR1 1
#define CPHA 2
#define CPOL 3
#define MSTR 4
#define DORD 5
#define SPE 6
#define SPIE 7
#define SPSR _SFR_IO8(0x2D)
#define SPI2X 0
#define WCOL 6
#define SPIF 7
#define SPCR _SFR_IO8(0x2C)
#define SPDR _SFR_IO8(0x2E)
#endif
#ifdef ARDUINO_MAIN
#define PA 1
#define PB 2
#define PC 3
#define PD 4
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
(uint16_t) &DDRA,
(uint16_t) &DDRB,
(uint16_t) &DDRC,
(uint16_t) &DDRD,
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
(uint16_t) &PORTA,
(uint16_t) &PORTB,
(uint16_t) &PORTC,
(uint16_t) &PORTD,
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
(uint16_t) &PINA,
(uint16_t) &PINB,
(uint16_t) &PINC,
(uint16_t) &PIND,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PB, /* D0 */
PB,
PB,
PB,
PB,
PB,
PB,
PB,
PD, /* D8 */
PD,
PD,
PD,
PD,
PD,
PD,
PD,
PC, /* D16 */
PC,
PC,
PC,
PC,
PC,
PC,
PC,
PA, /* D24 */
PA,
PA,
PA,
PA,
PA,
PA,
PA /* D31 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* D0, port B */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(0), /* D8, port D */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(0), /* D16, port C */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(0), /* D24, port A */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7)
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* D0 - PB0 */
NOT_ON_TIMER, /* D1 - PB1 */
NOT_ON_TIMER, /* D2 - PB2 */
NOT_ON_TIMER, /* D3 - PB3 */
NOT_ON_TIMER, /* D4 - PB4 */
NOT_ON_TIMER, /* D5 - PB5 */
NOT_ON_TIMER, /* D6 - PB6 */
NOT_ON_TIMER, /* D7 - PB7 */
NOT_ON_TIMER, /* D8 - PD0 */
NOT_ON_TIMER, /* D9 - PD1 */
NOT_ON_TIMER, /* D10 - PD2 */
NOT_ON_TIMER, /* D11 - PD3 */
NOT_ON_TIMER, /* D12 - PD4 */
NOT_ON_TIMER, /* D13 - PD5 */
NOT_ON_TIMER, /* D14 - PD6 */
NOT_ON_TIMER, /* D15 - PD7 */
NOT_ON_TIMER, /* D16 - PC0 */
NOT_ON_TIMER, /* D17 - PC1 */
NOT_ON_TIMER, /* D18 - PC2 */
NOT_ON_TIMER, /* D19 - PC3 */
NOT_ON_TIMER, /* D20 - PC4 */
NOT_ON_TIMER, /* D21 - PC5 */
NOT_ON_TIMER, /* D22 - PC6 */
NOT_ON_TIMER, /* D23 - PC7 */
NOT_ON_TIMER, /* D24 - PA0 */
NOT_ON_TIMER, /* D25 - PA1 */
NOT_ON_TIMER, /* D26 - PA2 */
NOT_ON_TIMER, /* D27 - PA3 */
NOT_ON_TIMER, /* D28 - PA4 */
NOT_ON_TIMER, /* D29 - PA5 */
NOT_ON_TIMER, /* D30 - PA6 */
NOT_ON_TIMER /* D31 - PA7 */
};
#endif // ARDUINO_MAIN
#endif // Pins_Arduino_h
// vim:ai:cin:sts=2 sw=2 ft=cpp