diff options
author | Ryan <fauxpark@gmail.com> | 2021-08-18 18:20:25 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-18 18:20:25 +1000 |
commit | b16091659cc9a724a8800f77e631643b4ab089ad (patch) | |
tree | e44933472c6d100bd4fc5d8a693d9d21e3c32f6f /lib/usbhost/arduino-1.0.1/variants/leonardo/pins_arduino.h | |
parent | cf5e40c25139ff64ff246f1c6280e983ef75551c (diff) | |
download | qmk_firmware-b16091659cc9a724a8800f77e631643b4ab089ad.tar.gz qmk_firmware-b16091659cc9a724a8800f77e631643b4ab089ad.zip |
Move USB Host Shield and Arduino core to `lib/` (#13973)
Diffstat (limited to 'lib/usbhost/arduino-1.0.1/variants/leonardo/pins_arduino.h')
-rw-r--r-- | lib/usbhost/arduino-1.0.1/variants/leonardo/pins_arduino.h | 256 |
1 files changed, 256 insertions, 0 deletions
diff --git a/lib/usbhost/arduino-1.0.1/variants/leonardo/pins_arduino.h b/lib/usbhost/arduino-1.0.1/variants/leonardo/pins_arduino.h new file mode 100644 index 000000000..9f770d6ce --- /dev/null +++ b/lib/usbhost/arduino-1.0.1/variants/leonardo/pins_arduino.h | |||
@@ -0,0 +1,256 @@ | |||
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 | |||
25 | #ifndef Pins_Arduino_h | ||
26 | #define Pins_Arduino_h | ||
27 | |||
28 | #include <avr/pgmspace.h> | ||
29 | |||
30 | #define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0) | ||
31 | #define TXLED0 PORTD |= (1<<5) | ||
32 | #define TXLED1 PORTD &= ~(1<<5) | ||
33 | #define RXLED0 PORTB |= (1<<0) | ||
34 | #define RXLED1 PORTB &= ~(1<<0) | ||
35 | |||
36 | static const uint8_t SDA = 2; | ||
37 | static const uint8_t SCL = 3; | ||
38 | |||
39 | // Map SPI port to 'new' pins D14..D17 | ||
40 | static const uint8_t SS = 17; | ||
41 | static const uint8_t MOSI = 16; | ||
42 | static const uint8_t MISO = 14; | ||
43 | static const uint8_t SCK = 15; | ||
44 | |||
45 | // Mapping of analog pins as digital I/O | ||
46 | // A6-A11 share with digital pins | ||
47 | static const uint8_t A0 = 18; | ||
48 | static const uint8_t A1 = 19; | ||
49 | static const uint8_t A2 = 20; | ||
50 | static const uint8_t A3 = 21; | ||
51 | static const uint8_t A4 = 22; | ||
52 | static const uint8_t A5 = 23; | ||
53 | static const uint8_t A6 = 24; // D4 | ||
54 | static const uint8_t A7 = 25; // D6 | ||
55 | static const uint8_t A8 = 26; // D8 | ||
56 | static const uint8_t A9 = 27; // D9 | ||
57 | static const uint8_t A10 = 28; // D10 | ||
58 | static const uint8_t A11 = 29; // D12 | ||
59 | |||
60 | #define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) | ||
61 | #define digitalPinToPCICRbit(p) 0 | ||
62 | #define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) | ||
63 | #define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4)))))) | ||
64 | |||
65 | // __AVR_ATmega32U4__ has an unusual mapping of pins to channels | ||
66 | extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; | ||
67 | #define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) | ||
68 | |||
69 | #ifdef ARDUINO_MAIN | ||
70 | |||
71 | // On the Arduino board, digital pins are also used | ||
72 | // for the analog output (software PWM). Analog input | ||
73 | // pins are a separate set. | ||
74 | |||
75 | // ATMEL ATMEGA32U4 / ARDUINO LEONARDO | ||
76 | // | ||
77 | // D0 PD2 RXD1/INT2 | ||
78 | // D1 PD3 TXD1/INT3 | ||
79 | // D2 PD1 SDA SDA/INT1 | ||
80 | // D3# PD0 PWM8/SCL OC0B/SCL/INT0 | ||
81 | // D4 A6 PD4 ADC8 | ||
82 | // D5# PC6 ??? OC3A/#OC4A | ||
83 | // D6# A7 PD7 FastPWM #OC4D/ADC10 | ||
84 | // D7 PE6 INT6/AIN0 | ||
85 | // | ||
86 | // D8 A8 PB4 ADC11/PCINT4 | ||
87 | // D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5 | ||
88 | // D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6 | ||
89 | // D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7 | ||
90 | // D12 A11 PD6 T1/#OC4D/ADC9 | ||
91 | // D13# PC7 PWM10 CLK0/OC4A | ||
92 | // | ||
93 | // A0 D18 PF7 ADC7 | ||
94 | // A1 D19 PF6 ADC6 | ||
95 | // A2 D20 PF5 ADC5 | ||
96 | // A3 D21 PF4 ADC4 | ||
97 | // A4 D22 PF1 ADC1 | ||
98 | // A5 D23 PF0 ADC0 | ||
99 | // | ||
100 | // New pins D14..D17 to map SPI port to digital pins | ||
101 | // | ||
102 | // MISO D14 PB3 MISO,PCINT3 | ||
103 | // SCK D15 PB1 SCK,PCINT1 | ||
104 | // MOSI D16 PB2 MOSI,PCINT2 | ||
105 | // SS D17 PB0 RXLED,SS/PCINT0 | ||
106 | // | ||
107 | // TXLED PD5 | ||
108 | // RXLED PB0 | ||
109 | // HWB PE2 HWB | ||
110 | |||
111 | // these arrays map port names (e.g. port B) to the | ||
112 | // appropriate addresses for various functions (e.g. reading | ||
113 | // and writing) | ||
114 | const uint16_t PROGMEM port_to_mode_PGM[] = { | ||
115 | NOT_A_PORT, | ||
116 | NOT_A_PORT, | ||
117 | (uint16_t) &DDRB, | ||
118 | (uint16_t) &DDRC, | ||
119 | (uint16_t) &DDRD, | ||
120 | (uint16_t) &DDRE, | ||
121 | (uint16_t) &DDRF, | ||
122 | }; | ||
123 | |||
124 | const uint16_t PROGMEM port_to_output_PGM[] = { | ||
125 | NOT_A_PORT, | ||
126 | NOT_A_PORT, | ||
127 | (uint16_t) &PORTB, | ||
128 | (uint16_t) &PORTC, | ||
129 | (uint16_t) &PORTD, | ||
130 | (uint16_t) &PORTE, | ||
131 | (uint16_t) &PORTF, | ||
132 | }; | ||
133 | |||
134 | const uint16_t PROGMEM port_to_input_PGM[] = { | ||
135 | NOT_A_PORT, | ||
136 | NOT_A_PORT, | ||
137 | (uint16_t) &PINB, | ||
138 | (uint16_t) &PINC, | ||
139 | (uint16_t) &PIND, | ||
140 | (uint16_t) &PINE, | ||
141 | (uint16_t) &PINF, | ||
142 | }; | ||
143 | |||
144 | const uint8_t PROGMEM digital_pin_to_port_PGM[30] = { | ||
145 | PD, // D0 - PD2 | ||
146 | PD, // D1 - PD3 | ||
147 | PD, // D2 - PD1 | ||
148 | PD, // D3 - PD0 | ||
149 | PD, // D4 - PD4 | ||
150 | PC, // D5 - PC6 | ||
151 | PD, // D6 - PD7 | ||
152 | PE, // D7 - PE6 | ||
153 | |||
154 | PB, // D8 - PB4 | ||
155 | PB, // D9 - PB5 | ||
156 | PB, // D10 - PB6 | ||
157 | PB, // D11 - PB7 | ||
158 | PD, // D12 - PD6 | ||
159 | PC, // D13 - PC7 | ||
160 | |||
161 | PB, // D14 - MISO - PB3 | ||
162 | PB, // D15 - SCK - PB1 | ||
163 | PB, // D16 - MOSI - PB2 | ||
164 | PB, // D17 - SS - PB0 | ||
165 | |||
166 | PF, // D18 - A0 - PF7 | ||
167 | PF, // D19 - A1 - PF6 | ||
168 | PF, // D20 - A2 - PF5 | ||
169 | PF, // D21 - A3 - PF4 | ||
170 | PF, // D22 - A4 - PF1 | ||
171 | PF, // D23 - A5 - PF0 | ||
172 | |||
173 | PD, // D24 / D4 - A6 - PD4 | ||
174 | PD, // D25 / D6 - A7 - PD7 | ||
175 | PB, // D26 / D8 - A8 - PB4 | ||
176 | PB, // D27 / D9 - A9 - PB5 | ||
177 | PB, // D28 / D10 - A10 - PB6 | ||
178 | PD, // D29 / D12 - A11 - PD6 | ||
179 | }; | ||
180 | |||
181 | const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[30] = { | ||
182 | _BV(2), // D0 - PD2 | ||
183 | _BV(3), // D1 - PD3 | ||
184 | _BV(1), // D2 - PD1 | ||
185 | _BV(0), // D3 - PD0 | ||
186 | _BV(4), // D4 - PD4 | ||
187 | _BV(6), // D5 - PC6 | ||
188 | _BV(7), // D6 - PD7 | ||
189 | _BV(6), // D7 - PE6 | ||
190 | |||
191 | _BV(4), // D8 - PB4 | ||
192 | _BV(5), // D9 - PB5 | ||
193 | _BV(6), // D10 - PB6 | ||
194 | _BV(7), // D11 - PB7 | ||
195 | _BV(6), // D12 - PD6 | ||
196 | _BV(7), // D13 - PC7 | ||
197 | |||
198 | _BV(3), // D14 - MISO - PB3 | ||
199 | _BV(1), // D15 - SCK - PB1 | ||
200 | _BV(2), // D16 - MOSI - PB2 | ||
201 | _BV(0), // D17 - SS - PB0 | ||
202 | |||
203 | _BV(7), // D18 - A0 - PF7 | ||
204 | _BV(6), // D19 - A1 - PF6 | ||
205 | _BV(5), // D20 - A2 - PF5 | ||
206 | _BV(4), // D21 - A3 - PF4 | ||
207 | _BV(1), // D22 - A4 - PF1 | ||
208 | _BV(0), // D23 - A5 - PF0 | ||
209 | |||
210 | _BV(4), // D24 / D4 - A6 - PD4 | ||
211 | _BV(7), // D25 / D6 - A7 - PD7 | ||
212 | _BV(4), // D26 / D8 - A8 - PB4 | ||
213 | _BV(5), // D27 / D9 - A9 - PB5 | ||
214 | _BV(6), // D28 / D10 - A10 - PB6 | ||
215 | _BV(6), // D29 / D12 - A11 - PD6 | ||
216 | }; | ||
217 | |||
218 | const uint8_t PROGMEM digital_pin_to_timer_PGM[16] = { | ||
219 | NOT_ON_TIMER, | ||
220 | NOT_ON_TIMER, | ||
221 | NOT_ON_TIMER, | ||
222 | TIMER0B, /* 3 */ | ||
223 | NOT_ON_TIMER, | ||
224 | TIMER3A, /* 5 */ | ||
225 | TIMER4D, /* 6 */ | ||
226 | NOT_ON_TIMER, | ||
227 | |||
228 | NOT_ON_TIMER, | ||
229 | TIMER1A, /* 9 */ | ||
230 | TIMER1B, /* 10 */ | ||
231 | TIMER0A, /* 11 */ | ||
232 | |||
233 | NOT_ON_TIMER, | ||
234 | TIMER4A, /* 13 */ | ||
235 | |||
236 | NOT_ON_TIMER, | ||
237 | NOT_ON_TIMER, | ||
238 | }; | ||
239 | |||
240 | const uint8_t PROGMEM analog_pin_to_channel_PGM[12] = { | ||
241 | 7, // A0 PF7 ADC7 | ||
242 | 6, // A1 PF6 ADC6 | ||
243 | 5, // A2 PF5 ADC5 | ||
244 | 4, // A3 PF4 ADC4 | ||
245 | 1, // A4 PF1 ADC1 | ||
246 | 0, // A5 PF0 ADC0 | ||
247 | 8, // A6 D4 PD4 ADC8 | ||
248 | 10, // A7 D6 PD7 ADC10 | ||
249 | 11, // A8 D8 PB4 ADC11 | ||
250 | 12, // A9 D9 PB5 ADC12 | ||
251 | 13, // A10 D10 PB6 ADC13 | ||
252 | 9 // A11 D12 PD6 ADC9 | ||
253 | }; | ||
254 | |||
255 | #endif /* ARDUINO_MAIN */ | ||
256 | #endif /* Pins_Arduino_h */ | ||