mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
Stm32 port (#71)
* Fix Stm32 Eeprom handler Fix missing parenthesis Fix some type consistencies * Fix #73 Add ability to override config.h with define NO_KNX_CONFIG * change tabs to space * coding style Co-authored-by: etrinh <etrinh@zdionline.net>
This commit is contained in:
parent
4677044f46
commit
f880114da5
@ -39,7 +39,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
|
||||
|
||||
#define getbyte(x,n) (*(((uint8_t*)&(x))+n))
|
||||
#define htons(x) ( (getbyte(x,0)<<8) | getbyte(x,1) )
|
||||
#define htonl(x) ( (getbyte(x,0)<<24) | getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) )
|
||||
#define htonl(x) ( (getbyte(x,0)<<24) | (getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) )
|
||||
#define ntohs(x) htons(x)
|
||||
#define ntohl(x) htonl(x)
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NO_KNX_CONFIG
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
#define SPI_SS_PIN 10
|
||||
#define GPIO_GDO2_PIN 9
|
||||
@ -19,3 +21,5 @@
|
||||
#ifdef USE_USB
|
||||
#define USE_CEMI_SERVER
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -198,12 +198,12 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
||||
_bau.deviceObject().bauNumber(value);
|
||||
}
|
||||
|
||||
void orderNumber(const char* value)
|
||||
void orderNumber(const uint8_t* value)
|
||||
{
|
||||
_bau.deviceObject().orderNumber(value);
|
||||
}
|
||||
|
||||
void hardwareType(uint8_t* value)
|
||||
void hardwareType(const uint8_t* value)
|
||||
{
|
||||
_bau.deviceObject().hardwareType(value);
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
#include "stm32_platform.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_STM32
|
||||
#include <EEPROM.h>
|
||||
#include <stm32_eeprom.h>
|
||||
#include "knx/bits.h"
|
||||
|
||||
Stm32Platform::Stm32Platform() : ArduinoPlatform(&Serial2), eepromPtr(nullptr), eepromSize(0)
|
||||
Stm32Platform::Stm32Platform() : ArduinoPlatform(&Serial2)
|
||||
{
|
||||
}
|
||||
|
||||
Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s), eepromPtr(nullptr), eepromSize(0)
|
||||
Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s)
|
||||
{
|
||||
}
|
||||
|
||||
Stm32Platform::~Stm32Platform()
|
||||
{
|
||||
delete [] eepromPtr;
|
||||
delete [] _eepromPtr;
|
||||
}
|
||||
|
||||
void Stm32Platform::restart()
|
||||
@ -24,19 +24,26 @@ void Stm32Platform::restart()
|
||||
|
||||
uint8_t * Stm32Platform::getEepromBuffer(uint16_t size)
|
||||
{
|
||||
delete [] eepromPtr;
|
||||
eepromPtr = new uint8_t[size];
|
||||
for (uint16_t i = 0; i < size; ++i)
|
||||
eepromPtr[i] = EEPROM[i];
|
||||
return eepromPtr;
|
||||
if (size > E2END + 1)
|
||||
{
|
||||
fatalError();
|
||||
}
|
||||
_eepromSize = size;
|
||||
delete [] _eepromPtr;
|
||||
_eepromPtr = new uint8_t[size];
|
||||
eeprom_buffer_fill();
|
||||
for (uint16_t i = 0; i < size; ++i)
|
||||
_eepromPtr[i] = eeprom_buffered_read_byte(i);
|
||||
return _eepromPtr;
|
||||
}
|
||||
|
||||
void Stm32Platform::commitToEeprom()
|
||||
{
|
||||
if(eepromPtr == nullptr)
|
||||
return;
|
||||
for (uint16_t i = 0; i < eepromSize; ++i)
|
||||
EEPROM.update(i, eepromPtr[i]);
|
||||
if(_eepromPtr == nullptr || _eepromSize == 0)
|
||||
return;
|
||||
for (uint16_t i = 0; i < _eepromSize; ++i)
|
||||
eeprom_buffered_write_byte(i, _eepromPtr[i]);
|
||||
eeprom_buffer_flush();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -15,8 +15,8 @@ public:
|
||||
uint8_t* getEepromBuffer(uint16_t size);
|
||||
void commitToEeprom();
|
||||
private:
|
||||
uint8_t *eepromPtr;
|
||||
uint16_t eepromSize;
|
||||
uint8_t *_eepromPtr = nullptr;
|
||||
uint16_t _eepromSize = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user