2020-04-02 18:09:53 +02:00
|
|
|
#include "stm32_platform.h"
|
|
|
|
|
|
|
|
#ifdef ARDUINO_ARCH_STM32
|
2020-06-30 14:58:53 +02:00
|
|
|
#include <stm32_eeprom.h>
|
2020-04-02 18:09:53 +02:00
|
|
|
#include "knx/bits.h"
|
|
|
|
|
2021-04-01 09:34:26 +02:00
|
|
|
Stm32Platform::Stm32Platform()
|
|
|
|
#ifndef KNX_NO_DEFAULT_UART
|
|
|
|
: ArduinoPlatform(&Serial2)
|
|
|
|
#endif
|
2020-04-02 18:09:53 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-30 14:58:53 +02:00
|
|
|
Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s)
|
2020-04-02 18:09:53 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Stm32Platform::~Stm32Platform()
|
|
|
|
{
|
2020-06-30 14:58:53 +02:00
|
|
|
delete [] _eepromPtr;
|
2020-04-02 18:09:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Stm32Platform::restart()
|
|
|
|
{
|
|
|
|
NVIC_SystemReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t * Stm32Platform::getEepromBuffer(uint16_t size)
|
|
|
|
{
|
2020-06-30 14:58:53 +02:00
|
|
|
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;
|
2020-04-02 18:09:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Stm32Platform::commitToEeprom()
|
|
|
|
{
|
2020-06-30 14:58:53 +02:00
|
|
|
if(_eepromPtr == nullptr || _eepromSize == 0)
|
|
|
|
return;
|
|
|
|
for (uint16_t i = 0; i < _eepromSize; ++i)
|
|
|
|
eeprom_buffered_write_byte(i, _eepromPtr[i]);
|
|
|
|
eeprom_buffer_flush();
|
2020-04-02 18:09:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|