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>
#endif
#ifndef KNX_NO_PRINT
Stream* ArduinoPlatform::SerialDebug = &Serial;
#endif
ArduinoPlatform::ArduinoPlatform(HardwareSerial* knxSerial) : _knxSerial(knxSerial)
ArduinoPlatform::ArduinoPlatform() : _knxSerial(nullptr)
{
}
@ -29,7 +31,8 @@ void ArduinoPlatform::fatalError()
void ArduinoPlatform::knxUart( HardwareSerial* serial )
{
closeUart();
if (_knxSerial)
closeUart();
_knxSerial = serial;
setupUart();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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