From 35ab21678fddb6d0fc7d7463ba3e6bf9c0a9b36a Mon Sep 17 00:00:00 2001 From: ajahern95 <83899406+ajahern95@users.noreply.github.com> Date: Fri, 14 May 2021 22:19:10 +0800 Subject: [PATCH] Samd51 Thing Plus Pin Definitions Update Adding support for interrupt on Pin D9 and Analog on D4 (A6) and D9 (A7) --- .../SparkFun_SAMD51_Thing_Plus/variant.cpp | 29 ++++++++------ .../SparkFun_SAMD51_Thing_Plus/variant.h | 40 ++++++++++--------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.cpp b/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.cpp index 1e855ee1..dd9b8449 100644 --- a/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.cpp +++ b/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.cpp @@ -34,28 +34,28 @@ const PinDescription g_APinDescription[]= // 0..13 - Digital pins // ---------------------- // 0/1 - SERCOM/UART (Serial1) - { PORTA, 13, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TC2_CH1, NOT_ON_TIMER, EXTERNAL_INT_13 }, // RX: SERCOM2/PAD[1] - { PORTA, 12, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TC2_CH0, NOT_ON_TIMER, EXTERNAL_INT_12 }, // TX: SERCOM2/PAD[2] + { PORTA, 13, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TC2_CH1, TC2_CH1, EXTERNAL_INT_13 }, // RX: SERCOM2/PAD[1] + { PORTA, 12, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TC2_CH0, TC2_CH0, EXTERNAL_INT_12 }, // TX: SERCOM2/PAD[2] // 2..12 // Digital { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, - { PORTA, 6, PIO_DIGITAL, PIN_ATTR_PWM_E, No_ADC_Channel, TC1_CH0, TC1_CH0, EXTERNAL_INT_6 }, + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_6 }, { PORTA, 15, PIO_TIMER_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC2_CH1, TC3_CH1, EXTERNAL_INT_2 }, { PORTA, 20, PIO_TIMER_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC0_CH0, TC7_CH0, EXTERNAL_INT_4 }, { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, - { PORTA, 7, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //pin 9 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel7, TC1_CH1, TC1_CH1, EXTERNAL_INT_7 }, //pin 9 { PORTA, 18, PIO_TIMER_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH2, TC3_CH0, EXTERNAL_INT_2 }, - { PORTA, 16, PIO_TIMER_ALT, PIN_ATTR_PWM_G, No_ADC_Channel, TCC1_CH0, NOT_ON_TIMER, EXTERNAL_INT_0 }, + { PORTA, 16, PIO_TIMER_ALT, PIN_ATTR_PWM_G, No_ADC_Channel, TCC1_CH0, TC2_CH0, EXTERNAL_INT_0 }, { PORTA, 19, PIO_TIMER_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH3, TC3_CH1, EXTERNAL_INT_3 }, // 13 (LED) { PORTA, 17, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH3, TC4_CH1, EXTERNAL_INT_1 }, // TCC2/WO[1] - // 14..19 - Analog pins + // 14..21 - Analog pins // -------------------- { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, { PORTB, 8, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel2, TC4_CH0, TC4_CH0, EXTERNAL_INT_8 }, @@ -64,38 +64,41 @@ const PinDescription g_APinDescription[]= { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, { PORTB, 2, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel14, TC6_CH0, TC6_CH0, EXTERNAL_INT_2 }, - // 20..21 I2C pins (SDA/SCL) + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_6 }, // Extra Analog pin D4 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel7, TC1_CH1, TC1_CH1, EXTERNAL_INT_7 }, // Extra Analog pin D9 + + // 22..23 I2C pins (SDA/SCL) // ---------------------- { PORTA, 22, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TC4_CH0, TC4_CH0, EXTERNAL_INT_6 }, // SDA: SERCOM3/PAD[0] { PORTA, 23, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TC4_CH1, TC4_CH1, EXTERNAL_INT_7 }, // SCL: SERCOM3/PAD[1] - // 22..24 - SPI pins (MISO,MOSI,SCK) + // 24..26 - SPI pins (MISO,MOSI,SCK) // ---------------------- { PORTB, 11, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // MISO: SERCOM4/PAD[3] { PORTB, 12, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_12 }, // MOSI: SERCOM4/PAD[0] { PORTB, 13, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_13 }, // SCK: SERCOM4/PAD[1] - // 25..26 - RX/TX LEDS -- unused + // 27..28 - RX/TX LEDS -- unused // -------------------- { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, - // 27..29 - USB + // 29..31 - USB // -------------------- { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable DOES NOT EXIST ON THIS BOARD { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP - // 30 (AREF) + // 32 (AREF) { PORTA, 3, PIO_ANALOG, PIN_ATTR_ANALOG, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // DAC/VREFP // ---------------------- - // 31..32 - Alternate use of A0/A4 (DAC output) + // 33..34 - Alternate use of A0/A4 (DAC output) { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // DAC/VOUT0 { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // DAC/VOUT1 // ---------------------- - // 33..36 SPI for Flash (SCK, CS, MISO, MOSI) + // 35..39 SPI for Flash (SCK, CS, MISO, MOSI) { PORTA, 9, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //SCK: SERCOM0/PAD[1] { PORTA, 10, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //CS: SERCOM0/PAD[2] { PORTA, 11, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //MISO: SERCOM0/PAD[3] diff --git a/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.h b/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.h index ee071781..f12e8e39 100644 --- a/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.h +++ b/sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.h @@ -57,11 +57,11 @@ extern "C" *----------------------------------------------------------------------------*/ // Number of pins defined in PinDescription array -#define PINS_COUNT (36u) +#define PINS_COUNT (38u) #define NUM_DIGITAL_PINS (20u) -#define NUM_ANALOG_INPUTS (6u) -#define NUM_ANALOG_OUTPUTS (1u) -#define analogInputToDigitalPin(p) ((p < 6u) ? (p) + 14u : -1) +#define NUM_ANALOG_INPUTS (8u) +#define NUM_ANALOG_OUTPUTS (2u) +#define analogInputToDigitalPin(p) ((p < 8u) ? (p) + 14u : -1) #define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) #define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) @@ -82,8 +82,8 @@ extern "C" // LEDs #define PIN_LED_13 (13u) -#define PIN_LED_RXL (25u) -#define PIN_LED_TXL (26u) +#define PIN_LED_RXL (27u) +#define PIN_LED_TXL (28u) #define PIN_LED PIN_LED_13 #define PIN_LED2 PIN_LED_RXL #define PIN_LED3 PIN_LED_TXL @@ -98,6 +98,8 @@ extern "C" #define PIN_A3 (PIN_A0 + 3) #define PIN_A4 (PIN_A0 + 4) #define PIN_A5 (PIN_A0 + 5) +#define PIN_A6 (PIN_A0 + 6) +#define PIN_A7 (PIN_A0 + 7) #define PIN_DAC0 (14ul) #define PIN_DAC1 PIN_A1 @@ -108,6 +110,8 @@ static const uint8_t A2 = PIN_A2; static const uint8_t A3 = PIN_A3; static const uint8_t A4 = PIN_A4; static const uint8_t A5 = PIN_A5; +static const uint8_t A6 = PIN_A6; +static const uint8_t A7 = PIN_A7; static const uint8_t DAC0 = PIN_DAC0; static const uint8_t DAC1 = PIN_DAC1; @@ -115,7 +119,7 @@ static const uint8_t DAC1 = PIN_DAC1; #define ADC_RESOLUTION 12 // Other pins -#define PIN_ATN (30ul) +#define PIN_ATN (32ul) static const uint8_t ATN = PIN_ATN; /* @@ -133,9 +137,9 @@ static const uint8_t ATN = PIN_ATN; */ #define SPI_INTERFACES_COUNT 2 -#define PIN_SPI_MISO (22u) -#define PIN_SPI_MOSI (23u) -#define PIN_SPI_SCK (24u) +#define PIN_SPI_MISO (24u) +#define PIN_SPI_MOSI (25u) +#define PIN_SPI_SCK (26u) #define PERIPH_SPI sercom4 #define PAD_SPI_TX SPI_PAD_0_SCK_1 #define PAD_SPI_RX SERCOM_RX_PAD_3 @@ -145,9 +149,9 @@ static const uint8_t MOSI = PIN_SPI_MOSI ; static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; -#define PIN_SPI1_MISO (35u) -#define PIN_SPI1_MOSI (36u) -#define PIN_SPI1_SCK (33u) +#define PIN_SPI1_MISO (37u) +#define PIN_SPI1_MOSI (38u) +#define PIN_SPI1_SCK (35u) #define PERIPH_SPI1 sercom0 #define PAD_SPI1_TX SPI_PAD_0_SCK_1 #define PAD_SPI1_RX SERCOM_RX_PAD_3 @@ -162,8 +166,8 @@ static const uint8_t FLASH_SCK = PIN_SPI1_SCK ; */ #define WIRE_INTERFACES_COUNT 1 -#define PIN_WIRE_SDA (20u) -#define PIN_WIRE_SCL (21u) +#define PIN_WIRE_SDA (22u) +#define PIN_WIRE_SCL (23u) #define PERIPH_WIRE sercom3 #define WIRE_IT_HANDLER SERCOM3_Handler #define WIRE_IT_HANDLER_0 SERCOM3_0_Handler @@ -177,9 +181,9 @@ static const uint8_t SCL = PIN_WIRE_SCL; /* * USB */ -#define PIN_USB_HOST_ENABLE (27ul) -#define PIN_USB_DM (28ul) -#define PIN_USB_DP (29ul) +#define PIN_USB_HOST_ENABLE (29ul) +#define PIN_USB_DM (30ul) +#define PIN_USB_DP (31ul) /* * I2S Interfaces