1
1
/*
2
- pins_arduino.c - pin definitions for the Arduino board
3
- Part of Arduino / Wiring Lite
2
+ pins_arduino.h - Pin definition functions for Arduino
3
+ Part of Arduino - http://www.arduino.cc/
4
4
5
- Copyright (c) 2005 David A. Mellis
5
+ Copyright (c) 2007 David A. Mellis
6
6
7
7
This library is free software; you can redistribute it and/or
8
8
modify it under the terms of the GNU Lesser General Public
19
19
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
20
Boston, MA 02111-1307 USA
21
21
22
- $Id$
22
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23
23
*/
24
24
25
- #include <avr/io.h>
26
- #include "wiring_private.h"
27
- #include "pins_arduino.h"
25
+ #ifndef Pins_Arduino_h
26
+ #define Pins_Arduino_h
28
27
29
- // On the Arduino board, digital pins are also used
30
- // for the analog output (software PWM). Analog input
31
- // pins are a separate set.
28
+ #include <avr/pgmspace.h>
32
29
33
- // ATMEL ATMEGA8 & 168 / ARDUINO
34
- //
35
- // +-\/-+
36
- // PC6 1| |28 PC5 (AI 5)
37
- // (D 0) PD0 2| |27 PC4 (AI 4)
38
- // (D 1) PD1 3| |26 PC3 (AI 3)
39
- // (D 2) PD2 4| |25 PC2 (AI 2)
40
- // PWM+ (D 3) PD3 5| |24 PC1 (AI 1)
41
- // (D 4) PD4 6| |23 PC0 (AI 0)
42
- // VCC 7| |22 GND
43
- // GND 8| |21 AREF
44
- // PB6 9| |20 AVCC
45
- // PB7 10| |19 PB5 (D 13)
46
- // PWM+ (D 5) PD5 11| |18 PB4 (D 12)
47
- // PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
48
- // (D 7) PD7 13| |16 PB2 (D 10) PWM
49
- // (D 8) PB0 14| |15 PB1 (D 9) PWM
50
- // +----+
51
- //
52
- // (PWM+ indicates the additional PWM pins on the ATmega168.)
30
+ #define NUM_DIGITAL_PINS 70
31
+ #define NUM_ANALOG_INPUTS 16
32
+ #define analogInputToDigitalPin (p ) ((p < 16) ? (p) + 54 : -1)
33
+ #define digitalPinHasPWM (p ) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))
53
34
54
- // ATMEL ATMEGA1280 / ARDUINO
55
- //
56
- // 0-7 PE0-PE7 works
57
- // 8-13 PB0-PB5 works
58
- // 14-21 PA0-PA7 works
59
- // 22-29 PH0-PH7 works
60
- // 30-35 PG5-PG0 works
61
- // 36-43 PC7-PC0 works
62
- // 44-51 PJ7-PJ0 works
63
- // 52-59 PL7-PL0 works
64
- // 60-67 PD7-PD0 works
65
- // A0-A7 PF0-PF7
66
- // A8-A15 PK0-PK7
35
+ const static uint8_t SS = 53 ;
36
+ const static uint8_t MOSI = 51 ;
37
+ const static uint8_t MISO = 50 ;
38
+ const static uint8_t SCK = 52 ;
67
39
68
- #define PA 1
69
- #define PB 2
70
- #define PC 3
71
- #define PD 4
72
- #define PE 5
73
- #define PF 6
74
- #define PG 7
75
- #define PH 8
76
- #define PJ 10
77
- #define PK 11
78
- #define PL 12
40
+ const static uint8_t SDA = 20 ;
41
+ const static uint8_t SCL = 21 ;
42
+ const static uint8_t LED_BUILTIN = 13 ;
79
43
44
+ const static uint8_t A0 = 54 ;
45
+ const static uint8_t A1 = 55 ;
46
+ const static uint8_t A2 = 56 ;
47
+ const static uint8_t A3 = 57 ;
48
+ const static uint8_t A4 = 58 ;
49
+ const static uint8_t A5 = 59 ;
50
+ const static uint8_t A6 = 60 ;
51
+ const static uint8_t A7 = 61 ;
52
+ const static uint8_t A8 = 62 ;
53
+ const static uint8_t A9 = 63 ;
54
+ const static uint8_t A10 = 64 ;
55
+ const static uint8_t A11 = 65 ;
56
+ const static uint8_t A12 = 66 ;
57
+ const static uint8_t A13 = 67 ;
58
+ const static uint8_t A14 = 68 ;
59
+ const static uint8_t A15 = 69 ;
60
+
61
+ // A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
62
+ // Only pins available for RECEIVE (TRANSMIT can be on any pin):
63
+ // (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
64
+ // Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
65
+
66
+ #define digitalPinToPCICR (p ) ( (((p) >= 10) && ((p) <= 13)) || \
67
+ (((p) >= 50) && ((p) <= 53)) || \
68
+ (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
69
+
70
+ #define digitalPinToPCICRbit (p ) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
71
+ ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
72
+ 0 ) )
73
+
74
+ #define digitalPinToPCMSK (p ) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
75
+ ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
76
+ ((uint8_t *)0) ) )
77
+
78
+ #define digitalPinToPCMSKbit (p ) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
79
+ ( ((p) == 50) ? 3 : \
80
+ ( ((p) == 51) ? 2 : \
81
+ ( ((p) == 52) ? 1 : \
82
+ ( ((p) == 53) ? 0 : \
83
+ ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
84
+ 0 ) ) ) ) ) )
85
+
86
+ #ifdef ARDUINO_MAIN
80
87
81
- #if defined(__AVR_ATmega1280__ ) || defined(__AVR_ATmega2560__ )
82
88
const uint16_t PROGMEM port_to_mode_PGM [] = {
83
89
NOT_A_PORT ,
84
90
(uint16_t ) & DDRA ,
@@ -351,115 +357,7 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
351
357
NOT_ON_TIMER , // PK 6 ** 68 ** A14
352
358
NOT_ON_TIMER , // PK 7 ** 69 ** A15
353
359
};
354
- #else
355
- // these arrays map port names (e.g. port B) to the
356
- // appropriate addresses for various functions (e.g. reading
357
- // and writing)
358
- const uint16_t PROGMEM port_to_mode_PGM [] = {
359
- NOT_A_PORT ,
360
- NOT_A_PORT ,
361
- (uint16_t ) & DDRB ,
362
- (uint16_t ) & DDRC ,
363
- (uint16_t ) & DDRD ,
364
- };
365
-
366
- const uint16_t PROGMEM port_to_output_PGM [] = {
367
- NOT_A_PORT ,
368
- NOT_A_PORT ,
369
- (uint16_t ) & PORTB ,
370
- (uint16_t ) & PORTC ,
371
- (uint16_t ) & PORTD ,
372
- };
373
360
374
- const uint16_t PROGMEM port_to_input_PGM [] = {
375
- NOT_A_PORT ,
376
- NOT_A_PORT ,
377
- (uint16_t ) & PINB ,
378
- (uint16_t ) & PINC ,
379
- (uint16_t ) & PIND ,
380
- };
381
-
382
- const uint8_t PROGMEM digital_pin_to_port_PGM [] = {
383
- PD , /* 0 */
384
- PD ,
385
- PD ,
386
- PD ,
387
- PD ,
388
- PD ,
389
- PD ,
390
- PD ,
391
- PB , /* 8 */
392
- PB ,
393
- PB ,
394
- PB ,
395
- PB ,
396
- PB ,
397
- PC , /* 14 */
398
- PC ,
399
- PC ,
400
- PC ,
401
- PC ,
402
- PC ,
403
- };
404
-
405
- const uint8_t PROGMEM digital_pin_to_bit_mask_PGM [] = {
406
- _BV (0 ), /* 0, port D */
407
- _BV (1 ),
408
- _BV (2 ),
409
- _BV (3 ),
410
- _BV (4 ),
411
- _BV (5 ),
412
- _BV (6 ),
413
- _BV (7 ),
414
- _BV (0 ), /* 8, port B */
415
- _BV (1 ),
416
- _BV (2 ),
417
- _BV (3 ),
418
- _BV (4 ),
419
- _BV (5 ),
420
- _BV (0 ), /* 14, port C */
421
- _BV (1 ),
422
- _BV (2 ),
423
- _BV (3 ),
424
- _BV (4 ),
425
- _BV (5 ),
426
- };
427
-
428
- const uint8_t PROGMEM digital_pin_to_timer_PGM [] = {
429
- NOT_ON_TIMER , /* 0 - port D */
430
- NOT_ON_TIMER ,
431
- NOT_ON_TIMER ,
432
- // on the ATmega168, digital pin 3 has hardware pwm
433
- #if defined(__AVR_ATmega8__ )
434
- NOT_ON_TIMER ,
435
- #else
436
- TIMER2B ,
437
- #endif
438
- NOT_ON_TIMER ,
439
- // on the ATmega168, digital pins 5 and 6 have hardware pwm
440
- #if defined(__AVR_ATmega8__ )
441
- NOT_ON_TIMER ,
442
- NOT_ON_TIMER ,
443
- #else
444
- TIMER0B ,
445
- TIMER0A ,
446
- #endif
447
- NOT_ON_TIMER ,
448
- NOT_ON_TIMER , /* 8 - port B */
449
- TIMER1A ,
450
- TIMER1B ,
451
- #if defined(__AVR_ATmega8__ )
452
- TIMER2 ,
453
- #else
454
- TIMER2A ,
455
- #endif
456
- NOT_ON_TIMER ,
457
- NOT_ON_TIMER ,
458
- NOT_ON_TIMER ,
459
- NOT_ON_TIMER , /* 14 - port C */
460
- NOT_ON_TIMER ,
461
- NOT_ON_TIMER ,
462
- NOT_ON_TIMER ,
463
- NOT_ON_TIMER ,
464
- };
465
361
#endif
362
+
363
+ #endif
0 commit comments