added support for the SAMD_21 chip with no EEPROM using the FlashStorage_SAMD emulated EEPROM library

added disable interrupts on the ESP8266 and ESP32 to avoid a crash during FLASH Write of emulated EEPROM
bumped version to 2.0.14
This commit is contained in:
Alex Shepherd
2023-02-07 23:58:45 +13:00
parent 24d6689b24
commit 02be948ed2
3 changed files with 16 additions and 2 deletions

View File

@@ -47,7 +47,11 @@
//------------------------------------------------------------------------
#include "NmraDcc.h"
#ifdef __SAMD21G18A__
#include <FlashStorage_SAMD.h>
#else
#include "EEPROM.h"
#endif
// Uncomment to print DEBUG messages
// #define DEBUG_PRINT
@@ -804,9 +808,18 @@ uint8_t readEEPROM (unsigned int CV)
void writeEEPROM (unsigned int CV, uint8_t Value)
{
EEPROM.write (CV, Value) ;
#if defined(ESP8266) || defined(ESP32)
noInterrupts();
#endif
#if defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
EEPROM.commit();
#endif
#if defined(ESP8266) || defined(ESP32)
interrupts();
#endif
}
bool readyEEPROM()

View File

@@ -128,7 +128,8 @@ typedef struct
#define PRIO_SYSTIC 8 // MUST be higher priority than DCC Irq
#elif defined(ARDUINO_ARCH_RP2040)
#define MAXCV 256 // todo: maybe somebody knows a good define for it
#elif defined(ARDUINO_SAMD_ZERO)
#define MAXCV EEPROM_EMULATION_SIZE
#else
#define MAXCV E2END // the upper limit of the CV value currently defined to max memory.
#endif

View File

@@ -1,5 +1,5 @@
name=NmraDcc
version=2.0.13
version=2.0.14
author=Alex Shepherd, Wolfgang Kuffer, Geoff Bunza, Martin Pischky, Franz-Peter Müller, Sven (littleyoda), Hans Tanner, bugfixes by Jueff
maintainer=Alex Shepherd <kiwi64ajs@gmail.com>
sentence=Enables NMRA DCC Communication