Commit e7b7e682 authored by Eric Duminil's avatar Eric Duminil
Browse files

Updated lib

parent 8010e1be
Pipeline #6048 passed with stage
in 1 minute and 47 seconds
......@@ -35,19 +35,17 @@ extern "C" {
// and callbacks corresponding to each possible GPIO pins have to be defined
ESP8266SoftwareSerial *ObjList[MAX_PIN + 1];
void ICACHE_RAM_ATTR sws_isr_0() { ObjList[0]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_1() { ObjList[1]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_2() { ObjList[2]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_3() { ObjList[3]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_4() { ObjList[4]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_5() { ObjList[5]->rxRead(); };
void IRAM_ATTR sws_isr_0() { ObjList[0]->rxRead(); };
void IRAM_ATTR sws_isr_1() { ObjList[1]->rxRead(); };
void IRAM_ATTR sws_isr_2() { ObjList[2]->rxRead(); };
void IRAM_ATTR sws_isr_3() { ObjList[3]->rxRead(); };
void IRAM_ATTR sws_isr_4() { ObjList[4]->rxRead(); };
void IRAM_ATTR sws_isr_5() { ObjList[5]->rxRead(); };
// Pin 6 to 11 can not be used
void ICACHE_RAM_ATTR sws_isr_12() { ObjList[12]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_13() { ObjList[13]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_14() { ObjList[14]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_15() { ObjList[15]->rxRead(); };
static boolean SerialBusy = false;
void IRAM_ATTR sws_isr_12() { ObjList[12]->rxRead(); };
void IRAM_ATTR sws_isr_13() { ObjList[13]->rxRead(); };
void IRAM_ATTR sws_isr_14() { ObjList[14]->rxRead(); };
void IRAM_ATTR sws_isr_15() { ObjList[15]->rxRead(); };
static void(*ISRList[MAX_PIN + 1])() = {
sws_isr_0,
......@@ -287,7 +285,6 @@ void ICACHE_RAM_ATTR ESP8266SoftwareSerial::rxRead() {
int pulseBitLength;
bool previousBit = !rxLevel;
bool gotByte = false;
switch (m_getByteState)
{
......@@ -313,7 +310,7 @@ void ICACHE_RAM_ATTR ESP8266SoftwareSerial::rxRead() {
if (propgateBits(previousBit, pulseBitLength - 1))
{
// store byte in buffer
int next = (m_inPos + 1) % m_buffSize;
unsigned int next = (m_inPos + 1) % m_buffSize;
if (next != m_outPos) {
m_buffer[m_inPos] = m_rec;
m_inPos = next;
......@@ -344,7 +341,7 @@ void ICACHE_RAM_ATTR ESP8266SoftwareSerial::rxRead() {
propgateBits(true, 8);
// store the byte in the buffer
int next = (m_inPos + 1) % m_buffSize;
unsigned int next = (m_inPos + 1) % m_buffSize;
if (next != m_outPos) {
m_buffer[m_inPos] = m_rec;
m_inPos = next;
......@@ -359,7 +356,7 @@ void ICACHE_RAM_ATTR ESP8266SoftwareSerial::rxRead() {
if (propgateBits(previousBit, pulseBitLength))
{
// Store the received value in the buffer unless we have an overflow
int next = (m_inPos + 1) % m_buffSize;
unsigned int next = (m_inPos + 1) % m_buffSize;
if (next != m_outPos) {
m_buffer[m_inPos] = m_rec;
m_inPos = next;
......@@ -387,7 +384,7 @@ void ICACHE_RAM_ATTR ESP8266SoftwareSerial::rxRead() {
// Stop bit
WAIT;
// Store the received value in the buffer unless we have an overflow
int next = (m_inPos + 1) % m_buffSize;
unsigned int next = (m_inPos + 1) % m_buffSize;
if (next != m_inPos) {
m_buffer[m_inPos] = rec;
m_inPos = next;
......
# Esp8266EdgeSoftwareSerial
Software serial for the ESP8266 that uses edge triggered interrupts to improve performance.
Incoming characters do not block programs for the time it takes them to arrive, leading to signficant performance improvements when used on serial data ports running at speeds of 9600 baud or less. Note that the slower the data rate, the more useful this driver becomes. For high speeds it doesn't confer as much of an advantage.
Incoming characters do not block programs for the time it takes them to arrive, leading to significant performance improvements when used on serial data ports running at speeds of 9600 baud or less. Note that the slower the data rate, the more useful this driver becomes. For high speeds it doesn't confer as much of an advantage.
You can drop the files into your Arduino sketch folder and use them as straight replacements for the SoftwareSerial library files. Simply replace the < and > characters with double quote characters in the include statement to use the new library:
......@@ -26,11 +26,11 @@ The data is not inverted (that's what false means) and it is using a 128 byte bu
The final parameter (which is true in the above code) selects edge operation.
If you leave the final parameter off your constructor the SoftwareSerial library works in exaclty the same way as the original library. In other words it defaults to non-edge operation.
If you leave the final parameter off your constructor the SoftwareSerial library works in exactly the same way as the original library. In other words it defaults to non-edge operation.
# Late charcters
# Late characters
There is one issue with this implmenentation. It is not guaranteed that the last character of a sequence of characters will be detected when it arrives. This happens because the driver needs to detect a signal change to detect data and some values don't have a signal change at their end.
There is one issue with this implementation. It is not guaranteed that the last character of a sequence of characters will be detected when it arrives. This happens because the driver needs to detect a signal change to detect data and some values don't have a signal change at their end.
The "late" character will be registered when the next character arrives. This is not a problem for devices such as GPS sensors and Air Quality sensors as these transmit data continuously, but it would be an issue if you used this mechanism on a user terminal connection. Having said that, you would not need to use edge triggering on such an interface, as your user will not type so quickly and continuously as to cause a problem.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment