Added MACROs CALC_MULTIFUNCTION_EXTENDED_ADDRESS_MSB and CALC_MULTIFUNCTION_EXTENDED_ADDRESS_LSB to correctly compute the DCC Address for CV storage
Corrected bug: ESP32 version stops working when loosing interupts or signal is bad (#48) bumped version to 2.0.7
This commit is contained in:
@@ -494,10 +494,10 @@ void ExternalInterruptHandler(void)
|
|||||||
ISRWatch = ISREdge;
|
ISRWatch = ISREdge;
|
||||||
#else
|
#else
|
||||||
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
attachInterrupt( DccProcState.ExtIntNum, ExternalInterruptHandler, ISREdge );
|
||||||
|
#endif
|
||||||
// enable level checking ( with direct port reading @ AVR )
|
// enable level checking ( with direct port reading @ AVR )
|
||||||
ISRChkMask = DccProcState.ExtIntMask;
|
ISRChkMask = DccProcState.ExtIntMask;
|
||||||
ISRLevel = (ISREdge==RISING)? DccProcState.ExtIntMask : 0 ;
|
ISRLevel = (ISREdge==RISING)? DccProcState.ExtIntMask : 0 ;
|
||||||
#endif
|
|
||||||
SET_TP3;
|
SET_TP3;
|
||||||
CLR_TP4;
|
CLR_TP4;
|
||||||
}
|
}
|
||||||
|
@@ -94,6 +94,10 @@ typedef struct
|
|||||||
|
|
||||||
// Product/Version Id Codes allocated under: MAN_ID_DIY
|
// Product/Version Id Codes allocated under: MAN_ID_DIY
|
||||||
|
|
||||||
|
#define DEFAULT_MULTIFUNCTION_DECODER_ADDRESS 3
|
||||||
|
#define DEFAULT_ACCESSORY_DECODER_ADDRESS 1
|
||||||
|
|
||||||
|
|
||||||
// Standard CV Addresses
|
// Standard CV Addresses
|
||||||
#define CV_ACCESSORY_DECODER_ADDRESS_LSB 1
|
#define CV_ACCESSORY_DECODER_ADDRESS_LSB 1
|
||||||
#define CV_ACCESSORY_DECODER_ADDRESS_MSB 9
|
#define CV_ACCESSORY_DECODER_ADDRESS_MSB 9
|
||||||
@@ -102,6 +106,9 @@ typedef struct
|
|||||||
#define CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB 17
|
#define CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB 17
|
||||||
#define CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB 18
|
#define CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB 18
|
||||||
|
|
||||||
|
#define CALC_MULTIFUNCTION_EXTENDED_ADDRESS_LSB(x) (x & 0xFF)
|
||||||
|
#define CALC_MULTIFUNCTION_EXTENDED_ADDRESS_MSB(x) (((x>>8) & 0x7F) + 192)
|
||||||
|
|
||||||
#define CV_VERSION_ID 7
|
#define CV_VERSION_ID 7
|
||||||
#define CV_MANUFACTURER_ID 8
|
#define CV_MANUFACTURER_ID 8
|
||||||
#define CV_29_CONFIG 29
|
#define CV_29_CONFIG 29
|
||||||
|
@@ -15,8 +15,8 @@ struct CVPair
|
|||||||
|
|
||||||
CVPair FactoryDefaultCVs [] =
|
CVPair FactoryDefaultCVs [] =
|
||||||
{
|
{
|
||||||
{CV_ACCESSORY_DECODER_ADDRESS_LSB, 1},
|
{CV_ACCESSORY_DECODER_ADDRESS_LSB, DEFAULT_ACCESSORY_DECODER_ADDRESS & 0xFF},
|
||||||
{CV_ACCESSORY_DECODER_ADDRESS_MSB, 0},
|
{CV_ACCESSORY_DECODER_ADDRESS_MSB, DEFAULT_ACCESSORY_DECODER_ADDRESS >> 8},
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t FactoryDefaultCVIndex = 0;
|
uint8_t FactoryDefaultCVIndex = 0;
|
||||||
|
@@ -40,8 +40,8 @@ struct CVPair
|
|||||||
|
|
||||||
CVPair FactoryDefaultCVs [] =
|
CVPair FactoryDefaultCVs [] =
|
||||||
{
|
{
|
||||||
{CV_ACCESSORY_DECODER_ADDRESS_LSB, 1}, // CV 1 Board Address (lower 6 bits)
|
{CV_ACCESSORY_DECODER_ADDRESS_LSB, DEFAULT_ACCESSORY_DECODER_ADDRESS & 0xFF},
|
||||||
{CV_ACCESSORY_DECODER_ADDRESS_MSB, 0}, // CV 9 Board Address (Upper 3 bits)
|
{CV_ACCESSORY_DECODER_ADDRESS_MSB, DEFAULT_ACCESSORY_DECODER_ADDRESS >> 8},
|
||||||
{CV_ACCESSORY_DECODER_OUTPUT_PULSE_TIME, 50}, // x 10mS for the output pulse duration
|
{CV_ACCESSORY_DECODER_OUTPUT_PULSE_TIME, 50}, // x 10mS for the output pulse duration
|
||||||
{CV_ACCESSORY_DECODER_CDU_RECHARGE_TIME, 30}, // x 10mS for the CDU recharge delay time
|
{CV_ACCESSORY_DECODER_CDU_RECHARGE_TIME, 30}, // x 10mS for the CDU recharge delay time
|
||||||
{CV_ACCESSORY_DECODER_ACTIVE_STATE, ACTIVE_OUTPUT_STATE},
|
{CV_ACCESSORY_DECODER_ACTIVE_STATE, ACTIVE_OUTPUT_STATE},
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
#include <NmraDcc.h>
|
#include <NmraDcc.h>
|
||||||
|
|
||||||
#define This_Decoder_Address 3
|
|
||||||
|
|
||||||
struct CVPair
|
struct CVPair
|
||||||
{
|
{
|
||||||
uint16_t CV;
|
uint16_t CV;
|
||||||
@@ -11,11 +9,11 @@ struct CVPair
|
|||||||
CVPair FactoryDefaultCVs [] =
|
CVPair FactoryDefaultCVs [] =
|
||||||
{
|
{
|
||||||
// The CV Below defines the Short DCC Address
|
// The CV Below defines the Short DCC Address
|
||||||
{CV_MULTIFUNCTION_PRIMARY_ADDRESS, This_Decoder_Address},
|
{CV_MULTIFUNCTION_PRIMARY_ADDRESS, DEFAULT_MULTIFUNCTION_DECODER_ADDRESS},
|
||||||
|
|
||||||
// These two CVs define the Long DCC Address
|
// These two CVs define the Long DCC Address
|
||||||
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0},
|
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, CALC_MULTIFUNCTION_EXTENDED_ADDRESS_MSB(DEFAULT_MULTIFUNCTION_DECODER_ADDRESS)},
|
||||||
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, This_Decoder_Address},
|
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, CALC_MULTIFUNCTION_EXTENDED_ADDRESS_LSB(DEFAULT_MULTIFUNCTION_DECODER_ADDRESS)},
|
||||||
|
|
||||||
// ONLY uncomment 1 CV_29_CONFIG line below as approprate
|
// ONLY uncomment 1 CV_29_CONFIG line below as approprate
|
||||||
// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps
|
// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps
|
||||||
|
@@ -89,8 +89,8 @@ CVPair FactoryDefaultCVs [] =
|
|||||||
{CV_VHIGH, 255},
|
{CV_VHIGH, 255},
|
||||||
|
|
||||||
// These two CVs define the Long DCC Address
|
// These two CVs define the Long DCC Address
|
||||||
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0},
|
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, CALC_MULTIFUNCTION_EXTENDED_ADDRESS_MSB(DEFAULT_DECODER_ADDRESS)},
|
||||||
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, DEFAULT_DECODER_ADDRESS},
|
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, CALC_MULTIFUNCTION_EXTENDED_ADDRESS_LSB(DEFAULT_DECODER_ADDRESS)},
|
||||||
|
|
||||||
// ONLY uncomment 1 CV_29_CONFIG line below as approprate
|
// ONLY uncomment 1 CV_29_CONFIG line below as approprate
|
||||||
// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps
|
// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps
|
||||||
|
@@ -36,8 +36,8 @@ struct CVPair
|
|||||||
|
|
||||||
CVPair FactoryDefaultCVs [] =
|
CVPair FactoryDefaultCVs [] =
|
||||||
{
|
{
|
||||||
{CV_ACCESSORY_DECODER_ADDRESS_LSB, 1},
|
{CV_ACCESSORY_DECODER_ADDRESS_LSB, DEFAULT_ACCESSORY_DECODER_ADDRESS & 0xFF},
|
||||||
{CV_ACCESSORY_DECODER_ADDRESS_MSB, 0},
|
{CV_ACCESSORY_DECODER_ADDRESS_MSB, DEFAULT_ACCESSORY_DECODER_ADDRESS >> 8},
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t FactoryDefaultCVIndex = 0;
|
uint8_t FactoryDefaultCVIndex = 0;
|
||||||
|
@@ -106,9 +106,9 @@ CVPair FactoryDefaultCVs [] =
|
|||||||
{CV_MANUF, MANUF_ID }, // Manufacturer ID.
|
{CV_MANUF, MANUF_ID }, // Manufacturer ID.
|
||||||
|
|
||||||
// These two CVs define the Long DCC Address
|
// These two CVs define the Long DCC Address
|
||||||
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, // Extended address MSB.
|
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, CALC_MULTIFUNCTION_EXTENDED_ADDRESS_MSB(DECODER_ADDR)},
|
||||||
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, DECODER_ADDR}, // Extended address LSB.
|
{CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, CALC_MULTIFUNCTION_EXTENDED_ADDRESS_LSB(DECODER_ADDR)},
|
||||||
|
|
||||||
{CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps
|
{CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps
|
||||||
{CV_MANUF_01, VER_MINOR}, // Minor decoder version.
|
{CV_MANUF_01, VER_MINOR}, // Minor decoder version.
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
name=NmraDcc
|
name=NmraDcc
|
||||||
version=2.0.6
|
version=2.0.7
|
||||||
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
|
||||||
maintainer=Alex Shepherd <kiwi64ajs@gmail.com>
|
maintainer=Alex Shepherd <kiwi64ajs@gmail.com>
|
||||||
sentence=Enables NMRA DCC Communication
|
sentence=Enables NMRA DCC Communication
|
||||||
|
Reference in New Issue
Block a user