Add support for Raspberry Pico (#56)
* fix ESP32 bug on interrupt reinitialisation * - add first version of Raspberry Pico support * - add first version of Raspberry Pico support * Fix problem with missing type PinStatus merge changes from master project * fix encoding issue
This commit is contained in:
40
NmraDcc.cpp
40
NmraDcc.cpp
@@ -38,6 +38,7 @@
|
|||||||
// 2018-12-17 added ESP32 support by Trusty (thierry@lapajaparis.net)
|
// 2018-12-17 added ESP32 support by Trusty (thierry@lapajaparis.net)
|
||||||
// 2019-02-17 added ESP32 specific changes by Hans Tanner
|
// 2019-02-17 added ESP32 specific changes by Hans Tanner
|
||||||
// 2020-05-15 changes to pass NMRA Tests ( always search for preamble )
|
// 2020-05-15 changes to pass NMRA Tests ( always search for preamble )
|
||||||
|
// 2021-03-11 fix ESP32 bug on interrupt reinitialisation
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// purpose: Provide a simplified interface to decode NMRA DCC packets
|
// purpose: Provide a simplified interface to decode NMRA DCC packets
|
||||||
@@ -490,8 +491,10 @@ void ExternalInterruptHandler(void)
|
|||||||
#if defined ( __STM32F1__ )
|
#if defined ( __STM32F1__ )
|
||||||
detachInterrupt( DccProcState.ExtIntNum );
|
detachInterrupt( DccProcState.ExtIntNum );
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP32
|
#if defined(ESP32)
|
||||||
ISRWatch = ISREdge;
|
ISRWatch = ISREdge;
|
||||||
|
#elif defined(ARDUINO_ARCH_RP2040)
|
||||||
|
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, (PinStatus)ISREdge );
|
||||||
#else
|
#else
|
||||||
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
||||||
#endif
|
#endif
|
||||||
@@ -540,8 +543,10 @@ void ExternalInterruptHandler(void)
|
|||||||
#if defined ( __STM32F1__ )
|
#if defined ( __STM32F1__ )
|
||||||
detachInterrupt( DccProcState.ExtIntNum );
|
detachInterrupt( DccProcState.ExtIntNum );
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP32
|
#if defined(ESP32)
|
||||||
ISRWatch = ISREdge;
|
ISRWatch = ISREdge;
|
||||||
|
#elif defined(ARDUINO_ARCH_RP2040)
|
||||||
|
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, (PinStatus)ISREdge );
|
||||||
#else
|
#else
|
||||||
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
||||||
#endif
|
#endif
|
||||||
@@ -583,14 +588,17 @@ void ExternalInterruptHandler(void)
|
|||||||
#if defined ( __STM32F1__ )
|
#if defined ( __STM32F1__ )
|
||||||
detachInterrupt( DccProcState.ExtIntNum );
|
detachInterrupt( DccProcState.ExtIntNum );
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP32
|
|
||||||
ISRWatch = ISREdge;
|
#if defined(ESP32)
|
||||||
#else
|
ISRWatch = ISREdge;
|
||||||
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
#elif defined(ARDUINO_ARCH_RP2040)
|
||||||
#endif
|
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, (PinStatus)ISREdge );
|
||||||
// enable level-checking
|
#else
|
||||||
ISRChkMask = DccProcState.ExtIntMask;
|
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
||||||
ISRLevel = (ISREdge==RISING)? DccProcState.ExtIntMask : 0 ;
|
#endif
|
||||||
|
// enable level-checking
|
||||||
|
ISRChkMask = DccProcState.ExtIntMask;
|
||||||
|
ISRLevel = (ISREdge==RISING)? DccProcState.ExtIntMask : 0 ;
|
||||||
|
|
||||||
//CLR_TP4;
|
//CLR_TP4;
|
||||||
break;
|
break;
|
||||||
@@ -755,10 +763,7 @@ uint8_t readEEPROM( unsigned int CV )
|
|||||||
void writeEEPROM( unsigned int CV, uint8_t Value )
|
void writeEEPROM( unsigned int CV, uint8_t Value )
|
||||||
{
|
{
|
||||||
EEPROM.write(CV, Value) ;
|
EEPROM.write(CV, Value) ;
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
#if defined(ESP32)
|
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1542,10 +1547,7 @@ void NmraDcc::initAccessoryDecoder( uint8_t ManufacturerId, uint8_t VersionId, u
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
void NmraDcc::init( uint8_t ManufacturerId, uint8_t VersionId, uint8_t Flags, uint8_t OpsModeAddressBaseCV )
|
void NmraDcc::init( uint8_t ManufacturerId, uint8_t VersionId, uint8_t Flags, uint8_t OpsModeAddressBaseCV )
|
||||||
{
|
{
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
|
||||||
EEPROM.begin(MAXCV);
|
|
||||||
#endif
|
|
||||||
#if defined(ESP32)
|
|
||||||
EEPROM.begin(MAXCV);
|
EEPROM.begin(MAXCV);
|
||||||
#endif
|
#endif
|
||||||
// Clear all the static member variables
|
// Clear all the static member variables
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ typedef struct
|
|||||||
#undef ALLOW_NESTED_IRQ // This is done with NVIC on STM32
|
#undef ALLOW_NESTED_IRQ // This is done with NVIC on STM32
|
||||||
#define PRIO_DCC_IRQ 9
|
#define PRIO_DCC_IRQ 9
|
||||||
#define PRIO_SYSTIC 8 // MUST be higher priority than DCC Irq
|
#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
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define MAXCV E2END // the upper limit of the CV value currently defined to max memory.
|
#define MAXCV E2END // the upper limit of the CV value currently defined to max memory.
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name=NmraDcc
|
name=NmraDcc
|
||||||
version=2.0.7
|
version=2.0.8
|
||||||
author=Alex Shepherd, Wolfgang Kuffer, Geoff Bunza, Martin Pischky, Franz-Peter Müller, Sven (littleyoda), Hans Tanner
|
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>
|
maintainer=Alex Shepherd <kiwi64ajs@gmail.com>
|
||||||
sentence=Enables NMRA DCC Communication
|
sentence=Enables NMRA DCC Communication
|
||||||
paragraph=This library allows you to interface to a NMRA DCC track signal and receive DCC commands. The library has been tested on AVR ATTiny84/85 & ATMega88/168/328/32u4, ESP8266 and Teensy 3.x using the INT0/1 Hardware Interrupt and micros() ONLY and no longer uses Timer0 Compare Match B, which makes it much more portable to other platforms.
|
paragraph=This library allows you to interface to a NMRA DCC track signal and receive DCC commands. The library has been tested on AVR ATTiny84/85 & ATMega88/168/328/32u4, ESP8266 and Teensy 3.x using the INT0/1 Hardware Interrupt and micros() ONLY and no longer uses Timer0 Compare Match B, which makes it much more portable to other platforms.
|
||||||
|
|||||||
Reference in New Issue
Block a user