diff options
Diffstat (limited to 'drivers/avr/pro_micro.h')
| -rw-r--r-- | drivers/avr/pro_micro.h | 270 |
1 files changed, 116 insertions, 154 deletions
diff --git a/drivers/avr/pro_micro.h b/drivers/avr/pro_micro.h index f9e7ed75d..762a99a05 100644 --- a/drivers/avr/pro_micro.h +++ b/drivers/avr/pro_micro.h | |||
| @@ -90,14 +90,14 @@ | |||
| 90 | #undef OCR2_6 | 90 | #undef OCR2_6 |
| 91 | #undef OCR2_7 | 91 | #undef OCR2_7 |
| 92 | 92 | ||
| 93 | #define NUM_DIGITAL_PINS 30 | 93 | #define NUM_DIGITAL_PINS 30 |
| 94 | #define NUM_ANALOG_INPUTS 12 | 94 | #define NUM_ANALOG_INPUTS 12 |
| 95 | 95 | ||
| 96 | #define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0) | 96 | #define TX_RX_LED_INIT DDRD |= (1 << 5), DDRB |= (1 << 0) |
| 97 | #define TXLED0 PORTD |= (1<<5) | 97 | #define TXLED0 PORTD |= (1 << 5) |
| 98 | #define TXLED1 PORTD &= ~(1<<5) | 98 | #define TXLED1 PORTD &= ~(1 << 5) |
| 99 | #define RXLED0 PORTB |= (1<<0) | 99 | #define RXLED0 PORTB |= (1 << 0) |
| 100 | #define RXLED1 PORTB &= ~(1<<0) | 100 | #define RXLED1 PORTB &= ~(1 << 0) |
| 101 | 101 | ||
| 102 | static const uint8_t SDA = 2; | 102 | static const uint8_t SDA = 2; |
| 103 | static const uint8_t SCL = 3; | 103 | static const uint8_t SCL = 3; |
| @@ -111,27 +111,27 @@ static const uint8_t SCK = 15; | |||
| 111 | 111 | ||
| 112 | // Mapping of analog pins as digital I/O | 112 | // Mapping of analog pins as digital I/O |
| 113 | // A6-A11 share with digital pins | 113 | // A6-A11 share with digital pins |
| 114 | static const uint8_t ADC0 = 18; | 114 | static const uint8_t ADC0 = 18; |
| 115 | static const uint8_t ADC1 = 19; | 115 | static const uint8_t ADC1 = 19; |
| 116 | static const uint8_t ADC2 = 20; | 116 | static const uint8_t ADC2 = 20; |
| 117 | static const uint8_t ADC3 = 21; | 117 | static const uint8_t ADC3 = 21; |
| 118 | static const uint8_t ADC4 = 22; | 118 | static const uint8_t ADC4 = 22; |
| 119 | static const uint8_t ADC5 = 23; | 119 | static const uint8_t ADC5 = 23; |
| 120 | static const uint8_t ADC6 = 24; // D4 | 120 | static const uint8_t ADC6 = 24; // D4 |
| 121 | static const uint8_t ADC7 = 25; // D6 | 121 | static const uint8_t ADC7 = 25; // D6 |
| 122 | static const uint8_t ADC8 = 26; // D8 | 122 | static const uint8_t ADC8 = 26; // D8 |
| 123 | static const uint8_t ADC9 = 27; // D9 | 123 | static const uint8_t ADC9 = 27; // D9 |
| 124 | static const uint8_t ADC10 = 28; // D10 | 124 | static const uint8_t ADC10 = 28; // D10 |
| 125 | static const uint8_t ADC11 = 29; // D12 | 125 | static const uint8_t ADC11 = 29; // D12 |
| 126 | 126 | ||
| 127 | #define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) | 127 | #define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) |
| 128 | #define digitalPinToPCICRbit(p) 0 | 128 | #define digitalPinToPCICRbit(p) 0 |
| 129 | #define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) | 129 | #define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) |
| 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)))))) | 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)))))) |
| 131 | 131 | ||
| 132 | // __AVR_ATmega32U4__ has an unusual mapping of pins to channels | 132 | // __AVR_ATmega32U4__ has an unusual mapping of pins to channels |
| 133 | extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; | 133 | extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; |
| 134 | #define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) | 134 | #define analogPinToChannel(P) (pgm_read_byte(analog_pin_to_channel_PGM + (P))) |
| 135 | 135 | ||
| 136 | #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) | 136 | #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) |
| 137 | 137 | ||
| @@ -182,159 +182,121 @@ extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; | |||
| 182 | // appropriate addresses for various functions (e.g. reading | 182 | // appropriate addresses for various functions (e.g. reading |
| 183 | // and writing) | 183 | // and writing) |
| 184 | const uint16_t PROGMEM port_to_mode_PGM[] = { | 184 | const uint16_t PROGMEM port_to_mode_PGM[] = { |
| 185 | NOT_A_PORT, | 185 | NOT_A_PORT, NOT_A_PORT, (uint16_t)&DDRB, (uint16_t)&DDRC, (uint16_t)&DDRD, (uint16_t)&DDRE, (uint16_t)&DDRF, |
| 186 | NOT_A_PORT, | ||
| 187 | (uint16_t) &DDRB, | ||
| 188 | (uint16_t) &DDRC, | ||
| 189 | (uint16_t) &DDRD, | ||
| 190 | (uint16_t) &DDRE, | ||
| 191 | (uint16_t) &DDRF, | ||
| 192 | }; | 186 | }; |
| 193 | 187 | ||
| 194 | const uint16_t PROGMEM port_to_output_PGM[] = { | 188 | const uint16_t PROGMEM port_to_output_PGM[] = { |
| 195 | NOT_A_PORT, | 189 | NOT_A_PORT, NOT_A_PORT, (uint16_t)&PORTB, (uint16_t)&PORTC, (uint16_t)&PORTD, (uint16_t)&PORTE, (uint16_t)&PORTF, |
| 196 | NOT_A_PORT, | ||
| 197 | (uint16_t) &PORTB, | ||
| 198 | (uint16_t) &PORTC, | ||
| 199 | (uint16_t) &PORTD, | ||
| 200 | (uint16_t) &PORTE, | ||
| 201 | (uint16_t) &PORTF, | ||
| 202 | }; | 190 | }; |
| 203 | 191 | ||
| 204 | const uint16_t PROGMEM port_to_input_PGM[] = { | 192 | const uint16_t PROGMEM port_to_input_PGM[] = { |
| 205 | NOT_A_PORT, | 193 | NOT_A_PORT, NOT_A_PORT, (uint16_t)&PINB, (uint16_t)&PINC, (uint16_t)&PIND, (uint16_t)&PINE, (uint16_t)&PINF, |
| 206 | NOT_A_PORT, | ||
| 207 | (uint16_t) &PINB, | ||
| 208 | (uint16_t) &PINC, | ||
| 209 | (uint16_t) &PIND, | ||
| 210 | (uint16_t) &PINE, | ||
| 211 | (uint16_t) &PINF, | ||
| 212 | }; | 194 | }; |
| 213 | 195 | ||
| 214 | const uint8_t PROGMEM digital_pin_to_port_PGM[] = { | 196 | const uint8_t PROGMEM digital_pin_to_port_PGM[] = { |
| 215 | PD, // D0 - PD2 | 197 | PD, // D0 - PD2 |
| 216 | PD, // D1 - PD3 | 198 | PD, // D1 - PD3 |
| 217 | PD, // D2 - PD1 | 199 | PD, // D2 - PD1 |
| 218 | PD, // D3 - PD0 | 200 | PD, // D3 - PD0 |
| 219 | PD, // D4 - PD4 | 201 | PD, // D4 - PD4 |
| 220 | PC, // D5 - PC6 | 202 | PC, // D5 - PC6 |
| 221 | PD, // D6 - PD7 | 203 | PD, // D6 - PD7 |
| 222 | PE, // D7 - PE6 | 204 | PE, // D7 - PE6 |
| 223 | 205 | ||
| 224 | PB, // D8 - PB4 | 206 | PB, // D8 - PB4 |
| 225 | PB, // D9 - PB5 | 207 | PB, // D9 - PB5 |
| 226 | PB, // D10 - PB6 | 208 | PB, // D10 - PB6 |
| 227 | PB, // D11 - PB7 | 209 | PB, // D11 - PB7 |
| 228 | PD, // D12 - PD6 | 210 | PD, // D12 - PD6 |
| 229 | PC, // D13 - PC7 | 211 | PC, // D13 - PC7 |
| 230 | 212 | ||
| 231 | PB, // D14 - MISO - PB3 | 213 | PB, // D14 - MISO - PB3 |
| 232 | PB, // D15 - SCK - PB1 | 214 | PB, // D15 - SCK - PB1 |
| 233 | PB, // D16 - MOSI - PB2 | 215 | PB, // D16 - MOSI - PB2 |
| 234 | PB, // D17 - SS - PB0 | 216 | PB, // D17 - SS - PB0 |
| 235 | 217 | ||
| 236 | PF, // D18 - A0 - PF7 | 218 | PF, // D18 - A0 - PF7 |
| 237 | PF, // D19 - A1 - PF6 | 219 | PF, // D19 - A1 - PF6 |
| 238 | PF, // D20 - A2 - PF5 | 220 | PF, // D20 - A2 - PF5 |
| 239 | PF, // D21 - A3 - PF4 | 221 | PF, // D21 - A3 - PF4 |
| 240 | PF, // D22 - A4 - PF1 | 222 | PF, // D22 - A4 - PF1 |
| 241 | PF, // D23 - A5 - PF0 | 223 | PF, // D23 - A5 - PF0 |
| 242 | 224 | ||
| 243 | PD, // D24 - PD5 | 225 | PD, // D24 - PD5 |
| 244 | PD, // D25 / D6 - A7 - PD7 | 226 | PD, // D25 / D6 - A7 - PD7 |
| 245 | PB, // D26 / D8 - A8 - PB4 | 227 | PB, // D26 / D8 - A8 - PB4 |
| 246 | PB, // D27 / D9 - A9 - PB5 | 228 | PB, // D27 / D9 - A9 - PB5 |
| 247 | PB, // D28 / D10 - A10 - PB6 | 229 | PB, // D28 / D10 - A10 - PB6 |
| 248 | PD, // D29 / D12 - A11 - PD6 | 230 | PD, // D29 / D12 - A11 - PD6 |
| 249 | }; | 231 | }; |
| 250 | 232 | ||
| 251 | const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { | 233 | const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { |
| 252 | _BV(2), // D0 - PD2 | 234 | _BV(2), // D0 - PD2 |
| 253 | _BV(3), // D1 - PD3 | 235 | _BV(3), // D1 - PD3 |
| 254 | _BV(1), // D2 - PD1 | 236 | _BV(1), // D2 - PD1 |
| 255 | _BV(0), // D3 - PD0 | 237 | _BV(0), // D3 - PD0 |
| 256 | _BV(4), // D4 - PD4 | 238 | _BV(4), // D4 - PD4 |
| 257 | _BV(6), // D5 - PC6 | 239 | _BV(6), // D5 - PC6 |
| 258 | _BV(7), // D6 - PD7 | 240 | _BV(7), // D6 - PD7 |
| 259 | _BV(6), // D7 - PE6 | 241 | _BV(6), // D7 - PE6 |
| 260 | 242 | ||
| 261 | _BV(4), // D8 - PB4 | 243 | _BV(4), // D8 - PB4 |
| 262 | _BV(5), // D9 - PB5 | 244 | _BV(5), // D9 - PB5 |
| 263 | _BV(6), // D10 - PB6 | 245 | _BV(6), // D10 - PB6 |
| 264 | _BV(7), // D11 - PB7 | 246 | _BV(7), // D11 - PB7 |
| 265 | _BV(6), // D12 - PD6 | 247 | _BV(6), // D12 - PD6 |
| 266 | _BV(7), // D13 - PC7 | 248 | _BV(7), // D13 - PC7 |
| 267 | 249 | ||
| 268 | _BV(3), // D14 - MISO - PB3 | 250 | _BV(3), // D14 - MISO - PB3 |
| 269 | _BV(1), // D15 - SCK - PB1 | 251 | _BV(1), // D15 - SCK - PB1 |
| 270 | _BV(2), // D16 - MOSI - PB2 | 252 | _BV(2), // D16 - MOSI - PB2 |
| 271 | _BV(0), // D17 - SS - PB0 | 253 | _BV(0), // D17 - SS - PB0 |
| 272 | 254 | ||
| 273 | _BV(7), // D18 - A0 - PF7 | 255 | _BV(7), // D18 - A0 - PF7 |
| 274 | _BV(6), // D19 - A1 - PF6 | 256 | _BV(6), // D19 - A1 - PF6 |
| 275 | _BV(5), // D20 - A2 - PF5 | 257 | _BV(5), // D20 - A2 - PF5 |
| 276 | _BV(4), // D21 - A3 - PF4 | 258 | _BV(4), // D21 - A3 - PF4 |
| 277 | _BV(1), // D22 - A4 - PF1 | 259 | _BV(1), // D22 - A4 - PF1 |
| 278 | _BV(0), // D23 - A5 - PF0 | 260 | _BV(0), // D23 - A5 - PF0 |
| 279 | 261 | ||
| 280 | _BV(5), // D24 - PD5 | 262 | _BV(5), // D24 - PD5 |
| 281 | _BV(7), // D25 / D6 - A7 - PD7 | 263 | _BV(7), // D25 / D6 - A7 - PD7 |
| 282 | _BV(4), // D26 / D8 - A8 - PB4 | 264 | _BV(4), // D26 / D8 - A8 - PB4 |
| 283 | _BV(5), // D27 / D9 - A9 - PB5 | 265 | _BV(5), // D27 / D9 - A9 - PB5 |
| 284 | _BV(6), // D28 / D10 - A10 - PB6 | 266 | _BV(6), // D28 / D10 - A10 - PB6 |
| 285 | _BV(6), // D29 / D12 - A11 - PD6 | 267 | _BV(6), // D29 / D12 - A11 - PD6 |
| 286 | }; | 268 | }; |
| 287 | 269 | ||
| 288 | const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { | 270 | const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { |
| 289 | NOT_ON_TIMER, | 271 | NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, TIMER0B, /* 3 */ |
| 290 | NOT_ON_TIMER, | 272 | NOT_ON_TIMER, TIMER3A, /* 5 */ |
| 291 | NOT_ON_TIMER, | 273 | TIMER4D, /* 6 */ |
| 292 | TIMER0B, /* 3 */ | ||
| 293 | NOT_ON_TIMER, | ||
| 294 | TIMER3A, /* 5 */ | ||
| 295 | TIMER4D, /* 6 */ | ||
| 296 | NOT_ON_TIMER, | 274 | NOT_ON_TIMER, |
| 297 | 275 | ||
| 298 | NOT_ON_TIMER, | 276 | NOT_ON_TIMER, TIMER1A, /* 9 */ |
| 299 | TIMER1A, /* 9 */ | 277 | TIMER1B, /* 10 */ |
| 300 | TIMER1B, /* 10 */ | 278 | TIMER0A, /* 11 */ |
| 301 | TIMER0A, /* 11 */ | ||
| 302 | 279 | ||
| 303 | NOT_ON_TIMER, | 280 | NOT_ON_TIMER, TIMER4A, /* 13 */ |
| 304 | TIMER4A, /* 13 */ | ||
| 305 | 281 | ||
| 306 | NOT_ON_TIMER, | 282 | NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, |
| 307 | NOT_ON_TIMER, | ||
| 308 | NOT_ON_TIMER, | ||
| 309 | NOT_ON_TIMER, | ||
| 310 | NOT_ON_TIMER, | ||
| 311 | NOT_ON_TIMER, | ||
| 312 | 283 | ||
| 313 | NOT_ON_TIMER, | 284 | NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, |
| 314 | NOT_ON_TIMER, | ||
| 315 | NOT_ON_TIMER, | ||
| 316 | NOT_ON_TIMER, | ||
| 317 | NOT_ON_TIMER, | ||
| 318 | NOT_ON_TIMER, | ||
| 319 | NOT_ON_TIMER, | ||
| 320 | NOT_ON_TIMER, | ||
| 321 | NOT_ON_TIMER, | ||
| 322 | NOT_ON_TIMER, | ||
| 323 | }; | 285 | }; |
| 324 | 286 | ||
| 325 | const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { | 287 | const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { |
| 326 | 7, // A0 PF7 ADC7 | 288 | 7, // A0 PF7 ADC7 |
| 327 | 6, // A1 PF6 ADC6 | 289 | 6, // A1 PF6 ADC6 |
| 328 | 5, // A2 PF5 ADC5 | 290 | 5, // A2 PF5 ADC5 |
| 329 | 4, // A3 PF4 ADC4 | 291 | 4, // A3 PF4 ADC4 |
| 330 | 1, // A4 PF1 ADC1 | 292 | 1, // A4 PF1 ADC1 |
| 331 | 0, // A5 PF0 ADC0 | 293 | 0, // A5 PF0 ADC0 |
| 332 | 8, // A6 D4 PD4 ADC8 | 294 | 8, // A6 D4 PD4 ADC8 |
| 333 | 10, // A7 D6 PD7 ADC10 | 295 | 10, // A7 D6 PD7 ADC10 |
| 334 | 11, // A8 D8 PB4 ADC11 | 296 | 11, // A8 D8 PB4 ADC11 |
| 335 | 12, // A9 D9 PB5 ADC12 | 297 | 12, // A9 D9 PB5 ADC12 |
| 336 | 13, // A10 D10 PB6 ADC13 | 298 | 13, // A10 D10 PB6 ADC13 |
| 337 | 9 // A11 D12 PD6 ADC9 | 299 | 9 // A11 D12 PD6 ADC9 |
| 338 | }; | 300 | }; |
| 339 | 301 | ||
| 340 | #endif /* ARDUINO_MAIN */ | 302 | #endif /* ARDUINO_MAIN */ |
| @@ -354,9 +316,9 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { | |||
| 354 | // | 316 | // |
| 355 | // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX | 317 | // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX |
| 356 | // pins are NOT connected to anything by default. | 318 | // pins are NOT connected to anything by default. |
| 357 | #define SERIAL_PORT_MONITOR Serial | 319 | #define SERIAL_PORT_MONITOR Serial |
| 358 | #define SERIAL_PORT_USBVIRTUAL Serial | 320 | #define SERIAL_PORT_USBVIRTUAL Serial |
| 359 | #define SERIAL_PORT_HARDWARE Serial1 | 321 | #define SERIAL_PORT_HARDWARE Serial1 |
| 360 | #define SERIAL_PORT_HARDWARE_OPEN Serial1 | 322 | #define SERIAL_PORT_HARDWARE_OPEN Serial1 |
| 361 | 323 | ||
| 362 | #endif /* Pins_Arduino_h */ | 324 | #endif /* Pins_Arduino_h */ |
