Skip to content

Commit 633e3d7

Browse files
authored
Merge pull request arduino#6 from matsujirushi/matsujirushi-patch-2
Fix warning: "digitalPinToInterrupt" redefined
2 parents a55f7b5 + 5234295 commit 633e3d7

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

libraries/SoftwareSerial/SoftwareSerial.cpp

+16-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF];
3131
volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0;
3232
volatile uint8_t SoftwareSerial::_receive_buffer_head = 0;
3333

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+
}
3442

3543
bool SoftwareSerial::listen()
3644
{
@@ -63,7 +71,7 @@ bool SoftwareSerial::stopListening()
6371
{
6472
if (active_object == this)
6573
{
66-
EIC->INTENCLR.reg = EIC_INTENCLR_EXTINT( 1 << digitalPinToInterrupt( _receivePin )) ;
74+
EIC->INTENCLR.reg = EIC_INTENCLR_EXTINT( 1 << DigitalPin_To_Interrupt( _receivePin )) ;
6775
active_object = NULL;
6876
return true;
6977
}
@@ -81,7 +89,7 @@ void SoftwareSerial::recv()
8189
if (_inverse_logic ? rx_pin_read() : !rx_pin_read())
8290
{
8391

84-
EIC->INTENCLR.reg = EIC_INTENCLR_EXTINT( 1 << digitalPinToInterrupt(_receivePin));
92+
EIC->INTENCLR.reg = EIC_INTENCLR_EXTINT( 1 << DigitalPin_To_Interrupt(_receivePin));
8593

8694
// Wait approximately 1/2 of a bit width to "center" the sample
8795
delayMicroseconds(_rx_delay_centering);
@@ -116,7 +124,7 @@ void SoftwareSerial::recv()
116124
// skip the stop bit
117125
delayMicroseconds(_rx_delay_stopbit);
118126

119-
EIC->INTENSET.reg = EIC_INTENSET_EXTINT( 1 << digitalPinToInterrupt(_receivePin));
127+
EIC->INTENSET.reg = EIC_INTENSET_EXTINT( 1 << DigitalPin_To_Interrupt(_receivePin));
120128
}
121129
}
122130

@@ -193,7 +201,7 @@ void SoftwareSerial::begin(long speed)
193201
_tx_delay = bit_delay;
194202

195203
// 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) {
197205
//Wait 1/2 bit - 2 micro seconds (time for interrupt to be served)
198206
_rx_delay_centering = (bit_delay/2) - 2;
199207
//Wait 1 bit - 2 micro seconds (time in each loop iteration)
@@ -257,7 +265,7 @@ size_t SoftwareSerial::write(uint8_t b)
257265
if (inv)
258266
b = ~b;
259267
// 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 ));
261269

262270
// Write the start bit
263271
if (inv)
@@ -287,7 +295,7 @@ size_t SoftwareSerial::write(uint8_t b)
287295
reg->reg |= reg_mask;
288296

289297

290-
EIC->INTENSET.reg = EIC_INTENSET_EXTINT( 1 << digitalPinToInterrupt( _receivePin ) ) ;
298+
EIC->INTENSET.reg = EIC_INTENSET_EXTINT( 1 << DigitalPin_To_Interrupt( _receivePin ) ) ;
291299

292300
delayMicroseconds(delay);
293301

@@ -299,11 +307,11 @@ void SoftwareSerial::flush()
299307
if (!isListening())
300308
return;
301309

302-
EIC->INTENCLR.reg = EIC_INTENCLR_EXTINT( 1 << digitalPinToInterrupt( _receivePin ) ) ;
310+
EIC->INTENCLR.reg = EIC_INTENCLR_EXTINT( 1 << DigitalPin_To_Interrupt( _receivePin ) ) ;
303311

304312
_receive_buffer_head = _receive_buffer_tail = 0;
305313

306-
EIC->INTENSET.reg = EIC_INTENSET_EXTINT( 1 << digitalPinToInterrupt( _receivePin ) ) ;
314+
EIC->INTENSET.reg = EIC_INTENSET_EXTINT( 1 << DigitalPin_To_Interrupt( _receivePin ) ) ;
307315

308316
}
309317

variants/XIAO_m0/variant.h

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#define portInputRegister(port) (&(port->IN.reg))
5252
#define portModeRegister(port) (&(port->DIR.reg))
5353
#define digitalPinHasPWM(P) (g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER)
54-
#define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt)
5554

5655
/*
5756
* digitalPinToTimer(..) is AVR-specific and is not defined for SAMD

0 commit comments

Comments
 (0)