96
96
//
97
97
#define DIGITAL_IO_PIN_SHIFT /* UNCOMMENT THIS to shift digital pin assignments for Arduino shield compatibility */
98
98
99
- //#define USE_AREF 0x2 /* see 28.16.3 in 'AU' manual - this is the REFCTRL bits for the reference select, AREF on PORTA (PA0) */
99
+ //#define USE_AREF analogReference_PORTA0 /* see 28.16.3 in 'AU' manual - this is the REFCTRL bits for the reference select, AREF on PORTA (PA0) */
100
100
101
101
#define NUM_DIGITAL_PINS 62
102
102
225
225
// --------------------------------------------
226
226
227
227
228
- #define DEFAULT_TWI TWIC /* for now, later maybe TWIE? */
229
- #define TWIC_VECT_ENABLE /* use this to select the correct interrupt vectors */
228
+ // TWI ports - default is TWIE
229
+ #define DEFAULT_TWI TWIE
230
+
231
+ // the XMega128a1u has four TWI ports
232
+ #define TWI_PORT0 TWIE
233
+ #define TWI_VECTOR_S0 TWIE_TWIS_vect
234
+ #define TWI_VECTOR_M0 TWIE_TWIM_vect
235
+ #define TWI_PORT1 TWIC
236
+ #define TWI_VECTOR_S1 TWIC_TWIS_vect
237
+ #define TWI_VECTOR_M1 TWIC_TWIM_vect
238
+ #define TWI_PORT2 TWID
239
+ #define TWI_VECTOR_S2 TWID_TWIS_vect
240
+ #define TWI_VECTOR_M2 TWID_TWIM_vect
241
+ #define TWI_PORT3 TWIF
242
+ #define TWI_VECTOR_S3 TWIF_TWIS_vect
243
+ #define TWI_VECTOR_M3 TWIF_TWIM_vect
244
+ #define TWI_INTERFACE_COUNT 4
245
+
246
+
247
+ // obsolete - consider removal in all of them
248
+ //#define TWIC_VECT_ENABLE /* use this to select the correct interrupt vectors for default */
230
249
231
250
// serial port 0
232
251
#define SERIAL_0_PORT_NAME PORTD
@@ -348,12 +367,18 @@ static const uint8_t MOSI1 = 3;
348
367
static const uint8_t MISO1 = 4 ;
349
368
static const uint8_t SCK1 = 5 ;
350
369
351
- // default 2-wire on PE0,PE1 - TWIE (for TWIC, you're on your own)
352
- // NOTE: TWIE appears it may be broken, so switch to TWIC?
370
+ // default 2-wire on PE0,PE1 - TWIE
371
+ // NOTE: this does NOT correspond to the mega2560, which uses 20 and 21 (need more remap work)
353
372
static const uint8_t SDA = 14 ;
354
373
static const uint8_t SCL = 15 ;
355
-
356
- // TODO: alternate 2-wire ports
374
+ static const uint8_t SDA0 = 14 ; // TWIE
375
+ static const uint8_t SCL0 = 15 ;
376
+ static const uint8_t SDA1 = 6 ; // TWIC
377
+ static const uint8_t SCL1 = 7 ;
378
+ static const uint8_t SDA2 = 59 ; // TWID
379
+ static const uint8_t SCL2 = 60 ;
380
+ static const uint8_t SDA3 = 22 ; // TWIF
381
+ static const uint8_t SCL3 = 23 ;
357
382
358
383
// keep track of the indices for port R since its control register
359
384
// settings may be slightly different
@@ -382,11 +407,18 @@ static const uint8_t MOSI1 = 5;
382
407
static const uint8_t MISO1 = 6 ;
383
408
static const uint8_t SCK1 = 7 ;
384
409
385
- // default 2-wire on PE0,PE1 - TWIE (for TWIC, you're on your own)
386
- // NOTE: TWIE appears it may be broken, so switch to TWIC?
410
+ // default 2-wire on PE0,PE1 - TWIE
387
411
// NOTE: this does NOT correspond to the mega2560, which uses 20 and 21 (need more remap work)
388
412
static const uint8_t SDA = 16 ;
389
413
static const uint8_t SCL = 17 ;
414
+ static const uint8_t SDA0 = 16 ;
415
+ static const uint8_t SCL0 = 17 ;
416
+ static const uint8_t SDA1 = 8 ;
417
+ static const uint8_t SCL1 = 9 ;
418
+ static const uint8_t SDA2 = 0 ;
419
+ static const uint8_t SCL2 = 1 ;
420
+ static const uint8_t SDA3 = 24 ;
421
+ static const uint8_t SCL3 = 25 ;
390
422
391
423
// TODO: alternate 2-wire ports TWIC?
392
424
@@ -522,25 +554,25 @@ const uint16_t PROGMEM port_to_input_PGM[] = {
522
554
523
555
const uint16_t PROGMEM digital_pin_to_control_PGM [] = {
524
556
#ifndef DIGITAL_IO_PIN_SHIFT
525
- (uint16_t ) & PORTD_PIN0CTRL , // PD 0 ** 0 **
526
- (uint16_t ) & PORTD_PIN1CTRL , // PD 1 ** 1 **
557
+ (uint16_t ) & PORTD_PIN0CTRL , // PD 0 ** 0 ** SDA2
558
+ (uint16_t ) & PORTD_PIN1CTRL , // PD 1 ** 1 ** SCL2
527
559
#endif // DIGITAL_IO_PIN_SHIFT
528
560
(uint16_t ) & PORTD_PIN2CTRL , // PD 2 ** 2 ** USARTD_RX ASYNC
529
561
(uint16_t ) & PORTD_PIN3CTRL , // PD 3 ** 3 ** USARTD_TX
530
562
(uint16_t ) & PORTD_PIN4CTRL , // PD 4 ** 4 **
531
563
(uint16_t ) & PORTD_PIN5CTRL , // PD 5 ** 5 **
532
564
(uint16_t ) & PORTD_PIN6CTRL , // PD 6 ** 6 **
533
565
(uint16_t ) & PORTD_PIN7CTRL , // PD 7 ** 7 **
534
- (uint16_t ) & PORTC_PIN0CTRL , // PC 0 ** 8 **
535
- (uint16_t ) & PORTC_PIN1CTRL , // PC 1 ** 9 **
566
+ (uint16_t ) & PORTC_PIN0CTRL , // PC 0 ** 8 ** SDA1
567
+ (uint16_t ) & PORTC_PIN1CTRL , // PC 1 ** 9 ** SCL1
536
568
(uint16_t ) & PORTC_PIN2CTRL , // PC 2 ** 10 ** ASYNC
537
569
(uint16_t ) & PORTC_PIN3CTRL , // PC 3 ** 11 **
538
570
(uint16_t ) & PORTC_PIN4CTRL , // PC 4 ** 12 ** SPI_SS
539
571
(uint16_t ) & PORTC_PIN5CTRL , // PC 5 ** 13 ** SPI_MOSI
540
572
(uint16_t ) & PORTC_PIN6CTRL , // PC 6 ** 14 ** SPI_MISO
541
573
(uint16_t ) & PORTC_PIN7CTRL , // PC 7 ** 15 ** SPI_SCK
542
- (uint16_t ) & PORTE_PIN0CTRL , // PE 0 ** 16 ** SDA
543
- (uint16_t ) & PORTE_PIN1CTRL , // PE 1 ** 17 ** SCL
574
+ (uint16_t ) & PORTE_PIN0CTRL , // PE 0 ** 16 ** SDA, SDA0
575
+ (uint16_t ) & PORTE_PIN1CTRL , // PE 1 ** 17 ** SCL, SCL0
544
576
(uint16_t ) & PORTE_PIN2CTRL , // PE 2 ** 18 ** ASYNC
545
577
(uint16_t ) & PORTE_PIN3CTRL , // PE 3 ** 19 **
546
578
@@ -549,8 +581,8 @@ const uint16_t PROGMEM digital_pin_to_control_PGM[] = {
549
581
(uint16_t ) & PORTE_PIN6CTRL , // PE 3 ** 22 **
550
582
(uint16_t ) & PORTE_PIN7CTRL , // PE 3 ** 23 **
551
583
552
- (uint16_t ) & PORTF_PIN0CTRL , // PF 0 ** 24 **
553
- (uint16_t ) & PORTF_PIN1CTRL , // PF 1 ** 25 **
584
+ (uint16_t ) & PORTF_PIN0CTRL , // PF 0 ** 24 ** SDA3
585
+ (uint16_t ) & PORTF_PIN1CTRL , // PF 1 ** 25 ** SCL3
554
586
(uint16_t ) & PORTF_PIN2CTRL , // PF 2 ** 26 ** ASYNC
555
587
(uint16_t ) & PORTF_PIN3CTRL , // PF 3 ** 27 **
556
588
(uint16_t ) & PORTF_PIN4CTRL , // PF 4 ** 28 **
@@ -593,8 +625,8 @@ const uint16_t PROGMEM digital_pin_to_control_PGM[] = {
593
625
(uint16_t ) & PORTR_PIN0CTRL , // PR 0 ** 60 **
594
626
(uint16_t ) & PORTR_PIN1CTRL , // PR 1 ** 61 ** default LED
595
627
#ifdef DIGITAL_IO_PIN_SHIFT
596
- (uint16_t ) & PORTD_PIN0CTRL , // PD 0 ** the new 60 **
597
- (uint16_t ) & PORTD_PIN1CTRL , // PD 1 ** the new 61 **
628
+ (uint16_t ) & PORTD_PIN0CTRL , // PD 0 ** the new 60 ** SDA2
629
+ (uint16_t ) & PORTD_PIN1CTRL , // PD 1 ** the new 61 ** SCL2
598
630
#endif // DIGITAL_IO_PIN_SHIFT
599
631
(uint16_t ) & PORTA_PIN0CTRL , // PA 0 ** 62 ** A0
600
632
(uint16_t ) & PORTA_PIN1CTRL , // PA 1 ** 63 ** A1
0 commit comments