mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-02 12:25:03 +01:00
Rename RMTPin to RMTChannel
This commit is contained in:
parent
c00d3a825d
commit
82df3a21dc
10
DCCRMT.cpp
10
DCCRMT.cpp
|
@ -57,11 +57,11 @@ void setEOT(rmt_item32_t* item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR interrupt(rmt_channel_t channel, void *t) {
|
void IRAM_ATTR interrupt(rmt_channel_t channel, void *t) {
|
||||||
RMTPin *tt = (RMTPin *)t;
|
RMTChannel *tt = (RMTChannel *)t;
|
||||||
tt->RMTinterrupt();
|
tt->RMTinterrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
RMTPin::RMTPin(byte pin, byte ch, byte plen) {
|
RMTChannel::RMTChannel(byte pin, byte ch, byte plen) {
|
||||||
|
|
||||||
// preamble
|
// preamble
|
||||||
preambleLen = plen+2; // plen 1 bits, one 0 bit and one EOF marker
|
preambleLen = plen+2; // plen 1 bits, one 0 bit and one EOF marker
|
||||||
|
@ -124,14 +124,14 @@ RMTPin::RMTPin(byte pin, byte ch, byte plen) {
|
||||||
RMTinterrupt();
|
RMTinterrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RMTPin::RMTprefill() {
|
void RMTChannel::RMTprefill() {
|
||||||
rmt_fill_tx_items(channel, preamble, preambleLen, 0);
|
rmt_fill_tx_items(channel, preamble, preambleLen, 0);
|
||||||
rmt_fill_tx_items(channel, idle, idleLen, preambleLen-1);
|
rmt_fill_tx_items(channel, idle, idleLen, preambleLen-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const byte transmitMask[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
const byte transmitMask[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
||||||
|
|
||||||
bool RMTPin::RMTfillData(const byte buffer[], byte byteCount, byte repeatCount=1) {
|
bool RMTChannel::RMTfillData(const byte buffer[], byte byteCount, byte repeatCount=1) {
|
||||||
if (dataReady == true || dataRepeat > 0) // we have still old work to do
|
if (dataReady == true || dataRepeat > 0) // we have still old work to do
|
||||||
return false;
|
return false;
|
||||||
if (DATA_LEN(byteCount) > maxDataLen) // this would overun our allocated memory for data
|
if (DATA_LEN(byteCount) > maxDataLen) // this would overun our allocated memory for data
|
||||||
|
@ -156,7 +156,7 @@ bool RMTPin::RMTfillData(const byte buffer[], byte byteCount, byte repeatCount=1
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR RMTPin::RMTinterrupt() {
|
void IRAM_ATTR RMTChannel::RMTinterrupt() {
|
||||||
//no rmt_tx_start(channel,true) as we run in loop mode
|
//no rmt_tx_start(channel,true) as we run in loop mode
|
||||||
//preamble is always loaded at beginning of buffer
|
//preamble is always loaded at beginning of buffer
|
||||||
if (dataReady) { // if we have new data, fill while preamble is running
|
if (dataReady) { // if we have new data, fill while preamble is running
|
||||||
|
|
8
DCCRMT.h
8
DCCRMT.h
|
@ -29,15 +29,15 @@
|
||||||
#define DCC_1_HALFPERIOD 58 //4640 // 1 / 80000000 * 4640 = 58us
|
#define DCC_1_HALFPERIOD 58 //4640 // 1 / 80000000 * 4640 = 58us
|
||||||
#define DCC_0_HALFPERIOD 100 //8000
|
#define DCC_0_HALFPERIOD 100 //8000
|
||||||
|
|
||||||
class RMTPin {
|
class RMTChannel {
|
||||||
public:
|
public:
|
||||||
RMTPin(byte pin, byte ch, byte plen);
|
RMTChannel(byte pin, byte ch, byte plen);
|
||||||
void IRAM_ATTR RMTinterrupt();
|
void IRAM_ATTR RMTinterrupt();
|
||||||
void RMTprefill();
|
void RMTprefill();
|
||||||
bool RMTfillData(const byte buffer[], byte byteCount, byte repeatCount);
|
bool RMTfillData(const byte buffer[], byte byteCount, byte repeatCount);
|
||||||
|
|
||||||
static RMTPin mainRMTPin;
|
static RMTChannel mainRMTChannel;
|
||||||
static RMTPin progRMTPin;
|
static RMTChannel progRMTChannel;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ uint8_t DCCWaveform::trailingEdgeCounter=0;
|
||||||
|
|
||||||
void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver) {
|
void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver) {
|
||||||
|
|
||||||
mainTrack.rmtPin = new RMTPin(21, 0, PREAMBLE_BITS_MAIN);
|
mainTrack.rmtPin = new RMTChannel(21, 0, PREAMBLE_BITS_MAIN);
|
||||||
|
|
||||||
mainTrack.motorDriver=mainDriver;
|
mainTrack.motorDriver=mainDriver;
|
||||||
progTrack.motorDriver=progDriver;
|
progTrack.motorDriver=progDriver;
|
||||||
|
|
|
@ -124,7 +124,7 @@ class DCCWaveform {
|
||||||
|
|
||||||
bool isMainTrack;
|
bool isMainTrack;
|
||||||
MotorDriver* motorDriver;
|
MotorDriver* motorDriver;
|
||||||
RMTPin* rmtPin;
|
RMTChannel* rmtPin;
|
||||||
// Transmission controller
|
// Transmission controller
|
||||||
byte transmitPacket[MAX_PACKET_SIZE+1]; // +1 for checksum
|
byte transmitPacket[MAX_PACKET_SIZE+1]; // +1 for checksum
|
||||||
byte transmitLength;
|
byte transmitLength;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user