1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

Adjusted off-by-one naming for Serial object: Serial2/3/4 => Serial1/2/3

This commit is contained in:
Cristian Maglie 2012-10-15 13:34:01 +02:00
parent e92ad6e96e
commit 562324d5f6
3 changed files with 53 additions and 55 deletions

View File

@ -163,9 +163,9 @@ shiftOut KEYWORD2 ShiftOut
tone KEYWORD2 Tone
Serial KEYWORD3 Serial
Serial1 KEYWORD3 Serial
Serial2 KEYWORD3 Serial
Serial3 KEYWORD3 Serial
Serial4 KEYWORD3 Serial
SerialUSB KEYWORD3 Serial
begin KEYWORD2 Serial_Begin
end KEYWORD2 Serial_End

View File

@ -144,15 +144,15 @@ extern const PinDescription g_APinDescription[]=
// 13 - AMBER LED
{ 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
// 14/15 - USART2 (Serial4)
// 14/15 - USART3 (Serial3)
{ 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
// 16/17 - USART1 (Serial3)
// 16/17 - USART1 (Serial2)
{ 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
// 18/19 - USART0 (Serial2)
// 18/19 - USART0 (Serial1)
{ 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
@ -258,11 +258,11 @@ extern const PinDescription g_APinDescription[]=
{ 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 },
// 81 - UART (Serial) all pins
{ 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 },
// 82 - USART0 (Serial2) all pins
// 82 - USART0 (Serial1) all pins
{ 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 },
// 83 - USART1 (Serial3) all pins
// 83 - USART1 (Serial2) all pins
{ 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 },
// 84 - USART3 (Serial4) all pins
// 84 - USART3 (Serial3) all pins
{ 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 },
// 85 - USB
@ -303,24 +303,24 @@ RingBuffer rx_buffer2 ;
RingBuffer rx_buffer3;
RingBuffer rx_buffer4;
USARTClass Serial2( USART0, USART0_IRQn, ID_USART0, &rx_buffer2 ) ;
USARTClass Serial3( USART1, USART1_IRQn, ID_USART1, &rx_buffer3 ) ;
USARTClass Serial4( USART3, USART3_IRQn, ID_USART3, &rx_buffer4 ) ;
USARTClass Serial1(USART0, USART0_IRQn, ID_USART0, &rx_buffer2);
USARTClass Serial2(USART1, USART1_IRQn, ID_USART1, &rx_buffer3);
USARTClass Serial3(USART3, USART3_IRQn, ID_USART3, &rx_buffer4);
// IT handlers
void USART0_Handler(void)
{
Serial2.IrqHandler() ;
Serial1.IrqHandler();
}
void USART1_Handler(void)
{
Serial3.IrqHandler() ;
Serial2.IrqHandler();
}
void USART3_Handler(void)
{
Serial4.IrqHandler() ;
Serial3.IrqHandler();
}
// ----------------------------------------------------------------------------
@ -339,10 +339,10 @@ void init( void )
if (SysTick_Config(SystemCoreClock / 1000))
{
// Capture error
while ( 1 ) ;
while (true);
}
// Disable watchdog, common to all SAM variants
// Disable watchdog
WDT_Disable(WDT);
// Initialize C library
@ -352,16 +352,12 @@ void init( void )
for (int i = 0; i < PINS_COUNT; i++)
digitalWrite(i, LOW);
// Initialize Serial port UART, common to all SAM3 variants
// Initialize Serial port U(S)ART pins
PIO_Configure(
g_APinDescription[PINS_UART].pPort,
g_APinDescription[PINS_UART].ulPinType,
g_APinDescription[PINS_UART].ulPin,
g_APinDescription[PINS_UART].ulPinConfiguration);
Serial.begin(115200);
// Initialize Serial ports USART
PIO_Configure(
g_APinDescription[PINS_USART0].pPort,
g_APinDescription[PINS_USART0].ulPinType,
@ -373,12 +369,12 @@ void init( void )
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);
g_APinDescription[PINS_USART3].pPort,
g_APinDescription[PINS_USART3].ulPinType,
g_APinDescription[PINS_USART3].ulPin,
g_APinDescription[PINS_USART3].ulPinConfiguration);
// Initialize USB
// Initialize USB pins
PIO_Configure(
g_APinDescription[PINS_USB].pPort,
g_APinDescription[PINS_USB].ulPinType,

View File

@ -130,11 +130,14 @@ static const uint8_t SCK = PIN_SPI_SCK ;
/*
* UART/USART Interfaces
*/
// Serial
#define PINS_UART (81u)
// Serial1
#define PINS_USART0 (82u)
// Serial2
#define PINS_USART1 (83u)
#define PINS_USART2 (84u)
// Serial3
#define PINS_USART3 (84u)
/*
* USB Interfaces
@ -202,10 +205,9 @@ static const uint8_t CANTX = 69;
#ifdef __cplusplus
extern UARTClass Serial;
extern USARTClass Serial1;
extern USARTClass Serial2;
extern USARTClass Serial3;
extern USARTClass Serial4 ;
#endif