-
Notifications
You must be signed in to change notification settings - Fork 1
/
Adjustment for Software Serial and SDI12 library conflict.txt
95 lines (76 loc) · 2.12 KB
/
Adjustment for Software Serial and SDI12 library conflict.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
**Contributed by Kevin Smith of Stroud Research Center**
If you look at the SoftwareSerial library -
https://github.com/arduino/Arduino/blob/master/libraries/SoftwareSerial/SoftwareSerial.cpp
- you will see a section of code copied below:
#if defined(PCINT0_vect)
ISR(PCINT0_vect)
{
SoftwareSerial::handle_interrupt();
}
#endif
#if defined(PCINT1_vect)
ISR(PCINT1_vect)
{
SoftwareSerial::handle_interrupt();
}
#endif
#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
SoftwareSerial::handle_interrupt();
}
#endif
#if defined(PCINT3_vect)
ISR(PCINT3_vect)
{
SoftwareSerial::handle_interrupt();
}
#endif
It basically says, if the hardware has something called PCINT0, PCINT1, PCINT2, or PCINT3,
claim it for the SoftwareSerial library to use. ArduinoUNO only has up to PCINT2, but
other models have more PCINTs available.
Anyway, we do not need to be so greedy. We only need pins 2 and 3 for SoftwareSerial, which
is PCINT2. So we simply "comment out" the sections in the SoftwareSerial library that
we aren't using for SoftwareSerial. Commenting out is better than deleting, since you
may want to get this functionality back later.
//#if defined(PCINT0_vect)
//ISR(PCINT0_vect)
//{
// SoftwareSerial::handle_interrupt();
//}
//#endif
//#if defined(PCINT1_vect)
//ISR(PCINT1_vect)
//{
// SoftwareSerial::handle_interrupt();
//}
//#endif
#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
SoftwareSerial::handle_interrupt();
}
#endif
//#if defined(PCINT3_vect)
//ISR(PCINT3_vect)
//{
// SoftwareSerial::handle_interrupt();
//}
//#endif
Next, we are going to do the complementary action in the SDI-12 Library, which is also
being greedy. Since we are using pin 9 for SDI-12, we give it to PCINT0:
//6.3
#if defined(PCINT0_vect)
ISR(PCINT0_vect){ SDI12::handleInterrupt(); }
#endif
//#if defined(PCINT1_vect)
//ISR(PCINT1_vect){ SDI12::handleInterrupt(); }
//#endif
//#if defined(PCINT2_vect)
//ISR(PCINT2_vect){ SDI12::handleInterrupt(); }
//#endif
//#if defined(PCINT3_vect)
//ISR(PCINT3_vect){ SDI12::handleInterrupt(); }
//#endif
Restart the Arduino IDE, and it should recognize the changes to the libraries and your
code should compile without issue.