2011-10-25 16:19:43 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) 2011 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
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-04-28 11:49:28 +02:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2011-10-25 16:19:43 +02:00
|
|
|
See the GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2011-09-13 17:01:32 +02:00
|
|
|
|
|
|
|
#include "variant.h"
|
|
|
|
|
2011-10-27 18:27:19 +02:00
|
|
|
/*
|
|
|
|
* DUE Board pin | PORT
|
|
|
|
* ----------------+--------
|
2012-03-20 13:48:44 +01:00
|
|
|
* 0 RX0 | PA8
|
|
|
|
* 1 TX0 | PA9
|
|
|
|
* 2 TIOA0 | PB25
|
|
|
|
* 3 TIOA7 | PC28
|
|
|
|
* 4 NPCS1 | PA29
|
2012-06-08 22:34:38 +02:00
|
|
|
* TIOB6 | PC26
|
2012-03-20 13:48:44 +01:00
|
|
|
* 5 TIOA6 | PC25
|
|
|
|
* 6 PWML7 | PC24
|
|
|
|
* 7 PWML6 | PC23
|
|
|
|
* 8 PWML5 | PC22
|
|
|
|
* 9 PWML4 | PC21
|
2012-06-08 22:34:38 +02:00
|
|
|
* 10 NPCS0 | PA28
|
|
|
|
* TIOB7 | PC29
|
2012-03-20 13:48:44 +01:00
|
|
|
* 11 TIOA8 | PD7
|
|
|
|
* 12 TIOB8 | PD8
|
|
|
|
* 13 TIOB0 | PB27
|
2012-04-27 14:25:57 +02:00
|
|
|
* 14 TX3 TXD3 | PD4
|
|
|
|
* 15 RX3 RXD3 | PD5
|
2012-03-20 13:48:44 +01:00
|
|
|
* 16 TX2 TXD1 | PA13
|
|
|
|
* 17 RX2 RXD1 | PA12
|
2012-04-27 14:25:57 +02:00
|
|
|
* 18 TX1 TXD0 | PA11
|
|
|
|
* 19 RX1 RXD0 | PA10
|
2012-03-20 13:48:44 +01:00
|
|
|
* 20 SDA | PB12 (this pin is level adapted to 5V)
|
|
|
|
* 21 SCL | PB13 (this pin is level adapted to 5V)
|
|
|
|
* 22 | PB26
|
|
|
|
* 23 | PA14
|
|
|
|
* 24 | PA15
|
|
|
|
* 25 | PD0
|
|
|
|
* 26 | PD1
|
|
|
|
* 27 | PD2
|
|
|
|
* 28 | PD3
|
|
|
|
* 29 | PD6
|
|
|
|
* 30 | PD9
|
|
|
|
* 31 | PA7
|
|
|
|
* 32 | PD10
|
|
|
|
* 33 | PC1
|
|
|
|
* 34 | PC2
|
|
|
|
* 35 | PC3
|
|
|
|
* 36 | PC4
|
|
|
|
* 37 | PC5
|
|
|
|
* 38 | PC6
|
|
|
|
* 39 | PC7
|
|
|
|
* 40 | PC8
|
|
|
|
* 41 | PC9
|
|
|
|
* 42 | PA19
|
|
|
|
* 43 | PA20
|
|
|
|
* 44 | PC19
|
|
|
|
* 45 | PC18
|
|
|
|
* 46 | PC17
|
|
|
|
* 47 | PC16
|
|
|
|
* 48 | PC15
|
|
|
|
* 49 | PC14
|
|
|
|
* 50 | PC13
|
|
|
|
* 51 | PC12
|
2012-06-08 22:34:38 +02:00
|
|
|
* 52 NPCS2 | PB21
|
2012-03-20 13:48:44 +01:00
|
|
|
* 53 | PB14
|
|
|
|
* A0 | PA16
|
|
|
|
* A1 | PA24
|
|
|
|
* A2 | PA23
|
|
|
|
* A3 | PA22
|
2012-08-24 20:53:24 +02:00
|
|
|
* A4 TIOB2 | PA6
|
2012-03-20 13:48:44 +01:00
|
|
|
* A5 | PA4
|
2012-08-24 20:53:24 +02:00
|
|
|
* A6 TIOB1 | PA3
|
|
|
|
* A7 TIOA1 | PA2
|
2012-03-20 13:48:44 +01:00
|
|
|
* A8 | PB17
|
|
|
|
* A9 | PB18
|
|
|
|
* A10 | PB19
|
|
|
|
* A11 | PB20
|
|
|
|
* A12 | PB15
|
|
|
|
* A13 | PB16
|
|
|
|
* A14 | PA1
|
|
|
|
* A15 | PA0
|
|
|
|
* SDA1 | PA17
|
|
|
|
* SCL1 | PA18
|
2011-10-27 18:27:19 +02:00
|
|
|
*
|
|
|
|
*
|
2012-03-20 13:48:44 +01:00
|
|
|
* AT45DB021 pin | PORT
|
2011-10-27 18:27:19 +02:00
|
|
|
* ----------------+--------
|
2012-03-20 13:48:44 +01:00
|
|
|
* SO | PA25
|
|
|
|
* SI | PA26
|
|
|
|
* SCK | PA27
|
2012-06-09 15:02:51 +02:00
|
|
|
* #CS NPCS3 | PB23
|
2011-10-27 18:27:19 +02:00
|
|
|
*
|
|
|
|
*
|
2012-04-28 11:49:28 +02:00
|
|
|
* USB pin | PORT
|
|
|
|
* ----------------+--------
|
|
|
|
* ID | PB11
|
|
|
|
* VBOF | PB10
|
|
|
|
*
|
|
|
|
*
|
2011-10-27 18:27:19 +02:00
|
|
|
* LEDs | PORT
|
|
|
|
* ----------------+--------
|
2012-03-20 13:48:44 +01:00
|
|
|
* "TX" | PA21
|
|
|
|
* "RX" | PC30
|
|
|
|
* "L" | PB27
|
2011-10-27 18:27:19 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-05-02 17:00:55 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-09-13 17:01:32 +02:00
|
|
|
/*
|
|
|
|
* Pins descriptions
|
|
|
|
*/
|
|
|
|
extern const PinDescription g_APinDescription[]=
|
|
|
|
{
|
2011-10-27 18:27:19 +02:00
|
|
|
// 0 .. 53 - Digital pins
|
2011-12-14 13:35:58 +01:00
|
|
|
// ----------------------
|
2011-10-27 18:27:19 +02:00
|
|
|
// 0/1 - UART (Serial)
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA8A_URXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // URXD
|
|
|
|
{ PIOA, PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // UTXD
|
2011-09-13 17:01:32 +02:00
|
|
|
|
2011-10-27 18:27:19 +02:00
|
|
|
// 2
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB25B_TIOA0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC0_CHA0 }, // TIOA0
|
|
|
|
{ PIOC, PIO_PC28B_TIOA7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA7 }, // TIOA7
|
|
|
|
{ PIOC, PIO_PC26B_TIOB6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB6 }, // TIOB6
|
2011-09-13 17:01:32 +02:00
|
|
|
|
2011-10-27 18:27:19 +02:00
|
|
|
// 5
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOC, PIO_PC25B_TIOA6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA6 }, // TIOA6
|
|
|
|
{ PIOC, PIO_PC24B_PWML7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH7, NOT_ON_TIMER }, // PWML7
|
|
|
|
{ PIOC, PIO_PC23B_PWML6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH6, NOT_ON_TIMER }, // PWML6
|
|
|
|
{ PIOC, PIO_PC22B_PWML5, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH5, NOT_ON_TIMER }, // PWML5
|
|
|
|
{ PIOC, PIO_PC21B_PWML4, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH4, NOT_ON_TIMER }, // PWML4
|
2011-10-27 18:27:19 +02:00
|
|
|
// 10
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOC, PIO_PC29B_TIOB7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB7 }, // TIOB7
|
|
|
|
{ PIOD, PIO_PD7B_TIOA8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA8 }, // TIOA8
|
|
|
|
{ PIOD, PIO_PD8B_TIOB8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB8 }, // TIOB8
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 13 - AMBER LED
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB27B_TIOB0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC0_CHB0 }, // TIOB0
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 14/15 - USART2 (Serial4)
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOD, PIO_PD4B_TXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD3
|
|
|
|
{ PIOD, PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD3
|
2011-09-13 17:01:32 +02:00
|
|
|
|
2011-10-27 18:27:19 +02:00
|
|
|
// 16/17 - USART1 (Serial3)
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA13A_TXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD1
|
|
|
|
{ PIOA, PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD1
|
2011-09-13 17:01:32 +02:00
|
|
|
|
2011-10-27 18:27:19 +02:00
|
|
|
// 18/19 - USART0 (Serial2)
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA11A_TXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD0
|
|
|
|
{ PIOA, PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD0
|
2011-10-11 20:46:18 +02:00
|
|
|
|
2011-10-27 18:27:19 +02:00
|
|
|
// 20/21 - TWI1
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB12A_TWD1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWD1 - SDA0
|
|
|
|
{ PIOB, PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWCK1 - SCL0
|
2011-10-11 20:46:18 +02:00
|
|
|
|
2011-10-27 18:27:19 +02:00
|
|
|
// 22
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB26, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 22
|
|
|
|
{ PIOA, PIO_PA14, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 23
|
|
|
|
{ PIOA, PIO_PA15, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 24
|
|
|
|
{ PIOD, PIO_PD0, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 25
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 26
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOD, PIO_PD1, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 26
|
|
|
|
{ PIOD, PIO_PD2, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 27
|
|
|
|
{ PIOD, PIO_PD3, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 28
|
|
|
|
{ PIOD, PIO_PD6, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 29
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 30
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOD, PIO_PD9, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 30
|
|
|
|
{ PIOA, PIO_PA7, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 31
|
|
|
|
{ PIOD, PIO_PD10, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 32
|
|
|
|
{ PIOC, PIO_PC1, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 33
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 34
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOC, PIO_PC2, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 34
|
|
|
|
{ PIOC, PIO_PC3, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 35
|
|
|
|
{ PIOC, PIO_PC4, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 36
|
|
|
|
{ PIOC, PIO_PC5, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 37
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 38
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOC, PIO_PC6, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 38
|
|
|
|
{ PIOC, PIO_PC7, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 39
|
|
|
|
{ PIOC, PIO_PC8, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 40
|
|
|
|
{ PIOC, PIO_PC9, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 41
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 42
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA19, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 42
|
|
|
|
{ PIOA, PIO_PA20, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 43
|
|
|
|
{ PIOC, PIO_PC19, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 44
|
|
|
|
{ PIOC, PIO_PC18, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 45
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 46
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOC, PIO_PC17, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 46
|
|
|
|
{ PIOC, PIO_PC16, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 47
|
|
|
|
{ PIOC, PIO_PC15, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 48
|
|
|
|
{ PIOC, PIO_PC14, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 49
|
2011-10-27 18:27:19 +02:00
|
|
|
|
|
|
|
// 50
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOC, PIO_PC13, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 50
|
|
|
|
{ PIOC, PIO_PC12, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 51
|
|
|
|
{ PIOB, PIO_PB21, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 52
|
|
|
|
{ PIOB, PIO_PB14, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 53
|
2011-12-14 13:35:58 +01:00
|
|
|
|
2012-03-20 13:48:44 +01:00
|
|
|
|
|
|
|
// 54 .. 69 - Analog pins
|
2011-12-14 13:35:58 +01:00
|
|
|
// ----------------------
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA16X1_AD7, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC7, NOT_ON_PWM, NOT_ON_TIMER }, // AD0
|
|
|
|
{ PIOA, PIO_PA24X1_AD6, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC1, ADC6, NOT_ON_PWM, NOT_ON_TIMER }, // AD1
|
|
|
|
{ PIOA, PIO_PA23X1_AD5, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC2, ADC5, NOT_ON_PWM, NOT_ON_TIMER }, // AD2
|
|
|
|
{ PIOA, PIO_PA22X1_AD4, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC3, ADC4, NOT_ON_PWM, NOT_ON_TIMER }, // AD3
|
2011-10-27 18:27:19 +02:00
|
|
|
// 58
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA6X1_AD3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC4, ADC3, NOT_ON_PWM, TC0_CHB2 }, // AD4
|
|
|
|
{ PIOA, PIO_PA4X1_AD2, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC5, ADC2, NOT_ON_PWM, NOT_ON_TIMER }, // AD5
|
|
|
|
{ PIOA, PIO_PA3X1_AD1, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC6, ADC1, NOT_ON_PWM, TC0_CHB1 }, // AD6
|
|
|
|
{ PIOA, PIO_PA2X1_AD0, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC7, ADC0, NOT_ON_PWM, TC0_CHA1 }, // AD7
|
2011-10-27 18:27:19 +02:00
|
|
|
// 62
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB17X1_AD10, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC8, ADC10, NOT_ON_PWM, NOT_ON_TIMER }, // AD8
|
|
|
|
{ PIOB, PIO_PB18X1_AD11, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC9, ADC11, NOT_ON_PWM, NOT_ON_TIMER }, // AD9
|
|
|
|
{ PIOB, PIO_PB19X1_AD12, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC10, ADC12, NOT_ON_PWM, NOT_ON_TIMER }, // AD10
|
|
|
|
{ PIOB, PIO_PB20X1_AD13, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC11, ADC13, NOT_ON_PWM, NOT_ON_TIMER }, // AD11
|
2011-10-27 18:27:19 +02:00
|
|
|
// 66
|
2012-10-05 20:20:27 +02:00
|
|
|
{ PIOB, PIO_PB15X1_DAC0, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC12, DA0, NOT_ON_PWM, NOT_ON_TIMER }, // AD12
|
|
|
|
{ PIOB, PIO_PB16X1_DAC1, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC13, DA1, NOT_ON_PWM, NOT_ON_TIMER }, // AD13
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA1A_CANRX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC14, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // AD14
|
|
|
|
{ PIOA, PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC15, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // AD15
|
2012-03-20 13:48:44 +01:00
|
|
|
|
|
|
|
// 70/71 - TWI0
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA17A_TWD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWD0 - SDA1
|
|
|
|
{ PIOA, PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWCK0 - SCL1
|
2011-10-27 18:27:19 +02:00
|
|
|
|
2012-03-20 13:48:44 +01:00
|
|
|
// 72/73 - LEDs
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOC, PIO_PC30, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // LED AMBER RXL
|
|
|
|
{ PIOA, PIO_PA21, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // LED AMBER TXL
|
2011-10-27 18:27:19 +02:00
|
|
|
|
2012-03-20 13:48:44 +01:00
|
|
|
// 74/75/76 - SPI
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA25A_SPI0_MISO,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // MISO
|
|
|
|
{ PIOA, PIO_PA26A_SPI0_MOSI,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // MOSI
|
|
|
|
{ PIOA, PIO_PA27A_SPI0_SPCK,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // SPCK
|
2011-10-27 18:27:19 +02:00
|
|
|
|
2012-03-20 13:48:44 +01:00
|
|
|
// 77 - SPI CS0
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA28A_SPI0_NPCS0,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS0
|
2011-10-27 18:27:19 +02:00
|
|
|
|
2012-03-20 13:48:44 +01:00
|
|
|
// 78 - SPI CS3 (chip select for onboard AT45DB021)
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB23B_SPI0_NPCS3,ID_PIOB,PIO_PERIPH_B,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS3
|
2011-10-27 18:27:19 +02:00
|
|
|
|
2012-03-20 13:48:44 +01:00
|
|
|
// 79 .. 84 - "All pins" masks
|
2011-10-27 18:27:19 +02:00
|
|
|
|
2012-03-20 13:48:44 +01:00
|
|
|
// 79 - TWI0 all pins
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA17A_TWD0|PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
2012-03-20 13:48:44 +01:00
|
|
|
// 80 - TWI1 all pins
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB12A_TWD1|PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
2012-03-20 13:48:44 +01:00
|
|
|
// 81 - UART (Serial) all pins
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA8A_URXD|PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
2012-03-20 13:48:44 +01:00
|
|
|
// 82 - USART0 (Serial2) all pins
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA11A_TXD0|PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
2012-03-20 13:48:44 +01:00
|
|
|
// 83 - USART1 (Serial3) all pins
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA13A_TXD1|PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
2012-04-27 14:25:57 +02:00
|
|
|
// 84 - USART3 (Serial4) all pins
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOD, PIO_PD4B_TXD3|PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
2011-10-27 18:27:19 +02:00
|
|
|
|
2012-04-28 11:49:28 +02:00
|
|
|
// 85 - USB
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ID - VBOF
|
2012-04-28 11:49:28 +02:00
|
|
|
|
2012-06-08 22:34:38 +02:00
|
|
|
// 86 - SPI CS2
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOB, PIO_PB21B_SPI0_NPCS2, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS2
|
2012-06-08 22:34:38 +02:00
|
|
|
|
|
|
|
// 87 - SPI CS1
|
2012-08-24 20:53:24 +02:00
|
|
|
{ PIOA, PIO_PA29A_SPI0_NPCS1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS1
|
2012-06-08 22:34:38 +02:00
|
|
|
|
2011-12-14 13:35:58 +01:00
|
|
|
// END
|
2012-08-24 20:53:24 +02:00
|
|
|
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }
|
2011-09-13 17:01:32 +02:00
|
|
|
} ;
|
|
|
|
|
2012-05-02 17:00:55 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-13 17:01:32 +02:00
|
|
|
/*
|
|
|
|
* UART objects
|
|
|
|
*/
|
|
|
|
RingBuffer rx_buffer1 ;
|
|
|
|
|
2012-09-28 16:18:22 +02:00
|
|
|
UARTClass Serial( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ;
|
2011-09-13 17:01:32 +02:00
|
|
|
|
|
|
|
// IT handlers
|
2012-03-27 12:20:47 +02:00
|
|
|
void UART_Handler(void)
|
2011-09-13 17:01:32 +02:00
|
|
|
{
|
2012-09-28 16:18:22 +02:00
|
|
|
Serial.IrqHandler() ;
|
2011-09-13 17:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
* USART objects
|
|
|
|
*/
|
|
|
|
RingBuffer rx_buffer2 ;
|
|
|
|
RingBuffer rx_buffer3 ;
|
2011-09-13 18:12:51 +02:00
|
|
|
RingBuffer rx_buffer4 ;
|
2011-09-13 17:01:32 +02:00
|
|
|
|
2011-12-01 15:50:37 +01:00
|
|
|
USARTClass Serial2( USART0, USART0_IRQn, ID_USART0, &rx_buffer2 ) ;
|
|
|
|
USARTClass Serial3( USART1, USART1_IRQn, ID_USART1, &rx_buffer3 ) ;
|
2012-04-27 14:25:57 +02:00
|
|
|
USARTClass Serial4( USART3, USART3_IRQn, ID_USART3, &rx_buffer4 ) ;
|
2011-09-13 17:01:32 +02:00
|
|
|
|
|
|
|
// IT handlers
|
2012-03-27 12:20:47 +02:00
|
|
|
void USART0_Handler( void )
|
2011-09-13 17:01:32 +02:00
|
|
|
{
|
|
|
|
Serial2.IrqHandler() ;
|
|
|
|
}
|
|
|
|
|
2012-03-27 12:20:47 +02:00
|
|
|
void USART1_Handler( void )
|
2011-09-13 17:01:32 +02:00
|
|
|
{
|
|
|
|
Serial3.IrqHandler() ;
|
|
|
|
}
|
|
|
|
|
2012-04-27 14:25:57 +02:00
|
|
|
void USART3_Handler( void )
|
2011-09-13 18:12:51 +02:00
|
|
|
{
|
|
|
|
Serial4.IrqHandler() ;
|
|
|
|
}
|
|
|
|
|
2011-09-13 17:01:32 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-09-19 16:23:39 +02:00
|
|
|
void __libc_init_array(void);
|
|
|
|
|
|
|
|
void init( void )
|
2011-09-13 17:01:32 +02:00
|
|
|
{
|
2011-10-27 18:27:19 +02:00
|
|
|
SystemInit() ;
|
2011-09-13 17:01:32 +02:00
|
|
|
|
2011-12-07 00:22:03 +01:00
|
|
|
// Set Systick to 1ms interval, common to all SAM3 variants
|
2011-10-27 18:27:19 +02:00
|
|
|
if ( SysTick_Config( SystemCoreClock / 1000 ) )
|
2011-09-13 17:01:32 +02:00
|
|
|
{
|
2011-12-07 00:22:03 +01:00
|
|
|
// Capture error
|
2011-09-13 17:01:32 +02:00
|
|
|
while ( 1 ) ;
|
2011-10-27 18:27:19 +02:00
|
|
|
}
|
2011-09-13 17:01:32 +02:00
|
|
|
|
2011-12-07 00:22:03 +01:00
|
|
|
// Disable watchdog, common to all SAM variants
|
2011-09-13 17:01:32 +02:00
|
|
|
WDT_Disable( WDT ) ;
|
|
|
|
|
2012-09-19 16:23:39 +02:00
|
|
|
// Initialize C library
|
|
|
|
__libc_init_array();
|
|
|
|
|
2011-09-13 18:12:51 +02:00
|
|
|
// Initialize Serial port UART, common to all SAM3 variants
|
2011-12-05 14:28:51 +01:00
|
|
|
PIO_Configure(
|
|
|
|
g_APinDescription[PINS_UART].pPort,
|
|
|
|
g_APinDescription[PINS_UART].ulPinType,
|
|
|
|
g_APinDescription[PINS_UART].ulPin,
|
|
|
|
g_APinDescription[PINS_UART].ulPinConfiguration);
|
|
|
|
|
2012-09-28 16:18:22 +02:00
|
|
|
Serial.begin(115200);
|
2012-04-30 19:34:27 +02:00
|
|
|
|
2011-12-05 14:28:51 +01:00
|
|
|
// Initialize Serial ports USART
|
|
|
|
PIO_Configure(
|
|
|
|
g_APinDescription[PINS_USART0].pPort,
|
|
|
|
g_APinDescription[PINS_USART0].ulPinType,
|
|
|
|
g_APinDescription[PINS_USART0].ulPin,
|
|
|
|
g_APinDescription[PINS_USART0].ulPinConfiguration);
|
|
|
|
PIO_Configure(
|
|
|
|
g_APinDescription[PINS_USART1].pPort,
|
|
|
|
g_APinDescription[PINS_USART1].ulPinType,
|
|
|
|
g_APinDescription[PINS_USART1].ulPin,
|
|
|
|
g_APinDescription[PINS_USART1].ulPinConfiguration);
|
|
|
|
PIO_Configure(
|
|
|
|
g_APinDescription[PINS_USART2].pPort,
|
|
|
|
g_APinDescription[PINS_USART2].ulPinType,
|
|
|
|
g_APinDescription[PINS_USART2].ulPin,
|
|
|
|
g_APinDescription[PINS_USART2].ulPinConfiguration);
|
2011-11-17 16:56:47 +01:00
|
|
|
|
2012-04-28 11:49:28 +02:00
|
|
|
// Initialize USB
|
|
|
|
PIO_Configure(
|
|
|
|
g_APinDescription[PINS_USB].pPort,
|
|
|
|
g_APinDescription[PINS_USB].ulPinType,
|
|
|
|
g_APinDescription[PINS_USB].ulPin,
|
|
|
|
g_APinDescription[PINS_USB].ulPinConfiguration);
|
|
|
|
|
2012-08-24 20:53:24 +02:00
|
|
|
// Initialize Analog Controller
|
2012-04-28 11:49:28 +02:00
|
|
|
pmc_enable_periph_clk( ID_ADC ) ;
|
2012-04-11 19:30:13 +02:00
|
|
|
adc_init( ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST ) ;
|
|
|
|
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
|
|
|
|
adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger.
|
|
|
|
adc_disable_interrupt( ADC, 0xFFFFFFFF ) ; // Disable all ADC interrupts.
|
|
|
|
adc_disable_all_channel( ADC ) ;
|
2011-11-17 16:56:47 +01:00
|
|
|
|
2011-12-07 00:22:03 +01:00
|
|
|
// Initialize analogOutput module
|
|
|
|
analogOutputInit();
|
2011-09-13 17:01:32 +02:00
|
|
|
}
|
2012-05-02 17:00:55 +02:00
|
|
|
|
2011-09-13 17:01:32 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|