Skip to content

Commit

Permalink
new board variants accordingly to the latest schematic, trying to kee…
Browse files Browse the repository at this point in the history
…p as close as possible to the original
  • Loading branch information
ldab committed Apr 24, 2019
1 parent 0b1ca1a commit 5da6a90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
25 changes: 3 additions & 22 deletions board_variant/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const PinDescription g_APinDescription[]=
{
// GPIO 0-4 on external pads
// D0, ADC, PWM, IRQ, and I2C SDA on sercom2 - no captouch
{ PORTA, 8, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel16, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_NMI }, // TCC0/WO[0]
{ PORTA, 8, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel16, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_NMI }, // TCC0/WO[0]

// D1, ADC, DAC, IRQ, Captouch and general purpose pin - no timer
{ PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ADC/AIN[0]

// D2, ADC, PWM, IRQ, and I2C SCL on sercom2 - no captouch
{ PORTA, 9, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel17, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_9 }, // TCC0/WO[1]
{ PORTA, 9, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel17, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_9 }, // TCC0/WO[1]

// D3, ADC, PWM, IRQ, UART RX, Captouch and general purpose pin
{ PORTA, 7, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // TCC1/WO[1]
Expand Down Expand Up @@ -84,25 +84,6 @@ const PinDescription g_APinDescription[]=
// Placeholder #21 & 22 for 'txled' and 'rxled'
{ PORTA, 14, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_14 },
{ PORTA, 15, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM3_CH1, TC3_CH1, EXTERNAL_INT_15 },

// Three additional pins For Battery and SARA UART
{ PORTA, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // ADC/AIN[1]

// SARA UART
{ PORTA, 16, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 17, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },

// Add all other not used PINs to check power consumption
/*{ PORTA, 4, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 5, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 6, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 11, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 18, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 19, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 22, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 23, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 27, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
{ PORTA, 28, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },*/
} ;

const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ;
Expand All @@ -118,4 +99,4 @@ SERCOM sercom3( SERCOM3 ) ;
void SERCOM0_Handler()
{
Serial1.IrqHandler();
}*/
}*/
19 changes: 8 additions & 11 deletions board_variant/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (25u)
#define NUM_DIGITAL_PINS (24u)
#define NUM_ANALOG_INPUTS (6u)
#define PINS_COUNT (22u)
#define NUM_DIGITAL_PINS (22u)
#define NUM_ANALOG_INPUTS (5u)
#define NUM_ANALOG_OUTPUTS (1u)
#define analogInputToDigitalPin(p) ((p < 6u) ? (p) + PIN_A0 : -1)
#define analogInputToDigitalPin(p) ((p < 5u) ? (p) + PIN_A0 : -1)

#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) )
#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin )
Expand Down Expand Up @@ -97,15 +97,13 @@ extern "C"
#define PIN_A3 (PIN_A0 + 3)
#define PIN_A4 (PIN_A0 + 4)
#define PIN_DAC0 PIN_A0
#define PIN_BATT (23ul)

static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
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 DAC0 = PIN_DAC0;
static const uint8_t BATT = PIN_BATT;

#define ADC_RESOLUTION 12

Expand Down Expand Up @@ -141,10 +139,10 @@ static const uint8_t SCK = PIN_SPI_SCK ;
*/
#define WIRE_INTERFACES_COUNT 1

#define PIN_WIRE_SDA (0u)
#define PIN_WIRE_SCL (2u)
#define PERIPH_WIRE sercom0
#define WIRE_IT_HANDLER SERCOM0_Handler
#define PIN_WIRE_SDA (5u)
#define PIN_WIRE_SCL (6u)
#define PERIPH_WIRE sercom0
#define WIRE_IT_HANDLER SERCOM0_Handler

static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;
Expand Down Expand Up @@ -201,4 +199,3 @@ extern Uart Serial1;
#define SERIAL_PORT_HARDWARE_OPEN Serial1

#endif /* _VARIANT_ARDUINO_ZERO_ */

0 comments on commit 5da6a90

Please sign in to comment.