Skip to content

Commit

Permalink
astyle everything
Browse files Browse the repository at this point in the history
  • Loading branch information
thelsing committed Aug 9, 2024
1 parent 44f90bb commit 1ba39e2
Show file tree
Hide file tree
Showing 169 changed files with 8,619 additions and 7,150 deletions.
31 changes: 19 additions & 12 deletions src/arduino_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#include <Arduino.h>
#ifndef KNX_NO_SPI
#include <SPI.h>
#include <SPI.h>
#endif

#ifndef KNX_NO_PRINT
Stream* ArduinoPlatform::SerialDebug = &KNX_DEBUG_SERIAL;
Stream* ArduinoPlatform::SerialDebug = &KNX_DEBUG_SERIAL;
#endif

ArduinoPlatform::ArduinoPlatform() : _knxSerial(nullptr)
Expand All @@ -29,6 +29,7 @@ void ArduinoPlatform::fatalError()
digitalWrite(KNX_LED, HIGH);
else
digitalWrite(KNX_LED, LOW);

#endif
}
}
Expand All @@ -37,6 +38,7 @@ void ArduinoPlatform::knxUart( HardwareSerial* serial )
{
if (_knxSerial)
closeUart();

_knxSerial = serial;
setupUart();
}
Expand All @@ -49,7 +51,8 @@ HardwareSerial* ArduinoPlatform::knxUart()
void ArduinoPlatform::setupUart()
{
_knxSerial->begin(19200, SERIAL_8E1);
while (!_knxSerial)

while (!_knxSerial)
;
}

Expand All @@ -73,7 +76,7 @@ size_t ArduinoPlatform::writeUart(const uint8_t data)
}


size_t ArduinoPlatform::writeUart(const uint8_t *buffer, size_t size)
size_t ArduinoPlatform::writeUart(const uint8_t* buffer, size_t size)
{
//printHex("<p", buffer, size);
return _knxSerial->write(buffer, size);
Expand All @@ -89,16 +92,18 @@ int ArduinoPlatform::readUart()
}


size_t ArduinoPlatform::readBytesUart(uint8_t *buffer, size_t length)
size_t ArduinoPlatform::readBytesUart(uint8_t* buffer, size_t length)
{
size_t toRead = length;
uint8_t* pos = buffer;

while (toRead > 0)
{
size_t val = _knxSerial->readBytes(pos, toRead);
pos += val;
toRead -= val;
}

//printHex("p>", buffer, length);
return length;
}
Expand All @@ -121,7 +126,7 @@ void ArduinoPlatform::closeSpi()
SPI.end();
}

int ArduinoPlatform::readWriteSpi(uint8_t *data, size_t len)
int ArduinoPlatform::readWriteSpi(uint8_t* data, size_t len)
{
SPI.transfer(data, len);
return 0;
Expand All @@ -130,20 +135,22 @@ int ArduinoPlatform::readWriteSpi(uint8_t *data, size_t len)

#ifndef KNX_NO_PRINT
void printUint64(uint64_t value, int base = DEC)
{
{
char buf[8 * sizeof(uint64_t) + 1];
char* str = &buf[sizeof(buf) - 1];
*str = '\0';

uint64_t n = value;
do {
char c = n % base;
n /= base;

*--str = c < 10 ? c + '0' : c + 'A' - 10;
do
{
char c = n % base;
n /= base;

*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while (n > 0);

print(str);
print(str);
}

void print(const char* s)
Expand Down
48 changes: 24 additions & 24 deletions src/arduino_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@
#include "Arduino.h"

#ifndef KNX_DEBUG_SERIAL
#define KNX_DEBUG_SERIAL Serial
#define KNX_DEBUG_SERIAL Serial
#endif

class ArduinoPlatform : public Platform
{
public:
ArduinoPlatform();
ArduinoPlatform(HardwareSerial* knxSerial);
public:
ArduinoPlatform();
ArduinoPlatform(HardwareSerial* knxSerial);

// basic stuff
void fatalError();
// basic stuff
void fatalError();

//uart
virtual void knxUart( HardwareSerial* serial);
virtual HardwareSerial* knxUart();
virtual void setupUart();
virtual void closeUart();
virtual int uartAvailable();
virtual size_t writeUart(const uint8_t data);
virtual size_t writeUart(const uint8_t* buffer, size_t size);
virtual int readUart();
virtual size_t readBytesUart(uint8_t* buffer, size_t length);
virtual void flushUart();
//uart
virtual void knxUart( HardwareSerial* serial);
virtual HardwareSerial* knxUart();
virtual void setupUart();
virtual void closeUart();
virtual int uartAvailable();
virtual size_t writeUart(const uint8_t data);
virtual size_t writeUart(const uint8_t* buffer, size_t size);
virtual int readUart();
virtual size_t readBytesUart(uint8_t* buffer, size_t length);
virtual void flushUart();

//spi
//spi
#ifndef KNX_NO_SPI
void setupSpi() override;
void closeSpi() override;
int readWriteSpi (uint8_t *data, size_t len) override;
void setupSpi() override;
void closeSpi() override;
int readWriteSpi (uint8_t* data, size_t len) override;
#endif
#ifndef KNX_NO_PRINT
static Stream* SerialDebug;
static Stream* SerialDebug;
#endif

protected:
HardwareSerial* _knxSerial;
protected:
HardwareSerial* _knxSerial;
};
Loading

0 comments on commit 1ba39e2

Please sign in to comment.