mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-23 02:58:52 +01:00
RMT prog track channel start
This commit is contained in:
parent
83300387d2
commit
37f44709f9
@ -2,6 +2,10 @@
|
||||
|
||||
const byte MAX_PACKET_SIZE = 5; // NMRA standard extended packets, payload size WITHOUT checksum.
|
||||
|
||||
// Number of preamble bits (moved here so MotorDriver and Waveform know)
|
||||
const int PREAMBLE_BITS_MAIN = 16;
|
||||
const int PREAMBLE_BITS_PROG = 22;
|
||||
|
||||
class dccPacket {
|
||||
public:
|
||||
byte data[MAX_PACKET_SIZE+1]; // space for checksum if needed
|
||||
|
19
DCCRMT.cpp
19
DCCRMT.cpp
@ -62,7 +62,7 @@ void IRAM_ATTR interrupt(rmt_channel_t channel, void *t) {
|
||||
tt->RMTinterrupt();
|
||||
}
|
||||
|
||||
RMTChannel::RMTChannel(byte pin, byte ch, byte plen) {
|
||||
RMTChannel::RMTChannel(byte pin, byte ch, byte plen, bool isMain) {
|
||||
|
||||
// preamble
|
||||
preambleLen = plen+2; // plen 1 bits, one 0 bit and one EOF marker
|
||||
@ -79,12 +79,17 @@ RMTChannel::RMTChannel(byte pin, byte ch, byte plen) {
|
||||
// idle
|
||||
idleLen = 28;
|
||||
idle = (rmt_item32_t*)malloc(idleLen*sizeof(rmt_item32_t));
|
||||
for (byte n=0; n<8; n++) // 0 to 7
|
||||
setDCCBit1(idle + n);
|
||||
for (byte n=8; n<18; n++) // 8, 9 to 16, 17
|
||||
setDCCBit0(idle + n);
|
||||
for (byte n=18; n<26; n++) // 18 to 25
|
||||
setDCCBit1(idle + n);
|
||||
if (isMain) {
|
||||
for (byte n=0; n<8; n++) // 0 to 7
|
||||
setDCCBit1(idle + n);
|
||||
for (byte n=8; n<18; n++) // 8, 9 to 16, 17
|
||||
setDCCBit0(idle + n);
|
||||
for (byte n=18; n<26; n++) // 18 to 25
|
||||
setDCCBit1(idle + n);
|
||||
} else {
|
||||
for (byte n=0; n<26; n++) // all zero
|
||||
setDCCBit0(idle + n);
|
||||
}
|
||||
setDCCBit1(idle + 26); // end bit
|
||||
setEOT(idle + 27); // EOT marker
|
||||
|
||||
|
8
DCCRMT.h
8
DCCRMT.h
@ -32,7 +32,13 @@
|
||||
|
||||
class RMTChannel {
|
||||
public:
|
||||
RMTChannel(byte pin, byte ch, byte plen);
|
||||
inline RMTChannel(byte pin, bool isMain) {
|
||||
if (isMain)
|
||||
RMTChannel(pin, 0, PREAMBLE_BITS_MAIN, 1);
|
||||
else
|
||||
RMTChannel(pin, 2, PREAMBLE_BITS_PROG, 0);
|
||||
};
|
||||
RMTChannel(byte pin, byte ch, byte plen, bool isProg);
|
||||
void IRAM_ATTR RMTinterrupt();
|
||||
void RMTprefill();
|
||||
bool RMTfillData(dccPacket packet);
|
||||
|
@ -41,7 +41,7 @@ MotorDriver::MotorDriver(byte power_pin, byte signal_pin, byte signal_pin2, int8
|
||||
if (dtype == RMT_MAIN) {
|
||||
signalPin=signal_pin;
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
rmtChannel = new RMTChannel(signalPin, 0, PREAMBLE_BITS_MAIN);
|
||||
rmtChannel = new RMTChannel(signalPin, true); // true: isMain
|
||||
#endif
|
||||
dualSignal=false;
|
||||
} else if (dtype & (TIMER_MAIN | TIMER_PROG)) {
|
||||
|
@ -29,10 +29,6 @@
|
||||
#include "DCCRMT.h"
|
||||
#endif
|
||||
|
||||
// Number of preamble bits (moved here so MotorDriver and Waveform know)
|
||||
const int PREAMBLE_BITS_MAIN = 16;
|
||||
const int PREAMBLE_BITS_PROG = 22;
|
||||
|
||||
#ifndef UNUSED_PIN // sync define with the one in MotorDrivers.h
|
||||
#define UNUSED_PIN 127 // inside int8_t
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user