Debian Codegraph @

variants/gemma/pins_arduino.h

raw
1 /*
2 pins_arduino.c - pin definitions for the Arduino board
3 Part of Arduino / Wiring Lite
4
5 Copyright (c) 2005 David A. Mellis
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General
18 Public License along with this library; if not, write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 Boston, MA 02111-1307 USA
21
22 Modified 28-08-2009 for attiny84 R.Wiersma
23 Modified 09-10-2009 for attiny45 A.Saporetti
24 */
25
26 #ifndef Pins_Arduino_h
27 #define Pins_Arduino_h
28
29 #include <avr/pgmspace.h>
30
31 // Defines to make D4 support PWM
32 // See for more info: http://forums.adafruit.com/viewtopic.php?f=52&t=43951
33 //#define TCCR1A GTCCR
34 //#define WGM10 PWM1B
35
36 // ATMEL ATTINY45 / ARDUINO
37 //
38 // +-\/-+
39 // Ain0 (D 5) PB5 1| |8 Vcc
40 // Ain3 (D 3) PB3 2| |7 PB2 (D 2) Ain1
41 // Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1
42 // GND 4| |5 PB0 (D 0) pwm0
43 // +----+
44
45 #define NUM_DIGITAL_PINS 3
46 #define NUM_ANALOG_INPUTS 1
47 #define LED_BUILTIN 1
48
49 #define PIN_A0 (6)
50 #define PIN_A1 (7)
51 #define PIN_A2 (8)
52 #define PIN_A3 (9)
53
54 static const uint8_t A0 = PIN_A0;
55 static const uint8_t A1 = PIN_A1;
56 static const uint8_t A2 = PIN_A2;
57 static const uint8_t A3 = PIN_A3;
58
59 #define digitalPinToPCICR(p) ( ((p) >= 0 && (p) <= 4) ? (&GIMSK) : ((uint8_t *)0) )
60 #define digitalPinToPCICRbit(p) ( PCIE )
61 #define digitalPinToPCMSK(p) ( ((p) <= 4) ? (&PCMSK) : ((uint8_t *)0) )
62 #define digitalPinToPCMSKbit(p) ( (p) )
63
64 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : NOT_AN_INTERRUPT)
65
66 #define analogPinToChannel(p) ( (p) < 6 ? (p) : (p) - 6 )
67
68 #define TCCR1A GTCCR
69
70 #ifdef ARDUINO_MAIN
71
72 void initVariant()
73 {
74 GTCCR |= (1 << PWM1B);
75 }
76
77 // these arrays map port names (e.g. port B) to the
78 // appropriate addresses for various functions (e.g. reading
79 // and writing) tiny45 only port B
80 const uint16_t PROGMEM port_to_mode_PGM[] = {
81 NOT_A_PORT,
82 NOT_A_PORT,
83 (uint16_t) &DDRB,
84 };
85
86 const uint16_t PROGMEM port_to_output_PGM[] = {
87 NOT_A_PORT,
88 NOT_A_PORT,
89 (uint16_t) &PORTB,
90 };
91
92 const uint16_t PROGMEM port_to_input_PGM[] = {
93 NOT_A_PIN,
94 NOT_A_PIN,
95 (uint16_t) &PINB,
96 };
97
98 const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
99 PB, /* 0 */
100 PB,
101 PB,
102 PB,
103 PB,
104 PB, // 5
105 PB, // A0
106 PB,
107 PB,
108 PB, // A4
109
110 };
111
112 const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
113 _BV(0), /* 0, port B */
114 _BV(1),
115 _BV(2),
116 _BV(3), /* 3 port B */
117 _BV(4),
118 _BV(5),
119 _BV(5),
120 _BV(2),
121 _BV(4),
122 _BV(3),
123 };
124
125 const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
126 TIMER0A, /* OC0A */
127 TIMER0B,
128 NOT_ON_TIMER,
129 NOT_ON_TIMER,
130 TIMER1B,
131 NOT_ON_TIMER,
132 NOT_ON_TIMER,
133 NOT_ON_TIMER,
134 NOT_ON_TIMER,
135 NOT_ON_TIMER,
136 };
137
138 #endif
139
140 #endif