|
| 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 NUM_DIGITAL_PINS 23 |
| 31 | +#define NUM_ANALOG_INPUTS 8 |
| 32 | +#define analogInputToDigitalPin(p) ((p < 8) ? (p) + 24 : -1) |
| 33 | +#define digitalPinHasPWM(p) ((p) == 2 || (p) == 3 || (p) == 4 || (p) == 5 || (p) == 21 || (p) == 22 || (p) == 23) |
| 34 | + |
| 35 | +static const uint8_t SS = 9; |
| 36 | +static const uint8_t MOSI = 10; |
| 37 | +static const uint8_t MISO = 11; |
| 38 | +static const uint8_t SCK = 12; |
| 39 | + |
| 40 | +static const uint8_t SCL = 15; |
| 41 | +static const uint8_t SDA = 16; |
| 42 | + |
| 43 | +static const uint8_t VCC_ENABLE = 17; |
| 44 | +static const uint8_t BATT_ALERT = 18; |
| 45 | +static const uint8_t BACKPACK_BUS = 19; |
| 46 | +static const uint8_t CHG_STATUS = 20; |
| 47 | +static const uint8_t LED_BLUE = 21; |
| 48 | +static const uint8_t LED_RED = 22; |
| 49 | +static const uint8_t LED_GREEN = 23; |
| 50 | +static const uint8_t LED_BUILTIN = 23; |
| 51 | +static const uint8_t LED = 23; |
| 52 | + |
| 53 | +static const uint8_t A0 = 24; |
| 54 | +static const uint8_t A1 = 25; |
| 55 | +static const uint8_t A2 = 26; |
| 56 | +static const uint8_t A3 = 27; |
| 57 | +static const uint8_t A4 = 28; |
| 58 | +static const uint8_t A5 = 29; |
| 59 | +static const uint8_t A6 = 30; |
| 60 | +static const uint8_t A7 = 31; |
| 61 | + |
| 62 | +#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 24) ? (&PCICR) : ((uint8_t *)0)) |
| 63 | +#define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1)) |
| 64 | +#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 24) ? (&PCMSK1) : ((uint8_t *)0)))) |
| 65 | +#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14))) |
| 66 | + |
| 67 | +#ifdef ARDUINO_MAIN |
| 68 | + |
| 69 | +const uint16_t PROGMEM port_to_mode_PGM[] = { |
| 70 | + NOT_A_PORT, |
| 71 | + NOT_A_PORT, |
| 72 | + (uint16_t)&DDRB, |
| 73 | + NOT_A_PORT, |
| 74 | + (uint16_t)&DDRD, |
| 75 | + (uint16_t)&DDRE, |
| 76 | + (uint16_t)&DDRF, |
| 77 | + (uint16_t)&DDRG, |
| 78 | + NOT_A_PORT, |
| 79 | + NOT_A_PORT, |
| 80 | + NOT_A_PORT, |
| 81 | + NOT_A_PORT, |
| 82 | + NOT_A_PORT, |
| 83 | +}; |
| 84 | + |
| 85 | +const uint16_t PROGMEM port_to_output_PGM[] = { |
| 86 | + NOT_A_PORT, |
| 87 | + NOT_A_PORT, |
| 88 | + (uint16_t)&PORTB, |
| 89 | + NOT_A_PORT, |
| 90 | + (uint16_t)&PORTD, |
| 91 | + (uint16_t)&PORTE, |
| 92 | + (uint16_t)&PORTF, |
| 93 | + (uint16_t)&PORTG, |
| 94 | + NOT_A_PORT, |
| 95 | + NOT_A_PORT, |
| 96 | + NOT_A_PORT, |
| 97 | + NOT_A_PORT, |
| 98 | + NOT_A_PORT, |
| 99 | +}; |
| 100 | + |
| 101 | +const uint16_t PROGMEM port_to_input_PGM[] = { |
| 102 | + NOT_A_PIN, |
| 103 | + NOT_A_PIN, |
| 104 | + (uint16_t)&PINB, |
| 105 | + NOT_A_PIN, |
| 106 | + (uint16_t)&PIND, |
| 107 | + (uint16_t)&PINE, |
| 108 | + (uint16_t)&PINF, |
| 109 | + (uint16_t)&PING, |
| 110 | + NOT_A_PIN, |
| 111 | + NOT_A_PIN, |
| 112 | + NOT_A_PIN, |
| 113 | + NOT_A_PIN, |
| 114 | + NOT_A_PIN, |
| 115 | +}; |
| 116 | + |
| 117 | +const uint8_t PROGMEM digital_pin_to_port_PGM[] = { |
| 118 | + // PORTLIST |
| 119 | + // ~: PWM, *: external interrupt |
| 120 | + // ------------------------------------------- |
| 121 | + PE , // PE 0 ** D0 ** USART0_RX |
| 122 | + PE , // PE 1 ** D1 ** USART0_TX |
| 123 | + PB , // PB 7 ** D2 ** D2~ |
| 124 | + PE , // PE 3 ** D3 ** D3~ |
| 125 | + PE , // PE 4 ** D4 ** D4*~ |
| 126 | + PE , // PE 5 ** D5 ** D5*~ |
| 127 | + PE , // PE 2 ** D6 ** D6 |
| 128 | + PE , // PE 6 ** D7 ** D7* |
| 129 | + PD , // PD 5 ** D8 ** D8 |
| 130 | + PB , // PB 0 ** D9 ** SPI_SSN |
| 131 | + PB , // PB 2 ** D10 ** SPI_MOSI |
| 132 | + PB , // PB 3 ** D11 ** SPI_MISO |
| 133 | + PB , // PB 1 ** D12 ** SPI_SCK |
| 134 | + PD , // PD 2 ** D13 ** USART1_RX* |
| 135 | + PD , // PD 3 ** D14 ** USART1_TX* |
| 136 | + PD , // PD 0 ** D15 ** I2C_SCL* |
| 137 | + PD , // PD 1 ** D16 ** I2C_SDA* |
| 138 | + PD , // PD 4 ** D17 ** VCC_ENABLE |
| 139 | + PE , // PE 7 ** D18 ** BATT_ALERT* |
| 140 | + PD , // PD 6 ** D19 ** BACKPACK_BUS |
| 141 | + PD , // PD 7 ** D20 ** CHG_STATUS |
| 142 | + PB , // PB 4 ** D21 ** LED_BLUE~ |
| 143 | + PB , // PB 5 ** D22 ** LED_RED~ |
| 144 | + PB , // PB 6 ** D23 ** LED_GREEN~ |
| 145 | + PF , // PF 0 ** D24 ** A0 |
| 146 | + PF , // PF 1 ** D25 ** A1 |
| 147 | + PF , // PF 2 ** D26 ** A2 |
| 148 | + PF , // PF 3 ** D27 ** A3 |
| 149 | + PF , // PF 4 ** D28 ** A4 |
| 150 | + PF , // PF 5 ** D29 ** A5 |
| 151 | + PF , // PF 6 ** D30 ** A6 |
| 152 | + PF , // PF 7 ** D31 ** A7 |
| 153 | +}; |
| 154 | + |
| 155 | +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { |
| 156 | + // PIN IN PORT |
| 157 | + // ~: PWM, *: external interrupt |
| 158 | + // ------------------------------------------- |
| 159 | + _BV(PE0) , // PE 0 ** D0 ** USART0_RX |
| 160 | + _BV(PE1) , // PE 1 ** D1 ** USART0_TX |
| 161 | + _BV(PB7) , // PB 7 ** D2 ** D2~ |
| 162 | + _BV(PE3) , // PE 3 ** D3 ** D3~ |
| 163 | + _BV(PE4) , // PE 4 ** D4 ** D4*~ |
| 164 | + _BV(PE5) , // PE 5 ** D5 ** D5*~ |
| 165 | + _BV(PE2) , // PE 2 ** D6 ** D6 |
| 166 | + _BV(PE6) , // PE 6 ** D7 ** D7* |
| 167 | + _BV(PD5) , // PD 5 ** D8 ** D8 |
| 168 | + _BV(PB0) , // PB 0 ** D9 ** SPI_SSN |
| 169 | + _BV(PB2) , // PB 2 ** D10 ** SPI_MOSI |
| 170 | + _BV(PB3) , // PB 3 ** D11 ** SPI_MISO |
| 171 | + _BV(PB1) , // PB 1 ** D12 ** SPI_SCK |
| 172 | + _BV(PD2) , // PD 2 ** D13 ** USART1_RX* |
| 173 | + _BV(PD3) , // PD 3 ** D14 ** USART1_TX* |
| 174 | + _BV(PD0) , // PD 0 ** D15 ** I2C_SCL* |
| 175 | + _BV(PD1) , // PD 1 ** D16 ** I2C_SDA* |
| 176 | + _BV(PD4) , // PD 4 ** D17 ** VCC_ENABLE |
| 177 | + _BV(PE7) , // PE 7 ** D18 ** BATT_ALERT* |
| 178 | + _BV(PD6) , // PD 6 ** D19 ** BACKPACK_BUS |
| 179 | + _BV(PD7) , // PD 7 ** D20 ** CHG_STATUS |
| 180 | + _BV(PB4) , // PB 4 ** D21 ** LED_BLUE~ |
| 181 | + _BV(PB5) , // PB 5 ** D22 ** LED_RED~ |
| 182 | + _BV(PB6) , // PB 6 ** D23 ** LED_GREEN~ |
| 183 | + _BV(PF0) , // PF 0 ** D24 ** A0 |
| 184 | + _BV(PF1) , // PF 1 ** D25 ** A1 |
| 185 | + _BV(PF2) , // PF 2 ** D26 ** A2 |
| 186 | + _BV(PF3) , // PF 3 ** D27 ** A3 |
| 187 | + _BV(PF4) , // PF 4 ** D28 ** A4 |
| 188 | + _BV(PF5) , // PF 5 ** D29 ** A5 |
| 189 | + _BV(PF6) , // PF 6 ** D30 ** A6 |
| 190 | + _BV(PF7) , // PF 7 ** D31 ** A7 |
| 191 | +}; |
| 192 | + |
| 193 | +const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { |
| 194 | + // TIMERS |
| 195 | + // ~: PWM, *: external interrupt |
| 196 | + // ------------------------------------------- |
| 197 | + NOT_ON_TIMER , // PE 0 ** D0 ** USART0_RX |
| 198 | + NOT_ON_TIMER , // PE 1 ** D1 ** USART0_TX |
| 199 | + TIMER0A , // PB 7 ** D2 ** D2~ |
| 200 | + TIMER3A , // PE 3 ** D3 ** D3~ |
| 201 | + TIMER3B , // PE 4 ** D4 ** D4*~ |
| 202 | + TIMER3C , // PE 5 ** D5 ** D5*~ |
| 203 | + NOT_ON_TIMER , // PE 2 ** D6 ** D6 |
| 204 | + NOT_ON_TIMER , // PE 6 ** D7 ** D7* |
| 205 | + NOT_ON_TIMER , // PD 5 ** D8 ** D8 |
| 206 | + NOT_ON_TIMER , // PB 0 ** D9 ** SPI_SSN |
| 207 | + NOT_ON_TIMER , // PB 2 ** D10 ** SPI_MOSI |
| 208 | + NOT_ON_TIMER , // PB 3 ** D11 ** SPI_MISO |
| 209 | + NOT_ON_TIMER , // PB 1 ** D12 ** SPI_SCK |
| 210 | + NOT_ON_TIMER , // PD 2 ** D13 ** USART1_RX* |
| 211 | + NOT_ON_TIMER , // PD 3 ** D14 ** USART1_TX* |
| 212 | + NOT_ON_TIMER , // PD 0 ** D15 ** I2C_SCL* |
| 213 | + NOT_ON_TIMER , // PD 1 ** D16 ** I2C_SDA* |
| 214 | + NOT_ON_TIMER , // PD 4 ** D17 ** VCC_ENABLE |
| 215 | + NOT_ON_TIMER , // PE 7 ** D18 ** BATT_ALERT* |
| 216 | + NOT_ON_TIMER , // PD 6 ** D19 ** BACKPACK_BUS |
| 217 | + NOT_ON_TIMER , // PD 7 ** D20 ** CHG_STATUS |
| 218 | + TIMER0B , // PB 4 ** D21 ** LED_BLUE~ |
| 219 | + TIMER1A , // PB 5 ** D22 ** LED_RED~ |
| 220 | + TIMER1B , // PB 6 ** D23 ** LED_GREEN~ |
| 221 | + NOT_ON_TIMER , // PF 0 ** D24 ** A0 |
| 222 | + NOT_ON_TIMER , // PF 1 ** D25 ** A1 |
| 223 | + NOT_ON_TIMER , // PF 2 ** D26 ** A2 |
| 224 | + NOT_ON_TIMER , // PF 3 ** D27 ** A3 |
| 225 | + NOT_ON_TIMER , // PF 4 ** D28 ** A4 |
| 226 | + NOT_ON_TIMER , // PF 5 ** D29 ** A5 |
| 227 | + NOT_ON_TIMER , // PF 6 ** D30 ** A6 |
| 228 | + NOT_ON_TIMER , // PF 7 ** D31 ** A7 |
| 229 | +}; |
| 230 | + |
| 231 | +#endif |
| 232 | + |
| 233 | +#endif |
0 commit comments