Add KNX_NO_DEFAULT_UART to avoid default uart assignation for ArduinoPlatforms and derivatives, with associated defines (HWSERIAL_NONE for stm32) to recover RAM from unused RX/TX buffers

Remove ArduinoPlatform(HardwareSerial* knxSerial) constructor, seems not useable by KnxFacade
This commit is contained in:
etrinh 2021-03-12 19:57:22 +01:00
parent 446ea1b9aa
commit a4c4288a19
10 changed files with 24 additions and 29 deletions

View File

@ -6,9 +6,11 @@
#include <SPI.h> #include <SPI.h>
#endif #endif
#ifndef KNX_NO_PRINT
Stream* ArduinoPlatform::SerialDebug = &Serial; Stream* ArduinoPlatform::SerialDebug = &Serial;
#endif
ArduinoPlatform::ArduinoPlatform(HardwareSerial* knxSerial) : _knxSerial(knxSerial) ArduinoPlatform::ArduinoPlatform() : _knxSerial(nullptr)
{ {
} }
@ -29,6 +31,7 @@ void ArduinoPlatform::fatalError()
void ArduinoPlatform::knxUart( HardwareSerial* serial ) void ArduinoPlatform::knxUart( HardwareSerial* serial )
{ {
if (_knxSerial)
closeUart(); closeUart();
_knxSerial = serial; _knxSerial = serial;
setupUart(); setupUart();

View File

@ -2,12 +2,10 @@
#include "Arduino.h" #include "Arduino.h"
extern Stream& _serialDBG;
class ArduinoPlatform : public Platform class ArduinoPlatform : public Platform
{ {
public: public:
ArduinoPlatform(HardwareSerial* knxSerial); ArduinoPlatform();
// basic stuff // basic stuff
void fatalError(); void fatalError();
@ -29,7 +27,9 @@ class ArduinoPlatform : public Platform
void closeSpi() override; void closeSpi() override;
int readWriteSpi (uint8_t *data, size_t len) override; int readWriteSpi (uint8_t *data, size_t len) override;
#endif #endif
#ifndef KNX_NO_PRINT
static Stream* SerialDebug; static Stream* SerialDebug;
#endif
protected: protected:
HardwareSerial* _knxSerial; HardwareSerial* _knxSerial;

View File

@ -6,12 +6,11 @@
#include "knx/bits.h" #include "knx/bits.h"
Esp32Platform::Esp32Platform() : ArduinoPlatform(&Serial1) Esp32Platform::Esp32Platform()
{
}
Esp32Platform::Esp32Platform(HardwareSerial* s) : ArduinoPlatform(s)
{ {
#ifndef KNX_NO_DEFAULT_UART
_knxSerial = &Serial1;
#endif
} }
uint32_t Esp32Platform::currentIpAddress() uint32_t Esp32Platform::currentIpAddress()

View File

@ -8,7 +8,6 @@ class Esp32Platform : public ArduinoPlatform
{ {
public: public:
Esp32Platform(); Esp32Platform();
Esp32Platform(HardwareSerial* s);
// ip stuff // ip stuff
uint32_t currentIpAddress() override; uint32_t currentIpAddress() override;

View File

@ -7,12 +7,11 @@
#include "knx/bits.h" #include "knx/bits.h"
EspPlatform::EspPlatform() : ArduinoPlatform(&Serial) EspPlatform::EspPlatform()
{
}
EspPlatform::EspPlatform( HardwareSerial* s) : ArduinoPlatform(s)
{ {
#ifndef KNX_NO_DEFAULT_UART
_knxSerial = &Serial;
#endif
} }
uint32_t EspPlatform::currentIpAddress() uint32_t EspPlatform::currentIpAddress()

View File

@ -8,7 +8,6 @@ class EspPlatform : public ArduinoPlatform
{ {
public: public:
EspPlatform(); EspPlatform();
EspPlatform(HardwareSerial* s);
// ip stuff // ip stuff
uint32_t currentIpAddress() override; uint32_t currentIpAddress() override;

View File

@ -6,12 +6,11 @@
#include <Arduino.h> #include <Arduino.h>
#include <FlashAsEEPROM.h> #include <FlashAsEEPROM.h>
SamdPlatform::SamdPlatform() : ArduinoPlatform(&Serial1) SamdPlatform::SamdPlatform()
{
}
SamdPlatform::SamdPlatform( HardwareSerial* s) : ArduinoPlatform(s)
{ {
#ifndef KNX_NO_DEFAULT_UART
_knxSerial = &Serial1;
#endif
} }
void SamdPlatform::restart() void SamdPlatform::restart()

View File

@ -8,7 +8,6 @@ class SamdPlatform : public ArduinoPlatform
{ {
public: public:
SamdPlatform(); SamdPlatform();
SamdPlatform( HardwareSerial* s);
void restart(); void restart();
uint8_t* getEepromBuffer(uint16_t size); uint8_t* getEepromBuffer(uint16_t size);

View File

@ -4,12 +4,11 @@
#include <stm32_eeprom.h> #include <stm32_eeprom.h>
#include "knx/bits.h" #include "knx/bits.h"
Stm32Platform::Stm32Platform() : ArduinoPlatform(&Serial2) Stm32Platform::Stm32Platform()
{
}
Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s)
{ {
#ifndef KNX_NO_DEFAULT_UART
_knxSerial = &Serial2;
#endif
} }
Stm32Platform::~Stm32Platform() Stm32Platform::~Stm32Platform()

View File

@ -5,7 +5,6 @@ class Stm32Platform : public ArduinoPlatform
{ {
public: public:
Stm32Platform(); Stm32Platform();
Stm32Platform( HardwareSerial* s);
~Stm32Platform(); ~Stm32Platform();
// basic stuff // basic stuff