1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-03-15 10:33:07 +01:00

Compare commits

..

No commits in common. "4739bb16ffccd3d1db2a374f1c638fe92f8f5f6b" and "0b6b7bcb0d5137adda993af8656b2044f413614c" have entirely different histories.

5 changed files with 20 additions and 53 deletions

View File

@ -267,8 +267,6 @@ DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true);
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false); DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false);
RMTChannel *DCCWaveform::rmtMainChannel = NULL; RMTChannel *DCCWaveform::rmtMainChannel = NULL;
RMTChannel *DCCWaveform::rmtProgChannel = NULL; RMTChannel *DCCWaveform::rmtProgChannel = NULL;
volatile bool DCCWaveform::railcomSampleWindow=false; // true during packet transmit
DCCWaveform::DCCWaveform(byte preambleBits, bool isMain) { DCCWaveform::DCCWaveform(byte preambleBits, bool isMain) {
isMainTrack = isMain; isMainTrack = isMain;

View File

@ -1,5 +0,0 @@
// file exists to break #include dependency loop
#include "EXRAIL2.h"
void RMFT3::blockEvent(int16_t block, int16_t loco, bool entering) {
RMFT2::blockEvent(block,loco,entering);
};

View File

@ -1,5 +0,0 @@
// file exists to break #include dependency loop
class RMFT3 {
public:
static void blockEvent(int16_t block, int16_t loco, bool entering);
};

View File

@ -45,7 +45,7 @@
#ifndef IO_I2CRailcom_h #ifndef IO_I2CRailcom_h
#define IO_I2CRailcom_h #define IO_I2CRailcom_h
#include "EXRAIL3.h"
#include "IODevice.h" #include "IODevice.h"
#include "I2CManager.h" #include "I2CManager.h"
#include "DIAG.h" #include "DIAG.h"
@ -63,7 +63,6 @@ private:
byte _inbuf[65]; byte _inbuf[65];
byte _outbuf[2]; byte _outbuf[2];
Railcom _channelMonitors[2]; Railcom _channelMonitors[2];
int16_t _locoInBlock[2];
public: public:
// Constructor // Constructor
I2CRailcom(VPIN firstVpin, int nPins, I2CAddress i2cAddress){ I2CRailcom(VPIN firstVpin, int nPins, I2CAddress i2cAddress){
@ -112,38 +111,23 @@ public:
// Read incoming raw Railcom data, and process accordingly // Read incoming raw Railcom data, and process accordingly
auto inlength= UART_ReadRegister(REG_RXLV); auto inlength= UART_ReadRegister(REG_RXLV);
if (inlength==0) return; if (inlength==0) return;
{
#ifdef DIAG_I2CRailcom #ifdef DIAG_I2CRailcom
DIAG(F("Railcom: %s/%d RX Fifo: %d"),_I2CAddress.toString(), _UART_CH, inlength); DIAG(F("Railcom: %s/%d RX Fifo: %d"),_I2CAddress.toString(), _UART_CH, inlength);
#endif #endif
// Ask UART for the data
_outbuf[0]=(byte)(REG_RHR << 3 | _UART_CH << 1); _outbuf[0]=(byte)(REG_RHR << 3 | _UART_CH << 1);
I2CManager.read(_I2CAddress, _inbuf, inlength, _outbuf, 1); I2CManager.read(_I2CAddress, _inbuf, inlength, _outbuf, 1);
#ifdef DIAG_I2CRailcom_data #ifdef DIAG_I2CRailcom_data
// Dump data buffer
DIAG(F("Railcom %s/%d RX FIFO Data"), _I2CAddress.toString(), _UART_CH); DIAG(F("Railcom %s/%d RX FIFO Data"), _I2CAddress.toString(), _UART_CH);
for (int i = 0; i < inlength; i++){ for (int i = 0; i < inlength; i++){
DIAG(F("[0x%x]: 0x%x"), i, _inbuf[i]); DIAG(F("[0x%x]: 0x%x"), i, _inbuf[i]);
} }
#endif
// Ask Railcom to interpret the channel1 loco
auto locoid=_channelMonitors[_UART_CH].getChannel1Loco(_inbuf); auto locoid=_channelMonitors[_UART_CH].getChannel1Loco(_inbuf);
DIAG(F("Railcom Channel1=%d"), locoid); DIAG(F("Railcom Channel1=%d"), locoid);
if (locoid<0) return; // -1 indicates Railcom needs another packet
// determine if loco in this block has changed #endif
auto prevLoco=_locoInBlock[_UART_CH]; }
if (locoid==prevLoco) return;
// Previous loco (if any) is exiting block
if (prevLoco) RMFT3::blockEvent(_firstVpin+_UART_CH,prevLoco,false);
// new loco, if any, is entering block
_locoInBlock[_UART_CH]=locoid;
if (locoid) RMFT3::blockEvent(_firstVpin+_UART_CH,locoid,true);
} }

View File

@ -25,11 +25,6 @@
class Railcom { class Railcom {
public: public:
Railcom(); Railcom();
/* returns -1: Call again next packet
0: No loco on track
>0: loco id
*/
int16_t getChannel1Loco(uint8_t * inbound); int16_t getChannel1Loco(uint8_t * inbound);
private: private: