Skip to content

Commit 93cf5b8

Browse files
committed
Adding flush() and notes on limitations.
1 parent bce65f2 commit 93cf5b8

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

libraries/SoftwareSerial/src/SoftwareSerial.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515
SoftwareSerial support for the Artemis
1616
Any pin can be used for software serial receive or transmit
1717
at 300 to 115200bps and anywhere inbetween.
18-
Limitations:
19-
Uses Timer/Compare module H. This will remove PWM capabilities
18+
Limitations (similar to Arduino core SoftwareSerial):
19+
* RX on one pin at a time.
20+
* No TX and RX at the same time.
21+
* TX gets priority. So if Artemis is receiving a string of characters
22+
and you do a Serial.print() the print will begin immediately and any additional
23+
RX characters will be lost.
24+
* Uses Timer/Compare module H (aka 7). This will remove PWM capabilities
2025
on some pins.
21-
Parity is supported but not checked during RX.
26+
* Parity is supported during TX but not checked during RX.
27+
* Enabling multiple ports causes 115200 RX to fail (because there is additional instance switching overhead)
28+
2229
2330
Development environment specifics:
2431
Arduino IDE 1.8.x
@@ -76,6 +83,9 @@ void SoftwareSerial::begin(uint32_t baudRate)
7683

7784
void SoftwareSerial::listen()
7885
{
86+
// Disable the timer interrupt in the NVIC.
87+
NVIC_DisableIRQ(STIMER_CMPR7_IRQn);
88+
7989
if (ap3_active_softwareserial_handle != NULL)
8090
ap3_active_softwareserial_handle->stopListening(); //Gracefully shut down previous instance
8191

@@ -179,6 +189,14 @@ int SoftwareSerial::peek()
179189
return (rxBuffer[tempTail]);
180190
}
181191

192+
//Wait for TX buffer to get sent
193+
void SoftwareSerial::flush()
194+
{
195+
while (txInUse)
196+
{
197+
}
198+
}
199+
182200
//Returns true if overflow flag is set
183201
//Clears flag when called
184202
bool SoftwareSerial::overflow()

libraries/SoftwareSerial/src/SoftwareSerial.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class SoftwareSerial : public Print
5858
int available();
5959
int read();
6060
int peek();
61+
void flush();
6162
bool overflow();
6263

6364
void rxBit(void);

0 commit comments

Comments
 (0)