diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index e38ccd6209a82593538df18fda28ecfba0fb51d2..e270b158cc87a40fe6a5414336596919a63ae328 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -101,44 +101,42 @@ typedef enum _EAnalogChannel #define ADC_CHANNEL_NUMBER_NONE 0xffffffff -// Definitions for PWM channels -typedef enum _EPWMChannel -{ - NOT_ON_PWM=-1, - // PWM_CH0=0, // todo - // PWM_CH1, - // PWM_CH2, - // PWM_CH3, - // PWM_CH4, - // PWM_CH5, - // PWM_CH6, - // PWM_CH7 -} EPWMChannel ; - // Definitions for TC channels typedef enum _ETCChannel { NOT_ON_TIMER=-1, - // TC0_CHA0=0, // todo - // TC0_CHB0, - // TC0_CHA1, - // TC0_CHB1, - // TC0_CHA2, - // TC0_CHB2, - // TC1_CHA3, - // TC1_CHB3, - // TC1_CHA4, - // TC1_CHB4, - // TC1_CHA5, - // TC1_CHB5, - // TC2_CHA6, - // TC2_CHB6, - // TC2_CHA7, - // TC2_CHB7, - // TC2_CHA8, - // TC2_CHB8 + TC3_CH0, + TC3_CH1, + TCC0_CH0, + TCC0_CH1, + TCC0_CH4, + TCC0_CH5, + TCC0_CH6, + TCC0_CH7, + TCC1_CH0, + TCC1_CH1, + TCC2_CH0, + TCC2_CH1 } ETCChannel ; +// Definitions for PWM channels +typedef enum _EPWMChannel +{ + NOT_ON_PWM=-1, + PWM3_CH0=TC3_CH0, + PWM3_CH1=TC3_CH1, + PWM0_CH0=TCC0_CH0, + PWM0_CH1=TCC0_CH1, + PWM0_CH4=TCC0_CH4, + PWM0_CH5=TCC0_CH5, + PWM0_CH6=TCC0_CH6, + PWM0_CH7=TCC0_CH7, + PWM1_CH0=TCC1_CH0, + PWM1_CH1=TCC1_CH1, + PWM2_CH0=TCC2_CH0, + PWM2_CH1=TCC2_CH1 +} EPWMChannel ; + typedef enum _EPortType { NOT_A_PORT=-1, @@ -153,8 +151,7 @@ typedef enum _EPortType typedef enum _EPioType { - PIO_NOT_A_PIN, /* Not under control of a peripheral. */ - PIO_DIGITAL, /* The pin is controlled by PORT. */ + PIO_NOT_A_PIN=-1, /* Not under control of a peripheral. */ PIO_EXTINT, /* The pin is controlled by the associated signal of peripheral A. */ PIO_ANALOG, /* The pin is controlled by the associated signal of peripheral B. */ PIO_SERCOM, /* The pin is controlled by the associated signal of peripheral C. */ @@ -163,10 +160,13 @@ typedef enum _EPioType PIO_TIMER_ALT, /* The pin is controlled by the associated signal of peripheral F. */ PIO_COM, /* The pin is controlled by the associated signal of peripheral G. */ PIO_AC_CLK, /* The pin is controlled by the associated signal of peripheral H. */ + PIO_PWM=PIO_TIMER, + PIO_PWM_ALT=PIO_TIMER_ALT, - PIO_INPUT, /* The pin is controlled by PORT and is an input. */ - PIO_OUTPUT_0, /* The pin is controlled by PORT and is an output with a default level of 0. */ - PIO_OUTPUT_1 /* The pin is controlled by PORT and is an output with a default level of 1. */ + PIO_DIGITAL, /* The pin is controlled by PORT. */ + PIO_INPUT, /* The pin is controlled by PORT and is an input. */ + PIO_INPUT_PULLUP, /* The pin is controlled by PORT and is an input with internal pull-up resistor enabled. */ + PIO_OUTPUT, /* The pin is controlled by PORT and is an output. */ } EPioType ; /** @@ -204,6 +204,7 @@ extern const PinDescription g_APinDescription[] ; #include "WMath.h" #include "HardwareSerial.h" #include "wiring_pulse.h" +#include "delay.h" #endif // __cplusplus diff --git a/cores/arduino/IPAddress.h b/cores/arduino/IPAddress.h index 622efb760518acc867d30ba23bccc4958f422d50..c86089c3adbfd7888a8a2ce6f694a9ab083383bd 100644 --- a/cores/arduino/IPAddress.h +++ b/cores/arduino/IPAddress.h @@ -42,7 +42,7 @@ public: // Overloaded cast operator to allow IPAddress objects to be used where a pointer // to a four-byte uint8_t array is expected - operator uint32_t() const { return *((uint32_t*)_address); }; + operator uint32_t() const { return *((uint32_t*)_address+0); }; bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); }; bool operator==(const uint8_t* addr) const; diff --git a/cores/arduino/RingBuffer.cpp b/cores/arduino/RingBuffer.cpp index f35e5df328ac8be463f84af98231bbcfc7bbe114..c72060d6b124fd20a5e25d71118bac54bff799ba 100644 --- a/cores/arduino/RingBuffer.cpp +++ b/cores/arduino/RingBuffer.cpp @@ -8,7 +8,7 @@ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public @@ -50,17 +50,17 @@ int RingBuffer::read_char() { if(_iTail == _iHead) return -1; - + int value = _aucBuffer[_iTail]; _iTail = nextIndex(_iTail); - + return value; } int RingBuffer::available() { int delta = _iHead - _iTail; - + if(delta < 0) return SERIAL_BUFFER_SIZE + delta; else @@ -71,7 +71,7 @@ int RingBuffer::peek() { if(_iTail == _iHead) return -1; - + return _aucBuffer[_iTail]; } @@ -80,7 +80,7 @@ int RingBuffer::nextIndex(int index) return (uint32_t)(index + 1) % SERIAL_BUFFER_SIZE; } -int RingBuffer::isFull() +bool RingBuffer::isFull() { return (nextIndex(_iTail) == _iHead); -} \ No newline at end of file +} diff --git a/cores/arduino/delay.h b/cores/arduino/delay.h index e26ba81b56a541cce8982cc829d213b96d6af6f7..9382d2c48fc22766c06477ead17119dddf44d415 100644 --- a/cores/arduino/delay.h +++ b/cores/arduino/delay.h @@ -24,6 +24,7 @@ extern "C" { #endif #include <stdint.h> +#include "variant.h" /** * \brief Returns the number of milliseconds since the Arduino board began running the current program. diff --git a/cores/arduino/validation/build_gcc/debug_arduino_zero/IPAddress.o b/cores/arduino/validation/build_gcc/debug_arduino_zero/IPAddress.o new file mode 100644 index 0000000000000000000000000000000000000000..9e63f8d59ab2c5d332ec21f1fed0183b45766ab3 Binary files /dev/null and b/cores/arduino/validation/build_gcc/debug_arduino_zero/IPAddress.o differ diff --git a/cores/arduino/validation/build_gcc/debug_arduino_zero/Print.o b/cores/arduino/validation/build_gcc/debug_arduino_zero/Print.o new file mode 100644 index 0000000000000000000000000000000000000000..7bb921ed00cfc1357c4c3913e0924f911e72f1b9 Binary files /dev/null and b/cores/arduino/validation/build_gcc/debug_arduino_zero/Print.o differ diff --git a/cores/arduino/validation/build_gcc/debug_arduino_zero/Reset.o b/cores/arduino/validation/build_gcc/debug_arduino_zero/Reset.o new file mode 100644 index 0000000000000000000000000000000000000000..c950d3a3ec4dbb3a4a1e0ec848fb0edd7c620ab9 Binary files /dev/null and b/cores/arduino/validation/build_gcc/debug_arduino_zero/Reset.o differ diff --git a/cores/arduino/validation/build_gcc/debug_arduino_zero/RingBuffer.o b/cores/arduino/validation/build_gcc/debug_arduino_zero/RingBuffer.o new file mode 100644 index 0000000000000000000000000000000000000000..4bd676669d25584711b5967f964b8797193a9392 Binary files /dev/null and b/cores/arduino/validation/build_gcc/debug_arduino_zero/RingBuffer.o differ diff --git a/cores/arduino/validation/build_gcc/debug_arduino_zero/main.o b/cores/arduino/validation/build_gcc/debug_arduino_zero/main.o new file mode 100644 index 0000000000000000000000000000000000000000..fde33e4e5f6cc1cfa607411de9a9ea91753925d6 Binary files /dev/null and b/cores/arduino/validation/build_gcc/debug_arduino_zero/main.o differ diff --git a/cores/arduino/validation/build_gcc/debug_arduino_zero/test.o b/cores/arduino/validation/build_gcc/debug_arduino_zero/test.o new file mode 100644 index 0000000000000000000000000000000000000000..6b21d4500e4bf0c52dfabd3538cfb5e2fa199473 Binary files /dev/null and b/cores/arduino/validation/build_gcc/debug_arduino_zero/test.o differ diff --git a/cores/arduino/wiring.c b/cores/arduino/wiring.c index 1bb8e2ab3e94c1cb9df0c257c61f98318ab8c5cd..182e5e1c21cc75c27e49f8272e9f9bec9c3db4a2 100644 --- a/cores/arduino/wiring.c +++ b/cores/arduino/wiring.c @@ -28,7 +28,7 @@ extern "C" { */ extern uint32_t SystemCoreClock=1000000ul ; -void __libc_init_array(void); +//void __libc_init_array(void); /* * Arduino Zero board initialization @@ -40,6 +40,8 @@ void __libc_init_array(void); */ void init( void ) { + uint32_t ul ; + // Set Systick to 1ms interval, common to all Cortex-M variants if ( SysTick_Config( SystemCoreClock / 1000 ) ) { @@ -53,6 +55,12 @@ void init( void ) // Setup PORT for Digital I/O PM->APBBMASK.bit.PORT=1 ; + // Setup all pins (digital and analog) in INPUT mode (default is nothing) + for ( ul = 0 ; ul < NUM_DIGITAL_PINS ; ul++ ) + { + pinMode( ul, INPUT ) ; + } + // Initialize Serial port U(S)ART pins // Todo diff --git a/cores/arduino/wiring_analog.c.disabled b/cores/arduino/wiring_analog.c.disabled index ffdc4e2f049fb023add8926230ec3e0c375aded5..bdc7de8788a32866ba84d3e5163ee9bd33951d43 100644 --- a/cores/arduino/wiring_analog.c.disabled +++ b/cores/arduino/wiring_analog.c.disabled @@ -59,76 +59,6 @@ uint32_t analogRead(uint32_t ulPin) ulChannel = g_APinDescription[ulPin].ulADCChannelNumber ; -#if defined __SAM3U4E__ - switch ( g_APinDescription[ulPin].ulAnalogChannel ) - { - // Handling ADC 10 bits channels - case ADC0 : - case ADC1 : - case ADC2 : - case ADC3 : - case ADC4 : - case ADC5 : - case ADC6 : - case ADC7 : - // Enable the corresponding channel - adc_enable_channel( ADC, ulChannel ); - - // Start the ADC - adc_start( ADC ); - - // Wait for end of conversion - while ((adc_get_status(ADC) & ADC_SR_DRDY) != ADC_SR_DRDY) - ; - - // Read the value - ulValue = adc_get_latest_value(ADC); - ulValue = mapResolution(ulValue, 10, _readResolution); - - // Disable the corresponding channel - adc_disable_channel( ADC, ulChannel ); - - // Stop the ADC - // adc_stop( ADC ) ; // never do adc_stop() else we have to reconfigure the ADC each time - break; - - // Handling ADC 12 bits channels - case ADC8 : - case ADC9 : - case ADC10 : - case ADC11 : - case ADC12 : - case ADC13 : - case ADC14 : - case ADC15 : - // Enable the corresponding channel - adc12b_enable_channel( ADC12B, ulChannel ); - - // Start the ADC12B - adc12b_start( ADC12B ); - - // Wait for end of conversion - while ((adc12b_get_status(ADC12B) & ADC12B_SR_DRDY) != ADC12B_SR_DRDY) - ; - - // Read the value - ulValue = adc12b_get_latest_value(ADC12B) >> 2; - ulValue = mapResolution(ulValue, 12, _readResolution); - - // Stop the ADC12B - // adc12_stop( ADC12B ) ; // never do adc12_stop() else we have to reconfigure the ADC12B each time - - // Disable the corresponding channel - adc12b_disable_channel( ADC12B, ulChannel ); - break; - - // Compiler could yell because we don't handle DAC pins - default : - ulValue=0; - break; - } -#endif - #if defined __SAM3X8E__ || defined __SAM3X8H__ static uint32_t latestSelectedChannel = -1; switch ( g_APinDescription[ulPin].ulAnalogChannel ) diff --git a/cores/arduino/wiring_digital.c.disabled b/cores/arduino/wiring_digital.c.disabled index 7c958de8a56ac8e16e5feac1517bcbd7c0ed6987..091350b35bc465d6a090667ee6d844ed04056bb9 100644 --- a/cores/arduino/wiring_digital.c.disabled +++ b/cores/arduino/wiring_digital.c.disabled @@ -1,5 +1,5 @@ /* - Copyright (c) 2011 Arduino. All right reserved. + Copyright (c) 2014 Arduino. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -22,57 +22,120 @@ extern "C" { #endif -extern void pinMode( uint32_t ulPin, uint32_t ulMode ) +int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral ) { if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) - { - return ; - } + { + return ; + } + + switch ( ulPeripheral ) + { + case PIO_DIGITAL: + case PIO_INPUT: + case PIO_OUTPUT_0: + case PIO_OUTPUT_1: + // Disable peripheral muxing + PORT->Group[g_APinDescription[ulPin].ulPort]->PINCFG[g_APinDescription[ulPin].ulPin].bit.PMUXEN = 1 ; + + // Configure pin mode, if requested + switch ( ulPeripheral ) + { + case PIO_INPUT: + pinMode( ulPin, INPUT ) ; + break ; + + case PIO_INPUT_PULLUP: + pinMode( ulPin, INPUT_PULLUP ) ; + break ; + + case PIO_OUTPUT: + pinMode( ulPin, OUTPUT ) ; + break ; + } + break ; + + case PIO_ANALOG: + PORT->Group[g_APinDescription[ulPin].ulPort]->PMUX[g_APinDescription[ulPin].ulPin]. + PORT->Group[g_APinDescription[ulPin].ulPort]->PINCFG[g_APinDescription[ulPin].ulPin].bit.PMUXEN = 1 ; + + if ( g_APinDescription[ulPin].ulPin < 16 ) + { + PORT->Group[g_APinDescription[ulPin].ulPort]->WRCONFIG.reg=PORT_WRCONFIG_PMUXEN|PORT_WRCONFIG_PINMASK( g_APinDescription[ulPin].ulPin ) ; + } + else + { + PORT->Group[g_APinDescription[ulPin].ulPort]->WRCONFIG.reg=PORT_WRCONFIG_HWSEL|PORT_WRCONFIG_PMUXEN| |PORT_WRCONFIG_PINMASK( g_APinDescription[ulPin].ulPin >> 16 ) ; + } + PORT_WRCONFIG_PMUX() + PORT_WRCONFIG_WRPINCFG + PORT_WRCONFIG_WRPMUX + PORT_WRCONFIG_PINMASK() + break ; + + case PIO_EXTINT: + break ; + + case PIO_SERCOM: + break ; + + case PIO_SERCOM_ALT: + break ; + + case PIO_TIMER: + break ; + + case PIO_TIMER_ALT: + break ; + + case PIO_COM: + break ; + + case PIO_AC_CLK: + break ; + + case PIO_NOT_A_PIN: + return -1 ; + break ; + } +} + +void pinMode( uint32_t ulPin, uint32_t ulMode ) +{ + if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) + { + return ; + } switch ( ulMode ) - { - case INPUT: - /* Enable peripheral for clocking input */ - pmc_enable_periph_clk( g_APinDescription[ulPin].ulPeripheralId ) ; - PIO_Configure( - g_APinDescription[ulPin].pPort, - PIO_INPUT, - g_APinDescription[ulPin].ulPin, - 0 ) ; - break ; - - case INPUT_PULLUP: - /* Enable peripheral for clocking input */ - pmc_enable_periph_clk( g_APinDescription[ulPin].ulPeripheralId ) ; - PIO_Configure( - g_APinDescription[ulPin].pPort, - PIO_INPUT, - g_APinDescription[ulPin].ulPin, - PIO_PULLUP ) ; - break ; - - case OUTPUT: - PIO_Configure( - g_APinDescription[ulPin].pPort, - PIO_OUTPUT_1, - g_APinDescription[ulPin].ulPin, - g_APinDescription[ulPin].ulPinConfiguration ) ; - - /* if all pins are output, disable PIO Controller clocking, reduce power consumption */ - if ( g_APinDescription[ulPin].pPort->PIO_OSR == 0xffffffff ) - { - pmc_disable_periph_clk( g_APinDescription[ulPin].ulPeripheralId ) ; - } - break ; - - default: - break ; - } + { + case INPUT: + // Set pin to input mode + PORT->Group[g_APinDescription[ulPin].ulPort]->PINCFG[g_APinDescription[ulPin].ulPin].reg=(uint8_t)(PORT_PINCFG_INEN) ; + PORT->Group[g_APinDescription[ulPin].ulPort]->DIRCLR.reg = (uint32_t)(1<<g_APinDescription[ulPin].ulPin) ; + break ; + + case INPUT_PULLUP: + // Set pin to input mode with pull-up resistor enabled + PORT->Group[g_APinDescription[ulPin].ulPort]->PINCFG[g_APinDescription[ulPin].ulPin].reg=(uint8_t)(PORT_PINCFG_INEN|PORT_PINCFG_PULLEN) ; + PORT->Group[g_APinDescription[ulPin].ulPort]->DIRCLR.reg = (uint32_t)(1<<g_APinDescription[ulPin].ulPin) ; + break ; + + case OUTPUT: + // Set pin to output mode + PORT->Group[g_APinDescription[ulPin].ulPort]->PINCFG[g_APinDescription[ulPin].ulPin].reg&=~(uint8_t)(PORT_PINCFG_INEN) ; + PORT->Group[g_APinDescription[ulPin].ulPort]->DIRSET.reg = (uint32_t)(1<<g_APinDescription[ulPin].ulPin) ; + break ; + + default: + // do nothing + break ; + } } -extern void digitalWrite( uint32_t ulPin, uint32_t ulVal ) +void digitalWrite( uint32_t ulPin, uint32_t ulVal ) { - /* Handle */ + /* Handle the case the pin isn't usable as PIO */ if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) { return ; @@ -88,17 +151,18 @@ extern void digitalWrite( uint32_t ulPin, uint32_t ulVal ) } } -extern int digitalRead( uint32_t ulPin ) +int digitalRead( uint32_t ulPin ) { + /* Handle the case the pin isn't usable as PIO */ if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) - { - return LOW ; - } - - if ( PIO_Get( g_APinDescription[ulPin].pPort, PIO_INPUT, g_APinDescription[ulPin].ulPin ) == 1 ) - { - return HIGH ; - } + { + return LOW ; + } + + if ( (PORT->Group[g_APinDescription[ulPin].ulPort]->IN.reg & g_APinDescription[ulPin].ulPin) != 0 ) + { + return HIGH ; + } return LOW ; } diff --git a/cores/arduino/wiring_private.h b/cores/arduino/wiring_private.h index 573da03dee0cb645f0c9dd466a9c25ae7cd00165..6200593c8af3fd80b77effbb6890fccafb853e8a 100644 --- a/cores/arduino/wiring_private.h +++ b/cores/arduino/wiring_private.h @@ -8,7 +8,7 @@ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public @@ -28,7 +28,7 @@ extern "C"{ #endif // Includes Atmel CMSIS -#include <chip.h> +#include "sam.h" #include "wiring_constants.h" diff --git a/cores/arduino/wiring_shift.c b/cores/arduino/wiring_shift.c index 302f0b5f90b20faeb137ab4c3de881db2f69697e..1a8e1a48f37daf3846d5c45ab9d12a4501e85911 100644 --- a/cores/arduino/wiring_shift.c +++ b/cores/arduino/wiring_shift.c @@ -8,7 +8,7 @@ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public @@ -16,7 +16,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "Arduino.h" +//#include "Arduino.h" +#include "wiring_private.h" #ifdef __cplusplus extern "C"{ @@ -24,46 +25,46 @@ extern "C"{ uint32_t shiftIn( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder ) { - uint8_t value = 0 ; - uint8_t i ; + uint8_t value = 0 ; + uint8_t i ; - for ( i=0 ; i < 8 ; ++i ) - { - digitalWrite( ulClockPin, HIGH ) ; + for ( i=0 ; i < 8 ; ++i ) + { + digitalWrite( ulClockPin, HIGH ) ; - if ( ulBitOrder == LSBFIRST ) - { - value |= digitalRead( ulDataPin ) << i ; - } - else - { - value |= digitalRead( ulDataPin ) << (7 - i) ; - } + if ( ulBitOrder == LSBFIRST ) + { + value |= digitalRead( ulDataPin ) << i ; + } + else + { + value |= digitalRead( ulDataPin ) << (7 - i) ; + } - digitalWrite( ulClockPin, LOW ) ; - } + digitalWrite( ulClockPin, LOW ) ; + } - return value ; + return value ; } void shiftOut( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder, uint32_t ulVal ) { - uint8_t i ; + uint8_t i ; - for ( i=0 ; i < 8 ; i++ ) + for ( i=0 ; i < 8 ; i++ ) + { + if ( ulBitOrder == LSBFIRST ) + { + digitalWrite( ulDataPin, !!(ulVal & (1 << i)) ) ; + } + else { - if ( ulBitOrder == LSBFIRST ) - { - digitalWrite( ulDataPin, !!(ulVal & (1 << i)) ) ; - } - else - { - digitalWrite( ulDataPin, !!(ulVal & (1 << (7 - i))) ) ; - } + digitalWrite( ulDataPin, !!(ulVal & (1 << (7 - i))) ) ; + } - digitalWrite( ulClockPin, HIGH ) ; - digitalWrite( ulClockPin, LOW ) ; - } + digitalWrite( ulClockPin, HIGH ) ; + digitalWrite( ulClockPin, LOW ) ; + } } #ifdef __cplusplus diff --git a/variants/arduino_zero/variant.cpp b/variants/arduino_zero/variant.cpp index 61b556a3d306bd1f2b8675ee16fb6a202df9068c..711ba1801b6d5ccc3e7b9716f9f40dd1bfce939c 100644 --- a/variants/arduino_zero/variant.cpp +++ b/variants/arduino_zero/variant.cpp @@ -26,8 +26,8 @@ * | 1 | 1 <- TX | PA11 | | EIC/EXTINT[11] ADC/AIN[19] *SERCOM0/PAD[3] SERCOM2/PAD[3] TCC1/WO[1] TCC0/WO[3] * | 2 | ~2 | PA08 | | EIC/NMI ADC/AIN[16] SERCOM0/PAD[0] SERCOM2/PAD[0] *TCC0/WO[0] TCC1/WO[2] * | 3 | ~3 | PA09 | | EIC/EXTINT[9] ADC/AIN[17] SERCOM0/PAD[1] SERCOM2/PAD[1] *TCC0/WO[1] TCC1/WO[3] - * | 4 | ~4 | PA14 | | EIC/EXTINT[14] SERCOM2/PAD[2] SERCOM4/PAD[2] *TC3/WO[0] TCC0/WO[4] - * | 5 | ~5 | PA15 | | EIC/EXTINT[15] SERCOM2/PAD[3] SERCOM4/PAD[3] *TC3/WO[1] TCC0/WO[5] + * | 4 | ~4 | PA14 | | EIC/EXTINT[14] SERCOM2/PAD[2] SERCOM4/PAD[2] TC3/WO[0] *TCC0/WO[4] + * | 5 | ~5 | PA15 | | EIC/EXTINT[15] SERCOM2/PAD[3] SERCOM4/PAD[3] TC3/WO[1] *TCC0/WO[5] * | 6 | ~6 | PA20 | | EIC/EXTINT[4] SERCOM5/PAD[2] SERCOM3/PAD[2] TC7/WO[0] *TCC0/WO[6] * | 7 | ~7 | PA21 | | EIC/EXTINT[5] SERCOM5/PAD[3] SERCOM3/PAD[3] TC7/WO[1] *TCC0/WO[7] * +------------+------------------+--------+-----------------+------------------------------ @@ -90,22 +90,33 @@ extern const PinDescription g_APinDescription[]= // 0/1 - SERCOM/UART (Serial) { PORTA, 10, PIO_SERCOM, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RX: SERCOM0/PAD[2] { PORTA, 11, PIO_SERCOM, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TX: SERCOM0/PAD[3] + =TC3_CH0, + =TC3_CH1, + =TCC0_CH1, + =TCC0_CH4, + =TCC0_CH5, + =TCC0_CH6, + =TCC0_CH7, + =TCC1_CH0, + =TCC1_CH1, + =TCC2_CH0, + PWM2_CH1=TCC2_CH1 // 2..12 - { PORTA, 8, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC0/WO[0] - { PORTA, 9, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC0/WO[1] - { PORTA, 14, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TC3/WO[0] - { PORTA, 15, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TC3/WO[1] - { PORTA, 20, PIO_TIMER_ALT, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC0/WO[6] - { PORTA, 21, PIO_TIMER_ALT, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC0/WO[7] - { PORTA, 6, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC1/WO[0] - { PORTA, 7, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC1/WO[1] - { PORTA, 18, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TC3/WO[0] - { PORTA, 16, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC2/WO[0] - { PORTA, 19, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TC3/WO[1] + { PORTA, 8, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM0_CH0, TCC0_CH0 }, // TCC0/WO[0] + { PORTA, 9, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM0_CH1, TCC0_CH1 }, // TCC0/WO[1] + { PORTA, 14, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM0_CH4, TCC0_CH4 }, // TCC0/WO[4] + { PORTA, 15, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM0_CH5, TCC0_CH5 }, // TCC0/WO[5] + { PORTA, 20, PIO_TIMER_ALT, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM0_CH6, TCC0_CH6 }, // TCC0/WO[6] + { PORTA, 21, PIO_TIMER_ALT, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM0_CH7, TCC0_CH7 }, // TCC0/WO[7] + { PORTA, 6, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM1_CH0, TCC1_CH0 }, // TCC1/WO[0] + { PORTA, 7, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM1_CH1, TCC1_CH1 }, // TCC1/WO[1] + { PORTA, 18, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM3_CH0, TC3_CH0 }, // TC3/WO[0] + { PORTA, 16, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM2_CH0, TCC2_CH0 }, // TCC2/WO[0] + { PORTA, 19, PIO_TIMER, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), NO_ADC, NO_ADC, PWM3_CH1, TC3_CH1 }, // TC3/WO[1] // 13 (LED) - { PORTA, 17, PIO_TIMER, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TCC2/WO[1] + { PORTA, 17, PIO_PWM, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM2_CH1, NOT_ON_TIMER }, // TCC2/WO[1] // 14 (GND) { NOT_A_PORT, 0, PIO_NOT_A_PIN, 0, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, @@ -138,8 +149,8 @@ extern const PinDescription g_APinDescription[]= { PORTA, 2, PIO_ANALOG, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC10, A5, NOT_ON_PWM, NOT_ON_TIMER }, // ADC/AIN[10] // 30..31 - RX/TX LEDS (PB03/PA27) - { PORTB, 3, PIO_DIGITAL, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // use as pure output - { PORTA, 27, PIO_DIGITAL, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // use as pure output + { PORTB, 3, PIO_OUTPUT, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // use as pure output + { PORTA, 27, PIO_OUTPUT, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // use as pure output // 32..33 - USB { PORTA, 28, PIO_COM, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // USB/SOF