]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/protocol/usb_hid/arduino-1.8.13/variants/robot_motor/pins_arduino.h
usb_hid: Update arduino cores to 1.8.13
[max/tmk_keyboard.git] / tmk_core / protocol / usb_hid / arduino-1.8.13 / variants / robot_motor / pins_arduino.h
1 /*
2   pins_arduino.h - Pin definition functions for Arduino Robot Control Board
3   Part of Arduino - http://www.arduino.cc/
4
5   Copyright (c) 2913 D. Cuartielles, X. Yang (Arduino Verkstad)
6   Copyright (c) 2012 D. Cuartielles, N. de la Riva, I. Gallego, E. Gallego
7
8   This library is free software; you can redistribute it and/or
9   modify it under the terms of the GNU Lesser General Public
10   License as published by the Free Software Foundation; either
11   version 2.1 of the License, or (at your option) any later version.
12
13   This library is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General
19   Public License along with this library; if not, write to the
20   Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21   Boston, MA  02111-1307  USA
22 */
23
24 #ifndef Pins_Arduino_h
25 #define Pins_Arduino_h
26
27 #include <avr/pgmspace.h>
28
29 #define ARDUINO_MODEL_USB_PID   0x0039
30
31 #define TX_RX_LED_INIT  DDRD |= (1<<5), DDRB |= (1<<0)
32 #define TXLED0                  PORTD |= (1<<5)
33 #define TXLED1                  PORTD &= ~(1<<5)
34 #define RXLED0                  PORTB |= (1<<0)
35 #define RXLED1                  PORTB &= ~(1<<0)
36
37 #define D10 TK1
38 #define D9 TK2
39 #define D8 TK4
40 #define D7 TK3
41
42 #define PIN_SERIAL_RX       (0)
43 #define PIN_SERIAL_TX       (1)
44
45 static const uint8_t RX  = PIN_SERIAL_RX;
46 static const uint8_t TX  = PIN_SERIAL_TX;
47
48 #define PIN_WIRE_SDA        (2)
49 #define PIN_WIRE_SCL        (3)
50
51 static const uint8_t SDA = PIN_WIRE_SDA;
52 static const uint8_t SCL = PIN_WIRE_SCL;
53
54 // Map SPI port to 'new' pins D14..D17
55 #define PIN_SPI_SS    (17)
56 #define PIN_SPI_MOSI  (16)
57 #define PIN_SPI_MISO  (14)
58 #define PIN_SPI_SCK   (15)
59
60 static const uint8_t SS   = PIN_SPI_SS;
61 static const uint8_t MOSI = PIN_SPI_MOSI;
62 static const uint8_t MISO = PIN_SPI_MISO;
63 static const uint8_t SCK  = PIN_SPI_SCK;
64
65 // Mapping of analog pins as digital I/O
66 // A6-A11 share with digital pins
67 #define PIN_A0   (18)
68 #define PIN_A1   (19)
69 #define PIN_A2   (20)
70 #define PIN_A3   (21)
71 #define PIN_A4   (22)
72 #define PIN_A5   (23)
73 #define PIN_A6   (24)
74 #define PIN_A7   (25)
75 #define PIN_A8   (26)
76 #define PIN_A9   (27)
77 #define PIN_A10  (28)
78 #define PIN_A11  (29)
79
80 static const uint8_t A0 = PIN_A0;
81 static const uint8_t A1 = PIN_A1;
82 static const uint8_t A2 = PIN_A2;
83 static const uint8_t A3 = PIN_A3;
84 static const uint8_t A4 = PIN_A4;
85 static const uint8_t A5 = PIN_A5;
86 static const uint8_t A6 = PIN_A6;       // D4
87 static const uint8_t A7 = PIN_A7;       // D6
88 static const uint8_t A8 = PIN_A8;       // D8
89 static const uint8_t A9 = PIN_A9;       // D9
90 static const uint8_t A10 = PIN_A10;     // D10
91 static const uint8_t A11 = PIN_A11;     // D12
92
93 // Specific Mapping for the Motor Board
94 static const uint8_t MUX_IN = 20;       // A2
95 static const uint8_t MUXA = 7;          // D7
96 static const uint8_t MUXB = 8;          // D8
97 static const uint8_t MUXC = 11;         // D11
98 static const uint8_t MUXI = 13;         // D13
99 static const uint8_t TRIM = 21;         // A3
100 static const uint8_t SENSE_A = 22;      // A4
101 static const uint8_t SENSE_B = 23;      // A5
102 static const uint8_t IN_A1 = 6;         // D6 - A7
103 static const uint8_t IN_A2 = 5;         // D5
104 static const uint8_t IN_B1 = 10;        // D10
105 static const uint8_t IN_B2 = 9;         // D9
106 static const uint8_t TK1 = 18;          // A0
107 static const uint8_t TK2 = 19;          // A1
108 static const uint8_t TK3 = 4;           // A6
109 static const uint8_t TK4 = 12;          // A11
110
111 //      __AVR_ATmega32U4__ has an unusual mapping of pins to channels
112 extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
113 #define analogPinToChannel(P)  ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
114
115 #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
116
117 #ifdef ARDUINO_MAIN
118
119 // On the Arduino board, digital pins are also used
120 // for the analog output (software PWM).  Analog input
121 // pins are a separate set.
122
123 // ARDUINO LEONARDO / ARDUINO ROBOT CONTROL / ATMEGA 32U4 / FUNCTION / REGISTER 
124 //
125 // D0           RX                                      PD2             RX                      RXD1/INT2
126 // D1           TX                                      PD3             TX                      TXD1/INT3
127 // D2           SDA                                     PD1             SDA                     SDA/INT1
128 // D3#          SCL                                     PD0             PWM8/SCL        OC0B/SCL/INT0
129 // D4           TK3                     A6              PD4                                     ADC8
130 // D5#          INA2                            PC6             ???                     OC3A/#OC4A
131 // D6#          INA1            A7              PD7             FastPWM         #OC4D/ADC10
132 // D7           MUXA                            PE6                                     INT6/AIN0
133 //
134 // D8           MUXB            A8              PB4                                     ADC11/PCINT4
135 // D9#          INB2            A9              PB5             PWM16           OC1A/#OC4B/ADC12/PCINT5
136 // D10#         INB1            A10             PB6             PWM16           OC1B/0c4B/ADC13/PCINT6
137 // D11#         MUXC                            PB7             PWM8/16         0C0A/OC1C/#RTS/PCINT7
138 // D12          TK4                     A11             PD6                                     T1/#OC4D/ADC9
139 // D13#         MUXI                            PC7             PWM10           CLK0/OC4A
140 //
141 // A0           TK1                     D18             PF7                                     ADC7
142 // A1           TK2                     D19             PF6                                     ADC6
143 // A2           MUX_IN          D20     PF5                                     ADC5
144 // A3           TRIM            D21     PF4                                     ADC4
145 // A4           SENSE_A         D22             PF1                                     ADC1
146 // A5           SENSE_B         D23     PF0                                     ADC0
147 //
148 // MISO         MISO            D14             PB3                                     MISO,PCINT3
149 // SCK          SCK                     D15             PB1                                     SCK,PCINT1
150 // MOSI         MOSI            D16             PB2                                     MOSI,PCINT2
151 // SS           RX_LED          D17             PB0                                     RXLED,SS/PCINT0
152 //
153 // TXLED        TX_LED          PD5
154 // HWB                                  PE2                                     HWB
155
156 // these arrays map port names (e.g. port B) to the
157 // appropriate addresses for various functions (e.g. reading
158 // and writing)
159 const uint16_t PROGMEM port_to_mode_PGM[] = {
160         NOT_A_PORT,
161         NOT_A_PORT,
162         (uint16_t) &DDRB,
163         (uint16_t) &DDRC,
164         (uint16_t) &DDRD,
165         (uint16_t) &DDRE,
166         (uint16_t) &DDRF,
167 };
168
169 const uint16_t PROGMEM port_to_output_PGM[] = {
170         NOT_A_PORT,
171         NOT_A_PORT,
172         (uint16_t) &PORTB,
173         (uint16_t) &PORTC,
174         (uint16_t) &PORTD,
175         (uint16_t) &PORTE,
176         (uint16_t) &PORTF,
177 };
178
179 const uint16_t PROGMEM port_to_input_PGM[] = {
180         NOT_A_PORT,
181         NOT_A_PORT,
182         (uint16_t) &PINB,
183         (uint16_t) &PINC,
184         (uint16_t) &PIND,
185         (uint16_t) &PINE,
186         (uint16_t) &PINF,
187 };
188
189 const uint8_t PROGMEM digital_pin_to_port_PGM[30] = {
190         PD, // D0 - PD2
191         PD,     // D1 - PD3
192         PD, // D2 - PD1
193         PD,     // D3 - PD0
194         PD,     // D4 - PD4
195         PC, // D5 - PC6
196         PD, // D6 - PD7
197         PE, // D7 - PE6
198         
199         PB, // D8 - PB4
200         PB,     // D9 - PB5
201         PB, // D10 - PB6
202         PB,     // D11 - PB7
203         PD, // D12 - PD6
204         PC, // D13 - PC7
205         
206         PB,     // D14 - MISO - PB3
207         PB,     // D15 - SCK - PB1
208         PB,     // D16 - MOSI - PB2
209         PB,     // D17 - SS - PB0
210         
211         PF,     // D18 - A0 - PF7
212         PF, // D19 - A1 - PF6
213         PF, // D20 - A2 - PF5
214         PF, // D21 - A3 - PF4
215         PF, // D22 - A4 - PF1
216         PF, // D23 - A5 - PF0
217         
218         PD, // D24 / D4 - A6 - PD4
219         PD, // D25 / D6 - A7 - PD7
220         PB, // D26 / D8 - A8 - PB4
221         PB, // D27 / D9 - A9 - PB5
222         PB, // D28 / D10 - A10 - PB6
223         PD, // D29 / D12 - A11 - PD6
224 };
225
226 const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[30] = {
227         _BV(2), // D0 - PD2
228         _BV(3), // D1 - PD3
229         _BV(1), // D2 - PD1
230         _BV(0), // D3 - PD0
231         _BV(4), // D4 - PD4
232         _BV(6), // D5 - PC6
233         _BV(7), // D6 - PD7
234         _BV(6), // D7 - PE6
235         
236         _BV(4), // D8 - PB4
237         _BV(5), // D9 - PB5
238         _BV(6), // D10 - PB6
239         _BV(7), // D11 - PB7
240         _BV(6), // D12 - PD6
241         _BV(7), // D13 - PC7
242         
243         _BV(3), // D14 - MISO - PB3
244         _BV(1), // D15 - SCK - PB1
245         _BV(2), // D16 - MOSI - PB2
246         _BV(0), // D17 - SS - PB0
247         
248         _BV(7), // D18 - A0 - PF7
249         _BV(6), // D19 - A1 - PF6
250         _BV(5), // D20 - A2 - PF5
251         _BV(4), // D21 - A3 - PF4
252         _BV(1), // D22 - A4 - PF1
253         _BV(0), // D23 - A5 - PF0
254         
255         _BV(4), // D24 / D4 - A6 - PD4
256         _BV(7), // D25 / D6 - A7 - PD7
257         _BV(4), // D26 / D8 - A8 - PB4
258         _BV(5), // D27 / D9 - A9 - PB5
259         _BV(6), // D28 / D10 - A10 - PB6
260         _BV(6), // D29 / D12 - A11 - PD6
261 };
262
263 const uint8_t PROGMEM digital_pin_to_timer_PGM[18] = {
264         NOT_ON_TIMER,   
265         NOT_ON_TIMER,
266         NOT_ON_TIMER,
267         TIMER0B,                /* 3 */
268         NOT_ON_TIMER,
269         TIMER3A,                /* 5 */
270         TIMER4D,                /* 6 */
271         NOT_ON_TIMER,   
272         
273         NOT_ON_TIMER,   
274         TIMER1A,                /* 9 */
275         TIMER1B,                /* 10 */
276         TIMER0A,                /* 11 */
277         
278         NOT_ON_TIMER,   
279         TIMER4A,                /* 13 */
280         
281         NOT_ON_TIMER,   
282         NOT_ON_TIMER,
283 };
284
285 const uint8_t PROGMEM analog_pin_to_channel_PGM[12] = {
286         7,      // A0                           PF7                                     ADC7
287         6,      // A1                           PF6                                     ADC6    
288         5,      // A2                           PF5                                     ADC5    
289         4,      // A3                           PF4                                     ADC4
290         1,      // A4                           PF1                                     ADC1    
291         0,      // A5                           PF0                                     ADC0    
292         8,      // A6           D4              PD4                                     ADC8
293         10,     // A7           D6              PD7                                     ADC10
294         11,     // A8           D8              PB4                                     ADC11
295         12,     // A9           D9              PB5                                     ADC12
296         13,     // A10          D10             PB6                                     ADC13
297         9       // A11          D12             PD6                                     ADC9
298 };
299
300 #endif /* ARDUINO_MAIN */
301
302 // These serial port names are intended to allow libraries and architecture-neutral
303 // sketches to automatically default to the correct port name for a particular type
304 // of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
305 // the first hardware serial port whose RX/TX pins are not dedicated to another use.
306 //
307 // SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor
308 //
309 // SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial
310 //
311 // SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library
312 //
313 // SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.
314 //
315 // SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX
316 //                            pins are NOT connected to anything by default.
317 #define SERIAL_PORT_MONITOR        Serial
318 #define SERIAL_PORT_USBVIRTUAL     Serial
319 #define SERIAL_PORT_HARDWARE       Serial1
320
321 #endif /* Pins_Arduino_h */