Commit 8010e1be authored by Eric Duminil's avatar Eric Duminil
Browse files

Renaming

parent f1647b8b
Pipeline #6047 passed with stage
in 1 minute and 44 seconds
......@@ -19,10 +19,10 @@ namespace config {
#if defined(ESP8266)
//NOTE: This library requires much less memory than SoftwareSerial.h
# include "src/lib/Esp8266EdgeSoftwareSerial/MySoftwareSerial.h"
# include "src/lib/Esp8266EdgeSoftwareSerial/ESP8266SoftwareSerial.h"
# define S8_RX_PIN 13 // GPIO13, a.k.a. D7, connected to S8 Tx pin.
# define S8_TX_PIN 15 // GPIO15, a.k.a. D8, connected to S8 Rx pin.
MySoftwareSerial S8_serial(S8_RX_PIN, S8_TX_PIN, false, 16); // 16 bytes buffer should be enough.
ESP8266SoftwareSerial S8_serial(S8_RX_PIN, S8_TX_PIN, false, 16); // 16 bytes buffer should be enough.
#endif
#if defined(ESP32)
// GPIO16 connected to S8 Tx pin.
......
/*
MySoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
ESP8266SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
......@@ -27,13 +27,13 @@ extern "C" {
#include "gpio.h"
}
#include "MySoftwareSerial.h"
#include "ESP8266SoftwareSerial.h"
#define MAX_PIN 15
// As the Arduino attachInterrupt has no parameter, lists of objects
// and callbacks corresponding to each possible GPIO pins have to be defined
MySoftwareSerial *ObjList[MAX_PIN + 1];
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(); };
......@@ -68,7 +68,7 @@ static void(*ISRList[MAX_PIN + 1])() = {
sws_isr_15
};
MySoftwareSerial::MySoftwareSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize, bool edge_triggered) {
ESP8266SoftwareSerial::ESP8266SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize, bool edge_triggered) {
m_oneWire = (receivePin == transmitPin);
m_rxValid = m_txValid = m_txEnableValid = false;
m_buffer = NULL;
......@@ -99,7 +99,7 @@ MySoftwareSerial::MySoftwareSerial(int receivePin, int transmitPin, bool inverse
begin(9600);
}
MySoftwareSerial::~MySoftwareSerial() {
ESP8266SoftwareSerial::~ESP8266SoftwareSerial() {
enableRx(false);
if (m_rxValid)
ObjList[m_rxPin] = NULL;
......@@ -107,11 +107,11 @@ MySoftwareSerial::~MySoftwareSerial() {
free(m_buffer);
}
bool MySoftwareSerial::isValidGPIOpin(int pin) {
bool ESP8266SoftwareSerial::isValidGPIOpin(int pin) {
return (pin >= 0 && pin <= 5) || (pin >= 12 && pin <= MAX_PIN);
}
void MySoftwareSerial::begin(long speed) {
void ESP8266SoftwareSerial::begin(long speed) {
// Use getCycleCount() loop to get as exact timing as possible
m_bitTime = F_CPU / speed;
// By default enable interrupt during tx only for low speed
......@@ -121,11 +121,11 @@ void MySoftwareSerial::begin(long speed) {
enableRx(true);
}
long MySoftwareSerial::baudRate() {
long ESP8266SoftwareSerial::baudRate() {
return F_CPU / m_bitTime;
}
void MySoftwareSerial::setTransmitEnablePin(int transmitEnablePin) {
void ESP8266SoftwareSerial::setTransmitEnablePin(int transmitEnablePin) {
if (isValidGPIOpin(transmitEnablePin)) {
m_txEnableValid = true;
m_txEnablePin = transmitEnablePin;
......@@ -137,11 +137,11 @@ void MySoftwareSerial::setTransmitEnablePin(int transmitEnablePin) {
}
}
void MySoftwareSerial::enableIntTx(bool on) {
void ESP8266SoftwareSerial::enableIntTx(bool on) {
m_intTxEnabled = on;
}
void MySoftwareSerial::enableTx(bool on) {
void ESP8266SoftwareSerial::enableTx(bool on) {
if (m_oneWire && m_txValid) {
if (on) {
enableRx(false);
......@@ -157,7 +157,7 @@ void MySoftwareSerial::enableTx(bool on) {
}
}
void MySoftwareSerial::enableRx(bool on) {
void ESP8266SoftwareSerial::enableRx(bool on) {
if (m_rxValid) {
if (on) {
if (m_edge)
......@@ -171,14 +171,14 @@ void MySoftwareSerial::enableRx(bool on) {
}
}
int MySoftwareSerial::read() {
int ESP8266SoftwareSerial::read() {
if (!m_rxValid || (m_inPos == m_outPos)) return -1;
uint8_t ch = m_buffer[m_outPos];
m_outPos = (m_outPos + 1) % m_buffSize;
return ch;
}
int MySoftwareSerial::available() {
int ESP8266SoftwareSerial::available() {
if (!m_rxValid) return 0;
int avail = m_inPos - m_outPos;
if (avail < 0) avail += m_buffSize;
......@@ -187,7 +187,7 @@ int MySoftwareSerial::available() {
#define WAIT { while (ESP.getCycleCount()-start < wait) if (m_intTxEnabled) optimistic_yield(1); wait += m_bitTime; }
size_t MySoftwareSerial::write(uint8_t b) {
size_t ESP8266SoftwareSerial::write(uint8_t b) {
if (!m_txValid) return 0;
if (m_invert) b = ~b;
......@@ -215,22 +215,22 @@ size_t MySoftwareSerial::write(uint8_t b) {
return 1;
}
void MySoftwareSerial::flush() {
void ESP8266SoftwareSerial::flush() {
m_inPos = m_outPos = 0;
}
bool MySoftwareSerial::overflow() {
bool ESP8266SoftwareSerial::overflow() {
bool res = m_overflow;
m_overflow = false;
return res;
}
int MySoftwareSerial::peek() {
int ESP8266SoftwareSerial::peek() {
if (!m_rxValid || (m_inPos == m_outPos)) return -1;
return m_buffer[m_outPos];
}
inline bool MySoftwareSerial::propgateBits(bool level, int pulseBitLength)
inline bool ESP8266SoftwareSerial::propgateBits(bool level, int pulseBitLength)
{
for (int i = 0; i < pulseBitLength; i++)
{
......@@ -247,12 +247,12 @@ inline bool MySoftwareSerial::propgateBits(bool level, int pulseBitLength)
return false;
}
inline void MySoftwareSerial::setWaitingForStart()
inline void ESP8266SoftwareSerial::setWaitingForStart()
{
m_getByteState = awaitingStart;
}
inline void MySoftwareSerial::setStartBit(unsigned long start)
inline void ESP8266SoftwareSerial::setStartBit(unsigned long start)
{
// mark - the start of a pulse
// set the timers and wait for the next pulse
......@@ -263,7 +263,7 @@ inline void MySoftwareSerial::setStartBit(unsigned long start)
m_getByteState = gotStart;
}
void ICACHE_RAM_ATTR MySoftwareSerial::rxRead() {
void ICACHE_RAM_ATTR ESP8266SoftwareSerial::rxRead() {
// Advance the starting point for the samples but compensate for the
// initial delay which occurs before the interrupt is delivered
unsigned long wait = m_bitTime + m_bitTime / 3 - 500;
......@@ -398,4 +398,4 @@ void ICACHE_RAM_ATTR MySoftwareSerial::rxRead() {
// it gets set even when interrupts are disabled
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << m_rxPin);
}
#endif
\ No newline at end of file
#endif
/*
MySoftwareSerial.h
ESP8266SoftwareSerial.h
MySoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
ESP8266SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
......@@ -20,9 +20,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MySoftwareSerial_h
#ifndef ESP8266SoftwareSerial_h
#if defined(ESP8266)
#define MySoftwareSerial_h
#define ESP8266SoftwareSerial_h
#include <inttypes.h>
#include <Stream.h>
......@@ -33,10 +33,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Speed up to 115200 can be used.
class MySoftwareSerial : public Stream {
class ESP8266SoftwareSerial : public Stream {
public:
MySoftwareSerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 64, bool edge_triggered = false);
virtual ~MySoftwareSerial();
ESP8266SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 64, bool edge_triggered = false);
virtual ~ESP8266SoftwareSerial();
void begin(long speed);
long baudRate();
......
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