sanguino/variants/standard/pins_arduino.h

changeset 2
b373b0288715
equal deleted inserted replaced
1:b584642d4f58 2:b373b0288715
1 /*
2 pins_arduino.h - Pin definition functions for Arduino
3 Part of Arduino - http://www.arduino.cc/
4
5 Copyright (c) 2007 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 $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23
24 Changelog
25 -----------
26 11/25/11 - ryan@ryanmsutton.com - Add pins for Sanguino 644P and 1284P
27 07/15/12 - ryan@ryanmsutton.com - Updated for arduino0101
28 */
29
30 #ifndef Pins_Arduino_h
31 #define Pins_Arduino_h
32
33 #include <avr/pgmspace.h>
34
35 #define NOT_A_PIN 0
36 #define NOT_A_PORT 0
37
38 #define NOT_ON_TIMER 0
39 #define TIMER0A 1
40 #define TIMER0B 2
41 #define TIMER1A 3
42 #define TIMER1B 4
43 #define TIMER2 5
44 #define TIMER2A 6
45 #define TIMER2B 7
46
47 #define TIMER3A 8
48 #define TIMER3B 9
49 #define TIMER3C 10
50 #define TIMER4A 11
51 #define TIMER4B 12
52 #define TIMER4C 13
53 #define TIMER5A 14
54 #define TIMER5B 15
55 #define TIMER5C 16
56
57 const static uint8_t SS = 4;
58 const static uint8_t MOSI = 5;
59 const static uint8_t MISO = 6;
60 const static uint8_t SCK = 7;
61
62 static const uint8_t SDA = 17;
63 static const uint8_t SCL = 16;
64 static const uint8_t LED_BUILTIN = 13;
65
66 static const uint8_t A0 = 31;
67 static const uint8_t A1 = 30;
68 static const uint8_t A2 = 29;
69 static const uint8_t A3 = 28;
70 static const uint8_t A4 = 27;
71 static const uint8_t A5 = 26;
72 static const uint8_t A6 = 25;
73 static const uint8_t A7 = 24;
74
75 // On the ATmega1280, the addresses of some of the port registers are
76 // greater than 255, so we can't store them in uint8_t's.
77 // extern const uint16_t PROGMEM port_to_mode_PGM[];
78 // extern const uint16_t PROGMEM port_to_input_PGM[];
79 // extern const uint16_t PROGMEM port_to_output_PGM[];
80
81 // extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
82 // extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
83 // extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
84 // extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
85
86 // ATMEL ATMEGA644P / SANGUINO
87 //
88 // +---\/---+
89 // INT0 (D 0) PB0 1| |40 PA0 (AI 0 / D31)
90 // INT1 (D 1) PB1 2| |39 PA1 (AI 1 / D30)
91 // INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
92 // PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
93 // PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
94 // MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
95 // MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
96 // SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
97 // RST 9| |32 AREF
98 // VCC 10| |31 GND
99 // GND 11| |30 AVCC
100 // XTAL2 12| |29 PC7 (D 23)
101 // XTAL1 13| |28 PC6 (D 22)
102 // RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
103 // TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
104 // RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
105 // TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
106 // PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
107 // PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
108 // PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
109 // +--------+
110 //
111 #define NUM_DIGITAL_PINS 24
112 #define NUM_ANALOG_INPUTS 8
113 #define analogInputToDigitalPin(p) ((p < 7) ? (p) + 24 : -1)
114
115 #define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 )
116
117 #define PA 1
118 #define PB 2
119 #define PC 3
120 #define PD 4
121 #define PE 5
122 #define PF 6
123 #define PG 7
124 #define PH 8
125 #define PJ 10
126 #define PK 11
127 #define PL 12
128
129 #ifdef ARDUINO_MAIN
130 // these arrays map port names (e.g. port B) to the
131 // appropriate addresses for various functions (e.g. reading
132 // and writing)
133 const uint16_t PROGMEM port_to_mode_PGM[] =
134 {
135 NOT_A_PORT,
136 (uint16_t) &DDRA,
137 (uint16_t) &DDRB,
138 (uint16_t) &DDRC,
139 (uint16_t) &DDRD,
140 };
141
142 const uint16_t PROGMEM port_to_output_PGM[] =
143 {
144 NOT_A_PORT,
145 (uint16_t) &PORTA,
146 (uint16_t) &PORTB,
147 (uint16_t) &PORTC,
148 (uint16_t) &PORTD,
149 };
150 const uint16_t PROGMEM port_to_input_PGM[] =
151 {
152 NOT_A_PORT,
153 (uint16_t) &PINA,
154 (uint16_t) &PINB,
155 (uint16_t) &PINC,
156 (uint16_t) &PIND,
157 };
158 const uint8_t PROGMEM digital_pin_to_port_PGM[] =
159 {
160 PB, /* 0 */
161 PB,
162 PB,
163 PB,
164 PB,
165 PB,
166 PB,
167 PB,
168 PD, /* 8 */
169 PD,
170 PD,
171 PD,
172 PD,
173 PD,
174 PD,
175 PD,
176 PC, /* 16 */
177 PC,
178 PC,
179 PC,
180 PC,
181 PC,
182 PC,
183 PC,
184 PA, /* 24 */
185 PA,
186 PA,
187 PA,
188 PA,
189 PA,
190 PA,
191 PA /* 31 */
192 };
193 const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
194 {
195 _BV(0), /* 0, port B */
196 _BV(1),
197 _BV(2),
198 _BV(3),
199 _BV(4),
200 _BV(5),
201 _BV(6),
202 _BV(7),
203 _BV(0), /* 8, port D */
204 _BV(1),
205 _BV(2),
206 _BV(3),
207 _BV(4),
208 _BV(5),
209 _BV(6),
210 _BV(7),
211 _BV(0), /* 16, port C */
212 _BV(1),
213 _BV(2),
214 _BV(3),
215 _BV(4),
216 _BV(5),
217 _BV(6),
218 _BV(7),
219 _BV(7), /* 24, port A */
220 _BV(6),
221 _BV(5),
222 _BV(4),
223 _BV(3),
224 _BV(2),
225 _BV(1),
226 _BV(0)
227 };
228 const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
229 {
230 NOT_ON_TIMER, /* 0 - PB0 */
231 NOT_ON_TIMER, /* 1 - PB1 */
232 NOT_ON_TIMER, /* 2 - PB2 */
233 TIMER0A, /* 3 - PB3 */
234 TIMER0B, /* 4 - PB4 */
235 NOT_ON_TIMER, /* 5 - PB5 */
236 NOT_ON_TIMER, /* 6 - PB6 */
237 NOT_ON_TIMER, /* 7 - PB7 */
238 NOT_ON_TIMER, /* 8 - PD0 */
239 NOT_ON_TIMER, /* 9 - PD1 */
240 NOT_ON_TIMER, /* 10 - PD2 */
241 NOT_ON_TIMER, /* 11 - PD3 */
242 TIMER1B, /* 12 - PD4 */
243 TIMER1A, /* 13 - PD5 */
244 TIMER2B, /* 14 - PD6 */
245 TIMER2A, /* 15 - PD7 */
246 NOT_ON_TIMER, /* 16 - PC0 */
247 NOT_ON_TIMER, /* 17 - PC1 */
248 NOT_ON_TIMER, /* 18 - PC2 */
249 NOT_ON_TIMER, /* 19 - PC3 */
250 NOT_ON_TIMER, /* 20 - PC4 */
251 NOT_ON_TIMER, /* 21 - PC5 */
252 NOT_ON_TIMER, /* 22 - PC6 */
253 NOT_ON_TIMER, /* 23 - PC7 */
254 NOT_ON_TIMER, /* 24 - PA0 */
255 NOT_ON_TIMER, /* 25 - PA1 */
256 NOT_ON_TIMER, /* 26 - PA2 */
257 NOT_ON_TIMER, /* 27 - PA3 */
258 NOT_ON_TIMER, /* 28 - PA4 */
259 NOT_ON_TIMER, /* 29 - PA5 */
260 NOT_ON_TIMER, /* 30 - PA6 */
261 NOT_ON_TIMER /* 31 - PA7 */
262 };
263 #endif
264 #endif

mercurial