Prusa MINI Firmware overview
fastio_644.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * Pin mapping for the 644, 644p, 644pa, and 1284p
26  *
27  * Logical Pin: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
28  * Port: B0 B1 B2 B3 B4 B5 B6 B7 D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 C2 C3 C4 C5 C6 C7 A7 A6 A5 A4 A3 A2 A1 A0
29  */
30 
31 /** ATMega644
32  *
33  * +---\/---+
34  * (D 0) PB0 1| |40 PA0 (AI 0 / D31)
35  * (D 1) PB1 2| |39 PA1 (AI 1 / D30)
36  * INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
37  * PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
38  * PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
39  * MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
40  * MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
41  * SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
42  * RST 9| |32 AREF
43  * VCC 10| |31 GND
44  * GND 11| |30 AVCC
45  * XTAL2 12| |29 PC7 (D 23)
46  * XTAL1 13| |28 PC6 (D 22)
47  * RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
48  * TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
49  * INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
50  * INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
51  * PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
52  * PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
53  * PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
54  * +--------+
55  */
56 
57 #include "../fastio.h"
58 
59 #define DEBUG_LED DIO0
60 
61 // UART
62 #define RXD DIO8
63 #define TXD DIO9
64 #define RXD0 DIO8
65 #define TXD0 DIO9
66 
67 #define RXD1 DIO10
68 #define TXD1 DIO11
69 
70 // SPI
71 #define SCK DIO7
72 #define MISO DIO6
73 #define MOSI DIO5
74 #define SS DIO4
75 
76 // TWI (I2C)
77 #define SCL DIO16
78 #define SDA DIO17
79 
80 // Timers and PWM
81 #define OC0A DIO3
82 #define OC0B DIO4
83 #define OC1A DIO13
84 #define OC1B DIO12
85 #define OC2A DIO15
86 #define OC2B DIO14
87 
88 // Digital I/O
89 
90 #define DIO0_PIN PINB0
91 #define DIO0_RPORT PINB
92 #define DIO0_WPORT PORTB
93 #define DIO0_DDR DDRB
94 #define DIO0_PWM nullptr
95 
96 #define DIO1_PIN PINB1
97 #define DIO1_RPORT PINB
98 #define DIO1_WPORT PORTB
99 #define DIO1_DDR DDRB
100 #define DIO1_PWM nullptr
101 
102 #define DIO2_PIN PINB2
103 #define DIO2_RPORT PINB
104 #define DIO2_WPORT PORTB
105 #define DIO2_DDR DDRB
106 #define DIO2_PWM nullptr
107 
108 #define DIO3_PIN PINB3
109 #define DIO3_RPORT PINB
110 #define DIO3_WPORT PORTB
111 #define DIO3_DDR DDRB
112 #define DIO3_PWM &OCR0A
113 
114 #define DIO4_PIN PINB4
115 #define DIO4_RPORT PINB
116 #define DIO4_WPORT PORTB
117 #define DIO4_DDR DDRB
118 #define DIO4_PWM &OCR0B
119 
120 #define DIO5_PIN PINB5
121 #define DIO5_RPORT PINB
122 #define DIO5_WPORT PORTB
123 #define DIO5_DDR DDRB
124 #define DIO5_PWM nullptr
125 
126 #define DIO6_PIN PINB6
127 #define DIO6_RPORT PINB
128 #define DIO6_WPORT PORTB
129 #define DIO6_DDR DDRB
130 #define DIO6_PWM nullptr
131 
132 #define DIO7_PIN PINB7
133 #define DIO7_RPORT PINB
134 #define DIO7_WPORT PORTB
135 #define DIO7_DDR DDRB
136 #define DIO7_PWM nullptr
137 
138 #define DIO8_PIN PIND0
139 #define DIO8_RPORT PIND
140 #define DIO8_WPORT PORTD
141 #define DIO8_DDR DDRD
142 #define DIO8_PWM nullptr
143 
144 #define DIO9_PIN PIND1
145 #define DIO9_RPORT PIND
146 #define DIO9_WPORT PORTD
147 #define DIO9_DDR DDRD
148 #define DIO9_PWM nullptr
149 
150 #define DIO10_PIN PIND2
151 #define DIO10_RPORT PIND
152 #define DIO10_WPORT PORTD
153 #define DIO10_DDR DDRD
154 #define DIO10_PWM nullptr
155 
156 #define DIO11_PIN PIND3
157 #define DIO11_RPORT PIND
158 #define DIO11_WPORT PORTD
159 #define DIO11_DDR DDRD
160 #define DIO11_PWM nullptr
161 
162 #define DIO12_PIN PIND4
163 #define DIO12_RPORT PIND
164 #define DIO12_WPORT PORTD
165 #define DIO12_DDR DDRD
166 #define DIO12_PWM &OCR1B
167 
168 #define DIO13_PIN PIND5
169 #define DIO13_RPORT PIND
170 #define DIO13_WPORT PORTD
171 #define DIO13_DDR DDRD
172 #define DIO13_PWM &OCR1A
173 
174 #define DIO14_PIN PIND6
175 #define DIO14_RPORT PIND
176 #define DIO14_WPORT PORTD
177 #define DIO14_DDR DDRD
178 #define DIO14_PWM &OCR2B
179 
180 #define DIO15_PIN PIND7
181 #define DIO15_RPORT PIND
182 #define DIO15_WPORT PORTD
183 #define DIO15_DDR DDRD
184 #define DIO15_PWM &OCR2A
185 
186 #define DIO16_PIN PINC0
187 #define DIO16_RPORT PINC
188 #define DIO16_WPORT PORTC
189 #define DIO16_DDR DDRC
190 #define DIO16_PWM nullptr
191 
192 #define DIO17_PIN PINC1
193 #define DIO17_RPORT PINC
194 #define DIO17_WPORT PORTC
195 #define DIO17_DDR DDRC
196 #define DIO17_PWM nullptr
197 
198 #define DIO18_PIN PINC2
199 #define DIO18_RPORT PINC
200 #define DIO18_WPORT PORTC
201 #define DIO18_DDR DDRC
202 #define DIO18_PWM nullptr
203 
204 #define DIO19_PIN PINC3
205 #define DIO19_RPORT PINC
206 #define DIO19_WPORT PORTC
207 #define DIO19_DDR DDRC
208 #define DIO19_PWM nullptr
209 
210 #define DIO20_PIN PINC4
211 #define DIO20_RPORT PINC
212 #define DIO20_WPORT PORTC
213 #define DIO20_DDR DDRC
214 #define DIO20_PWM nullptr
215 
216 #define DIO21_PIN PINC5
217 #define DIO21_RPORT PINC
218 #define DIO21_WPORT PORTC
219 #define DIO21_DDR DDRC
220 #define DIO21_PWM nullptr
221 
222 #define DIO22_PIN PINC6
223 #define DIO22_RPORT PINC
224 #define DIO22_WPORT PORTC
225 #define DIO22_DDR DDRC
226 #define DIO22_PWM nullptr
227 
228 #define DIO23_PIN PINC7
229 #define DIO23_RPORT PINC
230 #define DIO23_WPORT PORTC
231 #define DIO23_DDR DDRC
232 #define DIO23_PWM nullptr
233 
234 #define DIO24_PIN PINA7
235 #define DIO24_RPORT PINA
236 #define DIO24_WPORT PORTA
237 #define DIO24_DDR DDRA
238 #define DIO24_PWM nullptr
239 
240 #define DIO25_PIN PINA6
241 #define DIO25_RPORT PINA
242 #define DIO25_WPORT PORTA
243 #define DIO25_DDR DDRA
244 #define DIO25_PWM nullptr
245 
246 #define DIO26_PIN PINA5
247 #define DIO26_RPORT PINA
248 #define DIO26_WPORT PORTA
249 #define DIO26_DDR DDRA
250 #define DIO26_PWM nullptr
251 
252 #define DIO27_PIN PINA4
253 #define DIO27_RPORT PINA
254 #define DIO27_WPORT PORTA
255 #define DIO27_DDR DDRA
256 #define DIO27_PWM nullptr
257 
258 #define DIO28_PIN PINA3
259 #define DIO28_RPORT PINA
260 #define DIO28_WPORT PORTA
261 #define DIO28_DDR DDRA
262 #define DIO28_PWM nullptr
263 
264 #define DIO29_PIN PINA2
265 #define DIO29_RPORT PINA
266 #define DIO29_WPORT PORTA
267 #define DIO29_DDR DDRA
268 #define DIO29_PWM nullptr
269 
270 #define DIO30_PIN PINA1
271 #define DIO30_RPORT PINA
272 #define DIO30_WPORT PORTA
273 #define DIO30_DDR DDRA
274 #define DIO30_PWM nullptr
275 
276 #define DIO31_PIN PINA0
277 #define DIO31_RPORT PINA
278 #define DIO31_WPORT PORTA
279 #define DIO31_DDR DDRA
280 #define DIO31_PWM nullptr
281 
282 #define AIO0_PIN PINA0
283 #define AIO0_RPORT PINA
284 #define AIO0_WPORT PORTA
285 #define AIO0_DDR DDRA
286 #define AIO0_PWM nullptr
287 
288 #define AIO1_PIN PINA1
289 #define AIO1_RPORT PINA
290 #define AIO1_WPORT PORTA
291 #define AIO1_DDR DDRA
292 #define AIO1_PWM nullptr
293 
294 #define AIO2_PIN PINA2
295 #define AIO2_RPORT PINA
296 #define AIO2_WPORT PORTA
297 #define AIO2_DDR DDRA
298 #define AIO2_PWM nullptr
299 
300 #define AIO3_PIN PINA3
301 #define AIO3_RPORT PINA
302 #define AIO3_WPORT PORTA
303 #define AIO3_DDR DDRA
304 #define AIO3_PWM nullptr
305 
306 #define AIO4_PIN PINA4
307 #define AIO4_RPORT PINA
308 #define AIO4_WPORT PORTA
309 #define AIO4_DDR DDRA
310 #define AIO4_PWM nullptr
311 
312 #define AIO5_PIN PINA5
313 #define AIO5_RPORT PINA
314 #define AIO5_WPORT PORTA
315 #define AIO5_DDR DDRA
316 #define AIO5_PWM nullptr
317 
318 #define AIO6_PIN PINA6
319 #define AIO6_RPORT PINA
320 #define AIO6_WPORT PORTA
321 #define AIO6_DDR DDRA
322 #define AIO6_PWM nullptr
323 
324 #define AIO7_PIN PINA7
325 #define AIO7_RPORT PINA
326 #define AIO7_WPORT PORTA
327 #define AIO7_DDR DDRA
328 #define AIO7_PWM nullptr
329 
330 #undef PA0
331 #define PA0_PIN PINA0
332 #define PA0_RPORT PINA
333 #define PA0_WPORT PORTA
334 #define PA0_DDR DDRA
335 #define PA0_PWM nullptr
336 
337 #undef PA1
338 #define PA1_PIN PINA1
339 #define PA1_RPORT PINA
340 #define PA1_WPORT PORTA
341 #define PA1_DDR DDRA
342 #define PA1_PWM nullptr
343 
344 #undef PA2
345 #define PA2_PIN PINA2
346 #define PA2_RPORT PINA
347 #define PA2_WPORT PORTA
348 #define PA2_DDR DDRA
349 #define PA2_PWM nullptr
350 
351 #undef PA3
352 #define PA3_PIN PINA3
353 #define PA3_RPORT PINA
354 #define PA3_WPORT PORTA
355 #define PA3_DDR DDRA
356 #define PA3_PWM nullptr
357 
358 #undef PA4
359 #define PA4_PIN PINA4
360 #define PA4_RPORT PINA
361 #define PA4_WPORT PORTA
362 #define PA4_DDR DDRA
363 #define PA4_PWM nullptr
364 
365 #undef PA5
366 #define PA5_PIN PINA5
367 #define PA5_RPORT PINA
368 #define PA5_WPORT PORTA
369 #define PA5_DDR DDRA
370 #define PA5_PWM nullptr
371 
372 #undef PA6
373 #define PA6_PIN PINA6
374 #define PA6_RPORT PINA
375 #define PA6_WPORT PORTA
376 #define PA6_DDR DDRA
377 #define PA6_PWM nullptr
378 
379 #undef PA7
380 #define PA7_PIN PINA7
381 #define PA7_RPORT PINA
382 #define PA7_WPORT PORTA
383 #define PA7_DDR DDRA
384 #define PA7_PWM nullptr
385 
386 #undef PB0
387 #define PB0_PIN PINB0
388 #define PB0_RPORT PINB
389 #define PB0_WPORT PORTB
390 #define PB0_DDR DDRB
391 #define PB0_PWM nullptr
392 
393 #undef PB1
394 #define PB1_PIN PINB1
395 #define PB1_RPORT PINB
396 #define PB1_WPORT PORTB
397 #define PB1_DDR DDRB
398 #define PB1_PWM nullptr
399 
400 #undef PB2
401 #define PB2_PIN PINB2
402 #define PB2_RPORT PINB
403 #define PB2_WPORT PORTB
404 #define PB2_DDR DDRB
405 #define PB2_PWM nullptr
406 
407 #undef PB3
408 #define PB3_PIN PINB3
409 #define PB3_RPORT PINB
410 #define PB3_WPORT PORTB
411 #define PB3_DDR DDRB
412 #define PB3_PWM &OCR0A
413 
414 #undef PB4
415 #define PB4_PIN PINB4
416 #define PB4_RPORT PINB
417 #define PB4_WPORT PORTB
418 #define PB4_DDR DDRB
419 #define PB4_PWM &OCR0B
420 
421 #undef PB5
422 #define PB5_PIN PINB5
423 #define PB5_RPORT PINB
424 #define PB5_WPORT PORTB
425 #define PB5_DDR DDRB
426 #define PB5_PWM nullptr
427 
428 #undef PB6
429 #define PB6_PIN PINB6
430 #define PB6_RPORT PINB
431 #define PB6_WPORT PORTB
432 #define PB6_DDR DDRB
433 #define PB6_PWM nullptr
434 
435 #undef PB7
436 #define PB7_PIN PINB7
437 #define PB7_RPORT PINB
438 #define PB7_WPORT PORTB
439 #define PB7_DDR DDRB
440 #define PB7_PWM nullptr
441 
442 #undef PC0
443 #define PC0_PIN PINC0
444 #define PC0_RPORT PINC
445 #define PC0_WPORT PORTC
446 #define PC0_DDR DDRC
447 #define PC0_PWM nullptr
448 
449 #undef PC1
450 #define PC1_PIN PINC1
451 #define PC1_RPORT PINC
452 #define PC1_WPORT PORTC
453 #define PC1_DDR DDRC
454 #define PC1_PWM nullptr
455 
456 #undef PC2
457 #define PC2_PIN PINC2
458 #define PC2_RPORT PINC
459 #define PC2_WPORT PORTC
460 #define PC2_DDR DDRC
461 #define PC2_PWM nullptr
462 
463 #undef PC3
464 #define PC3_PIN PINC3
465 #define PC3_RPORT PINC
466 #define PC3_WPORT PORTC
467 #define PC3_DDR DDRC
468 #define PC3_PWM nullptr
469 
470 #undef PC4
471 #define PC4_PIN PINC4
472 #define PC4_RPORT PINC
473 #define PC4_WPORT PORTC
474 #define PC4_DDR DDRC
475 #define PC4_PWM nullptr
476 
477 #undef PC5
478 #define PC5_PIN PINC5
479 #define PC5_RPORT PINC
480 #define PC5_WPORT PORTC
481 #define PC5_DDR DDRC
482 #define PC5_PWM nullptr
483 
484 #undef PC6
485 #define PC6_PIN PINC6
486 #define PC6_RPORT PINC
487 #define PC6_WPORT PORTC
488 #define PC6_DDR DDRC
489 #define PC6_PWM nullptr
490 
491 #undef PC7
492 #define PC7_PIN PINC7
493 #define PC7_RPORT PINC
494 #define PC7_WPORT PORTC
495 #define PC7_DDR DDRC
496 #define PC7_PWM nullptr
497 
498 #undef PD0
499 #define PD0_PIN PIND0
500 #define PD0_RPORT PIND
501 #define PD0_WPORT PORTD
502 #define PD0_DDR DDRD
503 #define PD0_PWM nullptr
504 
505 #undef PD1
506 #define PD1_PIN PIND1
507 #define PD1_RPORT PIND
508 #define PD1_WPORT PORTD
509 #define PD1_DDR DDRD
510 #define PD1_PWM nullptr
511 
512 #undef PD2
513 #define PD2_PIN PIND2
514 #define PD2_RPORT PIND
515 #define PD2_WPORT PORTD
516 #define PD2_DDR DDRD
517 #define PD2_PWM nullptr
518 
519 #undef PD3
520 #define PD3_PIN PIND3
521 #define PD3_RPORT PIND
522 #define PD3_WPORT PORTD
523 #define PD3_DDR DDRD
524 #define PD3_PWM nullptr
525 
526 #undef PD4
527 #define PD4_PIN PIND4
528 #define PD4_RPORT PIND
529 #define PD4_WPORT PORTD
530 #define PD4_DDR DDRD
531 #define PD4_PWM nullptr
532 
533 #undef PD5
534 #define PD5_PIN PIND5
535 #define PD5_RPORT PIND
536 #define PD5_WPORT PORTD
537 #define PD5_DDR DDRD
538 #define PD5_PWM nullptr
539 
540 #undef PD6
541 #define PD6_PIN PIND6
542 #define PD6_RPORT PIND
543 #define PD6_WPORT PORTD
544 #define PD6_DDR DDRD
545 #define PD6_PWM &OCR2B
546 
547 #undef PD7
548 #define PD7_PIN PIND7
549 #define PD7_RPORT PIND
550 #define PD7_WPORT PORTD
551 #define PD7_DDR DDRD
552 #define PD7_PWM &OCR2A