24
24
#define NO_CTS_PIN 255
25
25
#define RTS_RX_THRESHOLD 10
26
26
27
- Uart::Uart (SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX)
27
+ Uart::Uart (SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX) :
28
+ Uart(_s, _pinRX, _pinTX, _padRX, _padTX, NO_RTS_PIN, NO_CTS_PIN)
29
+ {
30
+ }
31
+
32
+ Uart::Uart (SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX, uint8_t _pinRTS, uint8_t _pinCTS)
28
33
{
29
34
sercom = _s;
30
35
uc_pinRX = _pinRX;
31
36
uc_pinTX = _pinTX;
32
37
uc_padRX = _padRX ;
33
38
uc_padTX = _padTX;
34
- uc_pinRTS = NO_RTS_PIN ;
35
- uc_pinCTS = NO_CTS_PIN ;
39
+ uc_pinRTS = _pinRTS ;
40
+ uc_pinCTS = _pinCTS ;
36
41
}
37
42
38
43
void Uart::begin (unsigned long baudrate)
@@ -45,11 +50,8 @@ void Uart::begin(unsigned long baudrate, uint16_t config)
45
50
pinPeripheral (uc_pinRX, g_APinDescription[uc_pinRX].ulPinType );
46
51
pinPeripheral (uc_pinTX, g_APinDescription[uc_pinTX].ulPinType );
47
52
48
- if (uc_pinRTS != NO_RTS_PIN) {
53
+ if (uc_padTX == UART_TX_RTS_CTS_PAD_0_2_3 && uc_pinRTS != NO_RTS_PIN && uc_pinCTS != NO_CTS_PIN ) {
49
54
pinPeripheral (uc_pinRTS, g_APinDescription[uc_pinRTS].ulPinType );
50
- }
51
-
52
- if (uc_pinCTS != NO_CTS_PIN) {
53
55
pinPeripheral (uc_pinCTS, g_APinDescription[uc_pinCTS].ulPinType );
54
56
}
55
57
@@ -62,11 +64,6 @@ void Uart::begin(unsigned long baudrate, uint16_t config)
62
64
63
65
void Uart::end ()
64
66
{
65
- if (uc_pinRTS != NO_RTS_PIN) {
66
- digitalWrite (uc_pinRTS, LOW);
67
- pinMode (uc_pinRTS, INPUT);
68
- }
69
-
70
67
sercom->resetUART ();
71
68
rxBuffer.clear ();
72
69
txBuffer.clear ();
@@ -205,25 +202,3 @@ SercomParityMode Uart::extractParity(uint16_t config)
205
202
return SERCOM_ODD_PARITY;
206
203
}
207
204
}
208
-
209
- int Uart::attachRts (uint8_t pin)
210
- {
211
- if (uc_padTX == UART_TX_RTS_CTS_PAD_0_2_3) {
212
- uc_pinRTS = pin;
213
-
214
- return 1 ;
215
- }
216
-
217
- return 0 ;
218
- }
219
-
220
- int Uart::attachCts (uint8_t pin)
221
- {
222
- if (uc_padTX == UART_TX_RTS_CTS_PAD_0_2_3) {
223
- uc_pinCTS = pin;
224
-
225
- return 1 ;
226
- }
227
-
228
- return 0 ;
229
- }
0 commit comments