Revert "ESP32 - use HardwareSerial instead of SoftwareSerial"
This reverts commit ec686e469e
.
This commit is contained in:
parent
66d83e35d9
commit
9707cfc1ea
4 changed files with 4 additions and 46 deletions
|
@ -6,10 +6,6 @@ env:
|
||||||
- BOARD="arduino:avr:uno"
|
- BOARD="arduino:avr:uno"
|
||||||
- BOARD="arduino:avr:leonardo"
|
- BOARD="arduino:avr:leonardo"
|
||||||
- BOARD="arduino:avr:mega:cpu=atmega2560"
|
- 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:
|
before_install:
|
||||||
# install Arduino IDE
|
# install Arduino IDE
|
||||||
|
|
|
@ -9,11 +9,7 @@ void ISerial::begin(long speed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISerial::listen() {
|
bool ISerial::listen() {
|
||||||
#ifndef ESP32
|
|
||||||
return(_mod->ModuleSerial->listen());
|
return(_mod->ModuleSerial->listen());
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISerial::end() {
|
void ISerial::end() {
|
||||||
|
@ -21,27 +17,15 @@ void ISerial::end() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISerial::isListening() {
|
bool ISerial::isListening() {
|
||||||
#ifndef ESP32
|
|
||||||
return(_mod->ModuleSerial->isListening());
|
return(_mod->ModuleSerial->isListening());
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISerial::stopListening() {
|
bool ISerial::stopListening() {
|
||||||
#ifndef ESP32
|
|
||||||
return(_mod->ModuleSerial->stopListening());
|
return(_mod->ModuleSerial->stopListening());
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISerial::overflow() {
|
bool ISerial::overflow() {
|
||||||
#ifndef ESP32
|
|
||||||
return(_mod->ModuleSerial->overflow());
|
return(_mod->ModuleSerial->overflow());
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ISerial::peek() {
|
int ISerial::peek() {
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
Module::Module(int rx, int tx, int sernum) {
|
Module::Module(int rx, int tx) {
|
||||||
_cs = -1;
|
_cs = -1;
|
||||||
_rx = rx;
|
_rx = rx;
|
||||||
_tx = tx;
|
_tx = tx;
|
||||||
_int0 = -1;
|
_int0 = -1;
|
||||||
_int1 = -1;
|
_int1 = -1;
|
||||||
|
|
||||||
#ifndef ESP32
|
|
||||||
ModuleSerial = new SoftwareSerial(_rx, _tx);
|
ModuleSerial = new SoftwareSerial(_rx, _tx);
|
||||||
#else
|
|
||||||
ModuleSerial = new HardwareSerial(sernum);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Module(int cs, int int0, int int1, SPIClass& spi, SPISettings spiSettings) {
|
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;
|
_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;
|
_cs = cs;
|
||||||
_rx = rx;
|
_rx = rx;
|
||||||
_tx = tx;
|
_tx = tx;
|
||||||
|
@ -33,11 +29,7 @@ Module::Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi, SPISet
|
||||||
_spi = &spi;
|
_spi = &spi;
|
||||||
_spiSettings = spiSettings;
|
_spiSettings = spiSettings;
|
||||||
|
|
||||||
#ifndef ESP32
|
|
||||||
ModuleSerial = new SoftwareSerial(_rx, _tx);
|
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) {
|
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();
|
_spi->begin();
|
||||||
break;
|
break;
|
||||||
case USE_UART:
|
case USE_UART:
|
||||||
#ifndef ESP32
|
|
||||||
ModuleSerial->begin(baudrate);
|
ModuleSerial->begin(baudrate);
|
||||||
#else
|
|
||||||
ModuleSerial->begin(baudrate, _rx, _tx);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case USE_I2C:
|
case USE_I2C:
|
||||||
break;
|
break;
|
||||||
|
|
14
src/Module.h
14
src/Module.h
|
@ -3,9 +3,7 @@
|
||||||
|
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
//#include <Wire.h>
|
//#include <Wire.h>
|
||||||
#ifndef ESP32
|
|
||||||
#include <SoftwareSerial.h>
|
#include <SoftwareSerial.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "TypeDef.h"
|
#include "TypeDef.h"
|
||||||
|
|
||||||
|
@ -24,10 +22,8 @@ class Module {
|
||||||
\param tx Arduino pin to be used as Tx pin for SoftwareSerial communication.
|
\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 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.
|
\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 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 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
|
// public member variables
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Internal SoftwareSerial instance.
|
\brief Internal SoftwareSerial instance.
|
||||||
*/
|
*/
|
||||||
#ifndef ESP32
|
|
||||||
SoftwareSerial* ModuleSerial;
|
SoftwareSerial* ModuleSerial;
|
||||||
#else
|
|
||||||
HardwareSerial* ModuleSerial;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Baud rate of SoftwareSerial UART communication. Defaults to 9600 baud.
|
\brief Baud rate of SoftwareSerial UART communication. Defaults to 9600 baud.
|
||||||
|
|
Loading…
Add table
Reference in a new issue