restore ackCV
delete ackAdvancedCv and call ackCV only in servicemode Don't allow setting the RailcomBit in CV29
This commit is contained in:
22
NmraDcc.cpp
22
NmraDcc.cpp
@@ -597,17 +597,11 @@ void ExternalInterruptHandler(void)
|
||||
}
|
||||
|
||||
void ackCV(void)
|
||||
{
|
||||
if( notifyCVAck )
|
||||
{ // create the ack pulse only in service mode
|
||||
if( notifyCVAck && DccProcState.inServiceMode )
|
||||
notifyCVAck() ;
|
||||
}
|
||||
|
||||
void ackAdvancedCV(void)
|
||||
{
|
||||
if( notifyAdvancedCVAck && (DccProcState.cv29Value & CV29_ADV_ACK) )
|
||||
notifyAdvancedCVAck() ;
|
||||
}
|
||||
|
||||
|
||||
uint8_t readEEPROM( unsigned int CV ) {
|
||||
return EEPROM.read(CV) ;
|
||||
@@ -668,6 +662,8 @@ uint8_t writeCV( unsigned int CV, uint8_t Value)
|
||||
{
|
||||
case CV_29_CONFIG:
|
||||
// copy addressmode Bit to Flags
|
||||
Value = Value & ~CV29_RailCom_ENABLE; // Bidi (RailCom) Bit must not be enabled,
|
||||
// because you cannot build a Bidi decoder with this lib.
|
||||
DccProcState.cv29Value = Value;
|
||||
DccProcState.Flags = ( DccProcState.Flags & ~FLAGS_CV29_BITS) | (Value & FLAGS_CV29_BITS);
|
||||
// no break, because myDccAdress must also be reset
|
||||
@@ -730,7 +726,7 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
||||
if( validCV( CVAddr, 1 ) )
|
||||
{
|
||||
if( writeCV( CVAddr, Value ) == Value )
|
||||
ackAdvancedCV();
|
||||
ackCV();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,7 +735,7 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
||||
if( validCV( CVAddr, 0 ) )
|
||||
{
|
||||
if( readCV( CVAddr ) == Value )
|
||||
ackAdvancedCV();
|
||||
ackCV();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -764,7 +760,7 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
||||
tempValue &= ~BitMask ; // Turn the Bit Off
|
||||
|
||||
if( writeCV( CVAddr, tempValue ) == tempValue )
|
||||
ackAdvancedCV() ;
|
||||
ackCV() ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,12 +772,12 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
||||
if( BitValue )
|
||||
{
|
||||
if( tempValue & BitMask )
|
||||
ackAdvancedCV() ;
|
||||
ackCV() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !( tempValue & BitMask) )
|
||||
ackAdvancedCV() ;
|
||||
ackCV() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
NmraDcc.h
17
NmraDcc.h
@@ -49,7 +49,7 @@
|
||||
#ifndef NMRADCC_IS_IN
|
||||
#define NMRADCC_IS_IN
|
||||
|
||||
#define NMRADCC_VERSION 201 // Version 2.0.1
|
||||
#define NMRADCC_VERSION 202 // Version 2.0.2
|
||||
|
||||
#define MAX_DCC_MESSAGE_LEN 6 // including XOR-Byte
|
||||
|
||||
@@ -118,7 +118,7 @@ typedef enum {
|
||||
CV29_LOCO_DIR = 0b00000001, /** bit 0: Locomotive Direction: "0" = normal, "1" = reversed */
|
||||
CV29_F0_LOCATION = 0b00000010, /** bit 1: F0 location: "0" = bit 4 in Speed and Direction instructions, "1" = bit 4 in function group one instruction */
|
||||
CV29_APS = 0b00000100, /** bit 2: Alternate Power Source (APS) "0" = NMRA Digital only, "1" = Alternate power source set by CV12 */
|
||||
CV29_ADV_ACK = 0b00001000, /** bit 3: ACK, Advanced Acknowledge mode enabled if 1, disabled if 0 */
|
||||
CV29_RailCom_ENABLE = 0b00001000, /** bit 3: BiDi ( RailCom ) is active */
|
||||
CV29_SPEED_TABLE_ENABLE = 0b00010000, /** bit 4: STE, Speed Table Enable, "0" = values in CVs 2, 4 and 6, "1" = Custom table selected by CV 25 */
|
||||
CV29_EXT_ADDRESSING = 0b00100000, /** bit 5: "0" = one byte addressing, "1" = two byte addressing */
|
||||
CV29_OUTPUT_ADDRESS_MODE = 0b01000000, /** bit 6: "0" = Decoder Address Mode "1" = Output Address Mode */
|
||||
@@ -703,17 +703,8 @@ extern void notifyCVResetFactoryDefault(void) __attribute__ ((weak));
|
||||
* None
|
||||
*/
|
||||
extern void notifyCVAck(void) __attribute__ ((weak));
|
||||
/*+
|
||||
* notifyAdvancedCVAck() Called when a CV write must be acknowledged via Advanced Acknowledgement.
|
||||
* This callback must send the Advanced Acknowledgement via RailComm.
|
||||
*
|
||||
* Inputs:
|
||||
* None
|
||||
* *
|
||||
* Returns:
|
||||
* None
|
||||
*/
|
||||
extern void notifyAdvancedCVAck(void) __attribute__ ((weak));
|
||||
|
||||
|
||||
/*+
|
||||
* notifyServiceMode(bool) Called when state of 'inServiceMode' changes
|
||||
*
|
||||
|
Reference in New Issue
Block a user