Skip to content

Commit b161b71

Browse files
committed
Merge branch 'sercom-pads' into zero
2 parents 66f7eef + e951ca9 commit b161b71

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

cores/arduino/SERCOM.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ typedef enum
7979

8080
typedef enum
8181
{
82-
UART_TX_PAD_0 = 0x0ul, //Only for UART
83-
UART_TX_PAD_2 = 0x1ul, //Only for UART
84-
//UART_TX_PAD_1 = 0x0ul, //DON'T USE
85-
//UART_TX_PAD_3 = 0x1ul //DON'T USE
82+
UART_TX_PAD_0 = 0x0ul, // Only for UART
83+
UART_TX_PAD_2 = 0x1ul, // Only for UART
84+
UART_TX_RTS_CTS_PAD_0_2_3 = 0x2ul, // Only for UART with TX on PAD0, RTS on PAD2 and CTS on PAD3
8685
} SercomUartTXPad;
8786

8887
typedef enum

cores/arduino/Uart.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
#include "WVariant.h"
2121
#include "wiring_digital.h"
2222

23-
Uart::Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX)
23+
Uart::Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX)
2424
{
2525
sercom = _s;
2626
uc_pinRX = _pinRX;
2727
uc_pinTX = _pinTX;
28+
uc_padRX=_padRX ;
29+
uc_padTX=_padTX;
2830
}
2931

3032
void Uart::begin(unsigned long baudrate)
@@ -39,8 +41,7 @@ void Uart::begin(unsigned long baudrate, uint8_t config)
3941

4042
sercom->initUART(UART_INT_CLOCK, SAMPLE_RATE_x16, baudrate);
4143
sercom->initFrame(extractCharSize(config), LSB_FIRST, extractParity(config), extractNbStopBit(config));
42-
sercom->initPads(UART_TX_PAD_2, SERCOM_RX_PAD_3);
43-
44+
sercom->initPads(uc_padTX, uc_padRX);
4445

4546
sercom->enableUART();
4647
}
@@ -140,13 +141,3 @@ SercomParityMode Uart::extractParity(uint8_t config)
140141
return SERCOM_ODD_PARITY;
141142
}
142143
}
143-
144-
void SERCOM0_Handler()
145-
{
146-
Serial1.IrqHandler();
147-
}
148-
149-
void SERCOM5_Handler()
150-
{
151-
Serial.IrqHandler();
152-
}

cores/arduino/Uart.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525

2626
#include <cstddef>
2727

28-
2928
class Uart : public HardwareSerial
3029
{
3130
public:
32-
Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX);
31+
Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX);
3332
void begin(unsigned long baudRate);
3433
void begin(unsigned long baudrate, uint8_t config);
3534
void end();
@@ -50,14 +49,12 @@ class Uart : public HardwareSerial
5049

5150
uint8_t uc_pinRX;
5251
uint8_t uc_pinTX;
52+
SercomRXPad uc_padRX;
53+
SercomUartTXPad uc_padTX;
5354

5455
SercomNumberStopBit extractNbStopBit(uint8_t config);
5556
SercomUartCharSize extractCharSize(uint8_t config);
5657
SercomParityMode extractParity(uint8_t config);
5758
};
5859

59-
extern Uart Serial;
60-
extern Uart Serial1;
61-
62-
6360
#endif

variants/arduino_zero/variant.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,15 @@ SERCOM sercom3( SERCOM3 ) ;
207207
SERCOM sercom4( SERCOM4 ) ;
208208
SERCOM sercom5( SERCOM5 ) ;
209209

210-
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX ) ;
211-
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX ) ;
210+
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
211+
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
212+
void SERCOM0_Handler()
213+
{
214+
Serial1.IrqHandler();
215+
}
216+
217+
void SERCOM5_Handler()
218+
{
219+
Serial.IrqHandler();
220+
}
221+

variants/arduino_zero/variant.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ static const uint8_t A5 = PIN_A5 ;
106106
* Serial interfaces
107107
*/
108108
// Serial (EDBG)
109-
#define PIN_SERIAL_RX (31ul)
110-
#define PIN_SERIAL_TX (30ul)
109+
#define PIN_SERIAL_RX (31ul)
110+
#define PIN_SERIAL_TX (30ul)
111+
#define PAD_SERIAL_TX (UART_TX_PAD_2)
112+
#define PAD_SERIAL_RX (SERCOM_RX_PAD_3)
111113

112114
// Serial1
113-
#define PIN_SERIAL1_RX (0ul)
114-
#define PIN_SERIAL1_TX (1ul)
115+
#define PIN_SERIAL1_RX (0ul)
116+
#define PIN_SERIAL1_TX (1ul)
117+
#define PAD_SERIAL1_TX (UART_TX_PAD_2)
118+
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
115119

116120
/*
117121
* SPI Interfaces

0 commit comments

Comments
 (0)