@@ -31,6 +31,14 @@ char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF];
31
31
volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0 ;
32
32
volatile uint8_t SoftwareSerial::_receive_buffer_head = 0 ;
33
33
34
+ static EExt_Interrupts DigitalPin_To_Interrupt (uint8_t pin)
35
+ {
36
+ #if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
37
+ return g_APinDescription[pin].ulExtInt ;
38
+ #else
39
+ return digitalPinToInterrupt (pin);
40
+ #endif
41
+ }
34
42
35
43
bool SoftwareSerial::listen ()
36
44
{
@@ -63,7 +71,7 @@ bool SoftwareSerial::stopListening()
63
71
{
64
72
if (active_object == this )
65
73
{
66
- EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << digitalPinToInterrupt ( _receivePin )) ;
74
+ EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << DigitalPin_To_Interrupt ( _receivePin )) ;
67
75
active_object = NULL ;
68
76
return true ;
69
77
}
@@ -81,7 +89,7 @@ void SoftwareSerial::recv()
81
89
if (_inverse_logic ? rx_pin_read () : !rx_pin_read ())
82
90
{
83
91
84
- EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << digitalPinToInterrupt (_receivePin));
92
+ EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << DigitalPin_To_Interrupt (_receivePin));
85
93
86
94
// Wait approximately 1/2 of a bit width to "center" the sample
87
95
delayMicroseconds (_rx_delay_centering);
@@ -116,7 +124,7 @@ void SoftwareSerial::recv()
116
124
// skip the stop bit
117
125
delayMicroseconds (_rx_delay_stopbit);
118
126
119
- EIC->INTENSET .reg = EIC_INTENSET_EXTINT ( 1 << digitalPinToInterrupt (_receivePin));
127
+ EIC->INTENSET .reg = EIC_INTENSET_EXTINT ( 1 << DigitalPin_To_Interrupt (_receivePin));
120
128
}
121
129
}
122
130
@@ -193,7 +201,7 @@ void SoftwareSerial::begin(long speed)
193
201
_tx_delay = bit_delay;
194
202
195
203
// Only setup rx when we have a valid PCINT for this pin
196
- if (digitalPinToInterrupt (_receivePin)!=NOT_AN_INTERRUPT) {
204
+ if (DigitalPin_To_Interrupt (_receivePin)!=NOT_AN_INTERRUPT) {
197
205
// Wait 1/2 bit - 2 micro seconds (time for interrupt to be served)
198
206
_rx_delay_centering = (bit_delay/2 ) - 2 ;
199
207
// Wait 1 bit - 2 micro seconds (time in each loop iteration)
@@ -257,7 +265,7 @@ size_t SoftwareSerial::write(uint8_t b)
257
265
if (inv)
258
266
b = ~b;
259
267
// turn off interrupts for a clean txmit
260
- EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << digitalPinToInterrupt ( _receivePin ));
268
+ EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << DigitalPin_To_Interrupt ( _receivePin ));
261
269
262
270
// Write the start bit
263
271
if (inv)
@@ -287,7 +295,7 @@ size_t SoftwareSerial::write(uint8_t b)
287
295
reg->reg |= reg_mask;
288
296
289
297
290
- EIC->INTENSET .reg = EIC_INTENSET_EXTINT ( 1 << digitalPinToInterrupt ( _receivePin ) ) ;
298
+ EIC->INTENSET .reg = EIC_INTENSET_EXTINT ( 1 << DigitalPin_To_Interrupt ( _receivePin ) ) ;
291
299
292
300
delayMicroseconds (delay);
293
301
@@ -299,11 +307,11 @@ void SoftwareSerial::flush()
299
307
if (!isListening ())
300
308
return ;
301
309
302
- EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << digitalPinToInterrupt ( _receivePin ) ) ;
310
+ EIC->INTENCLR .reg = EIC_INTENCLR_EXTINT ( 1 << DigitalPin_To_Interrupt ( _receivePin ) ) ;
303
311
304
312
_receive_buffer_head = _receive_buffer_tail = 0 ;
305
313
306
- EIC->INTENSET .reg = EIC_INTENSET_EXTINT ( 1 << digitalPinToInterrupt ( _receivePin ) ) ;
314
+ EIC->INTENSET .reg = EIC_INTENSET_EXTINT ( 1 << DigitalPin_To_Interrupt ( _receivePin ) ) ;
307
315
308
316
}
309
317
0 commit comments