]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/deltasplit75/pro_micro.h
Changed case of deltasplit75 to be lowercase.
[qmk_firmware.git] / keyboards / deltasplit75 / pro_micro.h
1 /*\r
2   pins_arduino.h - Pin definition functions for Arduino\r
3   Part of Arduino - http://www.arduino.cc/\r
4 \r
5   Copyright (c) 2007 David A. Mellis\r
6 \r
7   This library is free software; you can redistribute it and/or\r
8   modify it under the terms of the GNU Lesser General Public\r
9   License as published by the Free Software Foundation; either\r
10   version 2.1 of the License, or (at your option) any later version.\r
11 \r
12   This library is distributed in the hope that it will be useful,\r
13   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
15   Lesser General Public License for more details.\r
16 \r
17   You should have received a copy of the GNU Lesser General\r
18   Public License along with this library; if not, write to the\r
19   Free Software Foundation, Inc., 59 Temple Place, Suite 330,\r
20   Boston, MA  02111-1307  USA\r
21 \r
22   $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $\r
23 */\r
24 \r
25 #ifndef Pins_Arduino_h\r
26 #define Pins_Arduino_h\r
27 \r
28 #include <avr/pgmspace.h>\r
29 \r
30 // Workaround for wrong definitions in "iom32u4.h".\r
31 // This should be fixed in the AVR toolchain.\r
32 #undef UHCON\r
33 #undef UHINT\r
34 #undef UHIEN\r
35 #undef UHADDR\r
36 #undef UHFNUM\r
37 #undef UHFNUML\r
38 #undef UHFNUMH\r
39 #undef UHFLEN\r
40 #undef UPINRQX\r
41 #undef UPINTX\r
42 #undef UPNUM\r
43 #undef UPRST\r
44 #undef UPCONX\r
45 #undef UPCFG0X\r
46 #undef UPCFG1X\r
47 #undef UPSTAX\r
48 #undef UPCFG2X\r
49 #undef UPIENX\r
50 #undef UPDATX\r
51 #undef TCCR2A\r
52 #undef WGM20\r
53 #undef WGM21\r
54 #undef COM2B0\r
55 #undef COM2B1\r
56 #undef COM2A0\r
57 #undef COM2A1\r
58 #undef TCCR2B\r
59 #undef CS20\r
60 #undef CS21\r
61 #undef CS22\r
62 #undef WGM22\r
63 #undef FOC2B\r
64 #undef FOC2A\r
65 #undef TCNT2\r
66 #undef TCNT2_0\r
67 #undef TCNT2_1\r
68 #undef TCNT2_2\r
69 #undef TCNT2_3\r
70 #undef TCNT2_4\r
71 #undef TCNT2_5\r
72 #undef TCNT2_6\r
73 #undef TCNT2_7\r
74 #undef OCR2A\r
75 #undef OCR2_0\r
76 #undef OCR2_1\r
77 #undef OCR2_2\r
78 #undef OCR2_3\r
79 #undef OCR2_4\r
80 #undef OCR2_5\r
81 #undef OCR2_6\r
82 #undef OCR2_7\r
83 #undef OCR2B\r
84 #undef OCR2_0\r
85 #undef OCR2_1\r
86 #undef OCR2_2\r
87 #undef OCR2_3\r
88 #undef OCR2_4\r
89 #undef OCR2_5\r
90 #undef OCR2_6\r
91 #undef OCR2_7\r
92 \r
93 #define NUM_DIGITAL_PINS  30\r
94 #define NUM_ANALOG_INPUTS 12\r
95 \r
96 #define TX_RX_LED_INIT  DDRD |= (1<<5), DDRB |= (1<<0)\r
97 #define TXLED0          PORTD |= (1<<5)\r
98 #define TXLED1          PORTD &= ~(1<<5)\r
99 #define RXLED0          PORTB |= (1<<0)\r
100 #define RXLED1          PORTB &= ~(1<<0)\r
101 \r
102 static const uint8_t SDA = 2;\r
103 static const uint8_t SCL = 3;\r
104 #define LED_BUILTIN 13\r
105 \r
106 // Map SPI port to 'new' pins D14..D17\r
107 static const uint8_t SS   = 17;\r
108 static const uint8_t MOSI = 16;\r
109 static const uint8_t MISO = 14;\r
110 static const uint8_t SCK  = 15;\r
111 \r
112 // Mapping of analog pins as digital I/O\r
113 // A6-A11 share with digital pins\r
114 static const uint8_t ADC0 = 18;\r
115 static const uint8_t ADC1 = 19;\r
116 static const uint8_t ADC2 = 20;\r
117 static const uint8_t ADC3 = 21;\r
118 static const uint8_t ADC4 = 22;\r
119 static const uint8_t ADC5 = 23;\r
120 static const uint8_t ADC6 = 24;   // D4\r
121 static const uint8_t ADC7 = 25;   // D6\r
122 static const uint8_t ADC8 = 26;   // D8\r
123 static const uint8_t ADC9 = 27;   // D9\r
124 static const uint8_t ADC10 = 28;  // D10\r
125 static const uint8_t ADC11 = 29;  // D12\r
126 \r
127 #define digitalPinToPCICR(p)    ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))\r
128 #define digitalPinToPCICRbit(p) 0\r
129 #define digitalPinToPCMSK(p)    ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))\r
130 #define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))\r
131 \r
132 //  __AVR_ATmega32U4__ has an unusual mapping of pins to channels\r
133 extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];\r
134 #define analogPinToChannel(P)  ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )\r
135 \r
136 #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))\r
137 \r
138 #ifdef ARDUINO_MAIN\r
139 \r
140 // On the Arduino board, digital pins are also used\r
141 // for the analog output (software PWM).  Analog input\r
142 // pins are a separate set.\r
143 \r
144 // ATMEL ATMEGA32U4 / ARDUINO LEONARDO\r
145 //\r
146 // D0               PD2                 RXD1/INT2\r
147 // D1               PD3                 TXD1/INT3\r
148 // D2               PD1     SDA         SDA/INT1\r
149 // D3#              PD0     PWM8/SCL    OC0B/SCL/INT0\r
150 // D4       A6      PD4                 ADC8\r
151 // D5#              PC6     ???         OC3A/#OC4A\r
152 // D6#      A7      PD7     FastPWM     #OC4D/ADC10\r
153 // D7               PE6                 INT6/AIN0\r
154 //\r
155 // D8       A8      PB4                 ADC11/PCINT4\r
156 // D9#      A9      PB5     PWM16       OC1A/#OC4B/ADC12/PCINT5\r
157 // D10#     A10     PB6     PWM16       OC1B/0c4B/ADC13/PCINT6\r
158 // D11#             PB7     PWM8/16     0C0A/OC1C/#RTS/PCINT7\r
159 // D12      A11     PD6                 T1/#OC4D/ADC9\r
160 // D13#             PC7     PWM10       CLK0/OC4A\r
161 //\r
162 // A0       D18     PF7                 ADC7\r
163 // A1       D19     PF6                 ADC6\r
164 // A2       D20     PF5                 ADC5\r
165 // A3       D21     PF4                 ADC4\r
166 // A4       D22     PF1                 ADC1\r
167 // A5       D23     PF0                 ADC0\r
168 //\r
169 // New pins D14..D17 to map SPI port to digital pins\r
170 //\r
171 // MISO     D14     PB3                 MISO,PCINT3\r
172 // SCK      D15     PB1                 SCK,PCINT1\r
173 // MOSI     D16     PB2                 MOSI,PCINT2\r
174 // SS       D17     PB0                 RXLED,SS/PCINT0\r
175 //\r
176 // Connected LEDs on board for TX and RX\r
177 // TXLED    D24     PD5                 XCK1\r
178 // RXLED    D17     PB0\r
179 // HWB              PE2                 HWB\r
180 \r
181 // these arrays map port names (e.g. port B) to the\r
182 // appropriate addresses for various functions (e.g. reading\r
183 // and writing)\r
184 const uint16_t PROGMEM port_to_mode_PGM[] = {\r
185     NOT_A_PORT,\r
186     NOT_A_PORT,\r
187     (uint16_t) &DDRB,\r
188     (uint16_t) &DDRC,\r
189     (uint16_t) &DDRD,\r
190     (uint16_t) &DDRE,\r
191     (uint16_t) &DDRF,\r
192 };\r
193 \r
194 const uint16_t PROGMEM port_to_output_PGM[] = {\r
195     NOT_A_PORT,\r
196     NOT_A_PORT,\r
197     (uint16_t) &PORTB,\r
198     (uint16_t) &PORTC,\r
199     (uint16_t) &PORTD,\r
200     (uint16_t) &PORTE,\r
201     (uint16_t) &PORTF,\r
202 };\r
203 \r
204 const uint16_t PROGMEM port_to_input_PGM[] = {\r
205     NOT_A_PORT,\r
206     NOT_A_PORT,\r
207     (uint16_t) &PINB,\r
208     (uint16_t) &PINC,\r
209     (uint16_t) &PIND,\r
210     (uint16_t) &PINE,\r
211     (uint16_t) &PINF,\r
212 };\r
213 \r
214 const uint8_t PROGMEM digital_pin_to_port_PGM[] = {\r
215     PD, // D0 - PD2\r
216     PD, // D1 - PD3\r
217     PD, // D2 - PD1\r
218     PD, // D3 - PD0\r
219     PD, // D4 - PD4\r
220     PC, // D5 - PC6\r
221     PD, // D6 - PD7\r
222     PE, // D7 - PE6\r
223 \r
224     PB, // D8 - PB4\r
225     PB, // D9 - PB5\r
226     PB, // D10 - PB6\r
227     PB, // D11 - PB7\r
228     PD, // D12 - PD6\r
229     PC, // D13 - PC7\r
230 \r
231     PB, // D14 - MISO - PB3\r
232     PB, // D15 - SCK - PB1\r
233     PB, // D16 - MOSI - PB2\r
234     PB, // D17 - SS - PB0\r
235 \r
236     PF, // D18 - A0 - PF7\r
237     PF, // D19 - A1 - PF6\r
238     PF, // D20 - A2 - PF5\r
239     PF, // D21 - A3 - PF4\r
240     PF, // D22 - A4 - PF1\r
241     PF, // D23 - A5 - PF0\r
242 \r
243     PD, // D24 - PD5\r
244     PD, // D25 / D6 - A7 - PD7\r
245     PB, // D26 / D8 - A8 - PB4\r
246     PB, // D27 / D9 - A9 - PB5\r
247     PB, // D28 / D10 - A10 - PB6\r
248     PD, // D29 / D12 - A11 - PD6\r
249 };\r
250 \r
251 const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {\r
252     _BV(2), // D0 - PD2\r
253     _BV(3), // D1 - PD3\r
254     _BV(1), // D2 - PD1\r
255     _BV(0), // D3 - PD0\r
256     _BV(4), // D4 - PD4\r
257     _BV(6), // D5 - PC6\r
258     _BV(7), // D6 - PD7\r
259     _BV(6), // D7 - PE6\r
260 \r
261     _BV(4), // D8 - PB4\r
262     _BV(5), // D9 - PB5\r
263     _BV(6), // D10 - PB6\r
264     _BV(7), // D11 - PB7\r
265     _BV(6), // D12 - PD6\r
266     _BV(7), // D13 - PC7\r
267 \r
268     _BV(3), // D14 - MISO - PB3\r
269     _BV(1), // D15 - SCK - PB1\r
270     _BV(2), // D16 - MOSI - PB2\r
271     _BV(0), // D17 - SS - PB0\r
272 \r
273     _BV(7), // D18 - A0 - PF7\r
274     _BV(6), // D19 - A1 - PF6\r
275     _BV(5), // D20 - A2 - PF5\r
276     _BV(4), // D21 - A3 - PF4\r
277     _BV(1), // D22 - A4 - PF1\r
278     _BV(0), // D23 - A5 - PF0\r
279 \r
280     _BV(5), // D24 - PD5\r
281     _BV(7), // D25 / D6 - A7 - PD7\r
282     _BV(4), // D26 / D8 - A8 - PB4\r
283     _BV(5), // D27 / D9 - A9 - PB5\r
284     _BV(6), // D28 / D10 - A10 - PB6\r
285     _BV(6), // D29 / D12 - A11 - PD6\r
286 };\r
287 \r
288 const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {\r
289     NOT_ON_TIMER,\r
290     NOT_ON_TIMER,\r
291     NOT_ON_TIMER,\r
292     TIMER0B,        /* 3 */\r
293     NOT_ON_TIMER,\r
294     TIMER3A,        /* 5 */\r
295     TIMER4D,        /* 6 */\r
296     NOT_ON_TIMER,\r
297 \r
298     NOT_ON_TIMER,\r
299     TIMER1A,        /* 9 */\r
300     TIMER1B,        /* 10 */\r
301     TIMER0A,        /* 11 */\r
302 \r
303     NOT_ON_TIMER,\r
304     TIMER4A,        /* 13 */\r
305 \r
306     NOT_ON_TIMER,\r
307     NOT_ON_TIMER,\r
308     NOT_ON_TIMER,\r
309     NOT_ON_TIMER,\r
310     NOT_ON_TIMER,\r
311     NOT_ON_TIMER,\r
312 \r
313     NOT_ON_TIMER,\r
314     NOT_ON_TIMER,\r
315     NOT_ON_TIMER,\r
316     NOT_ON_TIMER,\r
317     NOT_ON_TIMER,\r
318     NOT_ON_TIMER,\r
319     NOT_ON_TIMER,\r
320     NOT_ON_TIMER,\r
321     NOT_ON_TIMER,\r
322     NOT_ON_TIMER,\r
323 };\r
324 \r
325 const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {\r
326     7,  // A0               PF7                 ADC7\r
327     6,  // A1               PF6                 ADC6\r
328     5,  // A2               PF5                 ADC5\r
329     4,  // A3               PF4                 ADC4\r
330     1,  // A4               PF1                 ADC1\r
331     0,  // A5               PF0                 ADC0\r
332     8,  // A6       D4      PD4                 ADC8\r
333     10, // A7       D6      PD7                 ADC10\r
334     11, // A8       D8      PB4                 ADC11\r
335     12, // A9       D9      PB5                 ADC12\r
336     13, // A10      D10     PB6                 ADC13\r
337     9   // A11      D12     PD6                 ADC9\r
338 };\r
339 \r
340 #endif /* ARDUINO_MAIN */\r
341 \r
342 // These serial port names are intended to allow libraries and architecture-neutral\r
343 // sketches to automatically default to the correct port name for a particular type\r
344 // of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,\r
345 // the first hardware serial port whose RX/TX pins are not dedicated to another use.\r
346 //\r
347 // SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor\r
348 //\r
349 // SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial\r
350 //\r
351 // SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library\r
352 //\r
353 // SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.\r
354 //\r
355 // SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX\r
356 //                            pins are NOT connected to anything by default.\r
357 #define SERIAL_PORT_MONITOR        Serial\r
358 #define SERIAL_PORT_USBVIRTUAL     Serial\r
359 #define SERIAL_PORT_HARDWARE       Serial1\r
360 #define SERIAL_PORT_HARDWARE_OPEN  Serial1\r
361 \r
362 #endif /* Pins_Arduino_h */\r