Skip to content
Snippets Groups Projects
Commit e951ca9b authored by Thibaut VIARD's avatar Thibaut VIARD Committed by Cristian Maglie
Browse files

Adding the ability to choose SERCOM Pads

parent 980947c4
No related branches found
No related tags found
No related merge requests found
......@@ -79,10 +79,9 @@ typedef enum
typedef enum
{
UART_TX_PAD_0 = 0x0ul, //Only for UART
UART_TX_PAD_2 = 0x1ul, //Only for UART
//UART_TX_PAD_1 = 0x0ul, //DON'T USE
//UART_TX_PAD_3 = 0x1ul //DON'T USE
UART_TX_PAD_0 = 0x0ul, // Only for UART
UART_TX_PAD_2 = 0x1ul, // Only for UART
UART_TX_RTS_CTS_PAD_0_2_3 = 0x2ul, // Only for UART with TX on PAD0, RTS on PAD2 and CTS on PAD3
} SercomUartTXPad;
typedef enum
......
......@@ -20,11 +20,13 @@
#include "WVariant.h"
#include "wiring_digital.h"
Uart::Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX)
Uart::Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX)
{
sercom = _s;
uc_pinRX = _pinRX;
uc_pinTX = _pinTX;
uc_padRX=_padRX ;
uc_padTX=_padTX;
}
void Uart::begin(unsigned long baudrate)
......@@ -39,8 +41,7 @@ void Uart::begin(unsigned long baudrate, uint8_t config)
sercom->initUART(UART_INT_CLOCK, SAMPLE_RATE_x16, baudrate);
sercom->initFrame(extractCharSize(config), LSB_FIRST, extractParity(config), extractNbStopBit(config));
sercom->initPads(UART_TX_PAD_2, SERCOM_RX_PAD_3);
sercom->initPads(uc_padTX, uc_padRX);
sercom->enableUART();
}
......@@ -140,13 +141,3 @@ SercomParityMode Uart::extractParity(uint8_t config)
return SERCOM_ODD_PARITY;
}
}
void SERCOM0_Handler()
{
Serial1.IrqHandler();
}
void SERCOM5_Handler()
{
Serial.IrqHandler();
}
......@@ -25,11 +25,10 @@
#include <cstddef>
class Uart : public HardwareSerial
{
public:
Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX);
Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX);
void begin(unsigned long baudRate);
void begin(unsigned long baudrate, uint8_t config);
void end();
......@@ -50,14 +49,12 @@ class Uart : public HardwareSerial
uint8_t uc_pinRX;
uint8_t uc_pinTX;
SercomRXPad uc_padRX;
SercomUartTXPad uc_padTX;
SercomNumberStopBit extractNbStopBit(uint8_t config);
SercomUartCharSize extractCharSize(uint8_t config);
SercomParityMode extractParity(uint8_t config);
};
extern Uart Serial;
extern Uart Serial1;
#endif
......@@ -207,5 +207,15 @@ SERCOM sercom3( SERCOM3 ) ;
SERCOM sercom4( SERCOM4 ) ;
SERCOM sercom5( SERCOM5 ) ;
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX ) ;
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX ) ;
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
void SERCOM0_Handler()
{
Serial1.IrqHandler();
}
void SERCOM5_Handler()
{
Serial.IrqHandler();
}
......@@ -106,12 +106,16 @@ static const uint8_t A5 = PIN_A5 ;
* Serial interfaces
*/
// Serial (EDBG)
#define PIN_SERIAL_RX (31ul)
#define PIN_SERIAL_TX (30ul)
#define PIN_SERIAL_RX (31ul)
#define PIN_SERIAL_TX (30ul)
#define PAD_SERIAL_TX (UART_TX_PAD_2)
#define PAD_SERIAL_RX (SERCOM_RX_PAD_3)
// Serial1
#define PIN_SERIAL1_RX (0ul)
#define PIN_SERIAL1_TX (1ul)
#define PIN_SERIAL1_RX (0ul)
#define PIN_SERIAL1_TX (1ul)
#define PAD_SERIAL1_TX (UART_TX_PAD_2)
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
/*
* SPI Interfaces
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment