Revert "ESP32 - use HardwareSerial instead of SoftwareSerial"

This reverts commit ec686e469e.
This commit is contained in:
Bernd Giesecke 2019-09-07 20:23:55 +08:00
parent 66d83e35d9
commit 9707cfc1ea
4 changed files with 4 additions and 46 deletions

View file

@ -6,10 +6,6 @@ env:
- BOARD="arduino:avr:uno"
- BOARD="arduino:avr:leonardo"
- BOARD="arduino:avr:mega:cpu=atmega2560"
- HARDWARE=espressif/esp32 \
CORE=https://github.com/espressif/arduino-esp32/archive/70d0d4648766cea047613062ed50a9ecfc9de31f.tar.gz \
BOARD=espressif:esp32:esp32
before_install:
# install Arduino IDE

View file

@ -9,11 +9,7 @@ void ISerial::begin(long speed) {
}
bool ISerial::listen() {
#ifndef ESP32
return(_mod->ModuleSerial->listen());
#else
return true;
#endif
}
void ISerial::end() {
@ -21,27 +17,15 @@ void ISerial::end() {
}
bool ISerial::isListening() {
#ifndef ESP32
return(_mod->ModuleSerial->isListening());
#else
return true;
#endif
}
bool ISerial::stopListening() {
#ifndef ESP32
return(_mod->ModuleSerial->stopListening());
#else
return true;
#endif
}
bool ISerial::overflow() {
#ifndef ESP32
return(_mod->ModuleSerial->overflow());
#else
return true;
#endif
}
int ISerial::peek() {

View file

@ -1,17 +1,13 @@
#include "Module.h"
Module::Module(int rx, int tx, int sernum) {
Module::Module(int rx, int tx) {
_cs = -1;
_rx = rx;
_tx = tx;
_int0 = -1;
_int1 = -1;
#ifndef ESP32
ModuleSerial = new SoftwareSerial(_rx, _tx);
#else
ModuleSerial = new HardwareSerial(sernum);
#endif
}
Module::Module(int cs, int int0, int int1, SPIClass& spi, SPISettings spiSettings) {
@ -24,7 +20,7 @@ Module::Module(int cs, int int0, int int1, SPIClass& spi, SPISettings spiSetting
_spiSettings = spiSettings;
}
Module::Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi, SPISettings spiSettings, int sernum) {
Module::Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi, SPISettings spiSettings) {
_cs = cs;
_rx = rx;
_tx = tx;
@ -33,11 +29,7 @@ Module::Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi, SPISet
_spi = &spi;
_spiSettings = spiSettings;
#ifndef ESP32
ModuleSerial = new SoftwareSerial(_rx, _tx);
#else
ModuleSerial = new HardwareSerial(sernum);
#endif
}
Module::Module(int cs, int int0, int int1, int int2, SPIClass& spi, SPISettings spiSettings) {
@ -59,11 +51,7 @@ void Module::init(uint8_t interface, uint8_t gpio) {
_spi->begin();
break;
case USE_UART:
#ifndef ESP32
ModuleSerial->begin(baudrate);
#else
ModuleSerial->begin(baudrate, _rx, _tx);
#endif
break;
case USE_I2C:
break;

View file

@ -3,9 +3,7 @@
#include <SPI.h>
//#include <Wire.h>
#ifndef ESP32
#include <SoftwareSerial.h>
#endif
#include "TypeDef.h"
@ -24,10 +22,8 @@ class Module {
\param tx Arduino pin to be used as Tx pin for SoftwareSerial communication.
\param rx Arduino pin to be used as Rx pin for SoftwareSerial communication.
\param sernum number of the HW serial to be used on ESP32. Defaults to 2.
*/
Module(int tx, int rx, int sernum = 2);
Module(int tx, int rx);
/*!
\brief SPI-based module constructor.
@ -77,21 +73,15 @@ class Module {
\param spi SPI interface to be used. Defaults to Arduino hardware SPI interface, can also use software SPI implementations.
\param spiSettings SPI interface settings. Defaults to 2 MHz clock, MSB first, mode 0.
\param sernum number of the HW serial to be used on ESP32. Defaults to 2.
*/
Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), int sernum = 2);
Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0));
// public member variables
/*!
\brief Internal SoftwareSerial instance.
*/
#ifndef ESP32
SoftwareSerial* ModuleSerial;
#else
HardwareSerial* ModuleSerial;
#endif
/*!
\brief Baud rate of SoftwareSerial UART communication. Defaults to 9600 baud.