fix bug caused when AdvancedCVAck logic was added as the CV Programming code was shared between Service Mode and Ops Mode programming.
This commit is contained in:
33
NmraDcc.cpp
33
NmraDcc.cpp
@@ -41,7 +41,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Uncomment to print DEBUG messages
|
// Uncomment to print DEBUG messages
|
||||||
//#define DEBUG_PRINT
|
// #define DEBUG_PRINT
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// DCC Receive Routine
|
// DCC Receive Routine
|
||||||
@@ -599,13 +599,19 @@ void ExternalInterruptHandler(void)
|
|||||||
void ackCV(void)
|
void ackCV(void)
|
||||||
{
|
{
|
||||||
if( notifyCVAck )
|
if( notifyCVAck )
|
||||||
|
{
|
||||||
|
DB_PRINT("ackCV: Send Basic ACK");
|
||||||
notifyCVAck() ;
|
notifyCVAck() ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ackAdvancedCV(void)
|
void ackAdvancedCV(void)
|
||||||
{
|
{
|
||||||
if( notifyAdvancedCVAck && (DccProcState.cv29Value & CV29_ADV_ACK) )
|
if( notifyAdvancedCVAck && (DccProcState.cv29Value & CV29_ADV_ACK) )
|
||||||
|
{
|
||||||
|
DB_PRINT("ackAdvancedCV: Send Advanced ACK");
|
||||||
notifyAdvancedCVAck() ;
|
notifyAdvancedCVAck() ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -719,7 +725,7 @@ uint16_t getMyAddr(void)
|
|||||||
return DccProcState.myDccAddress ;
|
return DccProcState.myDccAddress ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
void processDirectCVOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value, void (*ackFunction)() )
|
||||||
{
|
{
|
||||||
// is it a Byte Operation
|
// is it a Byte Operation
|
||||||
if( Cmd & 0x04 )
|
if( Cmd & 0x04 )
|
||||||
@@ -729,8 +735,9 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
|||||||
{
|
{
|
||||||
if( validCV( CVAddr, 1 ) )
|
if( validCV( CVAddr, 1 ) )
|
||||||
{
|
{
|
||||||
|
DB_PRINT("CV: %d Byte Write: %02X", CVAddr, Value)
|
||||||
if( writeCV( CVAddr, Value ) == Value )
|
if( writeCV( CVAddr, Value ) == Value )
|
||||||
ackAdvancedCV();
|
ackFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,8 +745,9 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
|||||||
{
|
{
|
||||||
if( validCV( CVAddr, 0 ) )
|
if( validCV( CVAddr, 0 ) )
|
||||||
{
|
{
|
||||||
|
DB_PRINT("CV: %d Byte Read: %02X", CVAddr, Value)
|
||||||
if( readCV( CVAddr ) == Value )
|
if( readCV( CVAddr ) == Value )
|
||||||
ackAdvancedCV();
|
ackFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -752,6 +760,8 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
|||||||
|
|
||||||
uint8_t tempValue = readCV( CVAddr ) ; // Read the Current CV Value
|
uint8_t tempValue = readCV( CVAddr ) ; // Read the Current CV Value
|
||||||
|
|
||||||
|
DB_PRINT("CV: %d Current Value: %02X Bit-Wise Mode: %s Mask: %02X Value: %02X", CVAddr, tempValue, BitWrite ? "Write":"Read", BitMask, BitValue);
|
||||||
|
|
||||||
// Perform the Bit Write Operation
|
// Perform the Bit Write Operation
|
||||||
if( BitWrite )
|
if( BitWrite )
|
||||||
{
|
{
|
||||||
@@ -764,7 +774,7 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
|||||||
tempValue &= ~BitMask ; // Turn the Bit Off
|
tempValue &= ~BitMask ; // Turn the Bit Off
|
||||||
|
|
||||||
if( writeCV( CVAddr, tempValue ) == tempValue )
|
if( writeCV( CVAddr, tempValue ) == tempValue )
|
||||||
ackAdvancedCV() ;
|
ackFunction() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -776,12 +786,12 @@ void processDirectOpsOperation( uint8_t Cmd, uint16_t CVAddr, uint8_t Value )
|
|||||||
if( BitValue )
|
if( BitValue )
|
||||||
{
|
{
|
||||||
if( tempValue & BitMask )
|
if( tempValue & BitMask )
|
||||||
ackAdvancedCV() ;
|
ackFunction() ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !( tempValue & BitMask) )
|
if( !( tempValue & BitMask) )
|
||||||
ackAdvancedCV() ;
|
ackFunction() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -958,7 +968,7 @@ void processMultiFunctionMessage( uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t
|
|||||||
case 0b11100000: // CV Access
|
case 0b11100000: // CV Access
|
||||||
CVAddr = ( ( ( Cmd & 0x03 ) << 8 ) | Data1 ) + 1 ;
|
CVAddr = ( ( ( Cmd & 0x03 ) << 8 ) | Data1 ) + 1 ;
|
||||||
|
|
||||||
processDirectOpsOperation( Cmd, CVAddr, Data2 ) ;
|
processDirectCVOperation( Cmd, CVAddr, Data2, ackAdvancedCV) ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -973,7 +983,7 @@ void processServiceModeOperation( DCC_MSG * pDccMsg )
|
|||||||
if( pDccMsg->Size == 3) // 3 Byte Packets are for Address Only, Register and Paged Mode
|
if( pDccMsg->Size == 3) // 3 Byte Packets are for Address Only, Register and Paged Mode
|
||||||
{
|
{
|
||||||
uint8_t RegisterAddr ;
|
uint8_t RegisterAddr ;
|
||||||
DB_PRINT("3-BytePkt");
|
DB_PRINT("CV Address, Register & Paged Mode Operation");
|
||||||
RegisterAddr = pDccMsg->Data[0] & 0x07 ;
|
RegisterAddr = pDccMsg->Data[0] & 0x07 ;
|
||||||
Value = pDccMsg->Data[1] ;
|
Value = pDccMsg->Data[1] ;
|
||||||
|
|
||||||
@@ -1016,11 +1026,10 @@ void processServiceModeOperation( DCC_MSG * pDccMsg )
|
|||||||
|
|
||||||
else if( pDccMsg->Size == 4) // 4 Byte Packets are for Direct Byte & Bit Mode
|
else if( pDccMsg->Size == 4) // 4 Byte Packets are for Direct Byte & Bit Mode
|
||||||
{
|
{
|
||||||
DB_PRINT("BB-Mode");
|
DB_PRINT("CV Direct Byte and Bit Mode Mode Operation");
|
||||||
CVAddr = ( ( ( pDccMsg->Data[0] & 0x03 ) << 8 ) | pDccMsg->Data[1] ) + 1 ;
|
CVAddr = ( ( ( pDccMsg->Data[0] & 0x03 ) << 8 ) | pDccMsg->Data[1] ) + 1 ;
|
||||||
Value = pDccMsg->Data[2] ;
|
Value = pDccMsg->Data[2] ;
|
||||||
|
processDirectCVOperation( pDccMsg->Data[0] & 0b00001100, CVAddr, Value, ackCV) ;
|
||||||
processDirectOpsOperation( pDccMsg->Data[0] & 0b00001100, CVAddr, Value ) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
name=NmraDcc
|
name=NmraDcc
|
||||||
version=2.0.2
|
version=2.0.3
|
||||||
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