1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 03:26:13 +01:00

make RMT channel compile without dccpacket class

This commit is contained in:
Harald Barth 2022-07-31 00:18:35 +02:00
parent ca84cd2ea6
commit 06647ae7e4
2 changed files with 8 additions and 11 deletions

View File

@ -154,8 +154,8 @@ void RMTChannel::RMTprefill() {
const byte transmitMask[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; const byte transmitMask[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
//bool RMTChannel::RMTfillData(const byte buffer[], byte byteCount, byte repeatCount=0) { int RMTChannel::RMTfillData(const byte buffer[], byte byteCount, byte repeatCount=0) {
int RMTChannel::RMTfillData(dccPacket packet) { //int RMTChannel::RMTfillData(dccPacket packet) {
// dataReady: Signals to then interrupt routine. It is set when // dataReady: Signals to then interrupt routine. It is set when
// we have data in the channel buffer which can be copied out // we have data in the channel buffer which can be copied out
// to the HW. dataRepeat on the other hand signals back to // to the HW. dataRepeat on the other hand signals back to
@ -165,16 +165,14 @@ int RMTChannel::RMTfillData(dccPacket packet) {
return 1000; return 1000;
if (dataRepeat > 0) // we have still old work to do if (dataRepeat > 0) // we have still old work to do
return dataRepeat; return dataRepeat;
if (DATA_LEN(packet.length) > maxDataLen) { // this would overun our allocated memory for data if (DATA_LEN(byteCount) > maxDataLen) { // this would overun our allocated memory for data
DIAG(F("Can not convert DCC bytes # %d to DCC bits %d, buffer too small"), packet.length, maxDataLen); DIAG(F("Can not convert DCC bytes # %d to DCC bits %d, buffer too small"), byteCount, maxDataLen);
return -1; // something very broken, can not convert packet return -1; // something very broken, can not convert packet
} }
byte *buffer = packet.data;
// convert bytes to RMT stream of "bits" // convert bytes to RMT stream of "bits"
byte bitcounter = 0; byte bitcounter = 0;
for(byte n=0; n<packet.length; n++) { for(byte n=0; n<byteCount; n++) {
for(byte bit=0; bit<8; bit++) { for(byte bit=0; bit<8; bit++) {
if (buffer[n] & transmitMask[bit]) if (buffer[n] & transmitMask[bit])
setDCCBit1(data + bitcounter++); setDCCBit1(data + bitcounter++);
@ -187,7 +185,7 @@ int RMTChannel::RMTfillData(dccPacket packet) {
setEOT(data + bitcounter++); // EOT marker setEOT(data + bitcounter++); // EOT marker
dataLen = bitcounter; dataLen = bitcounter;
dataReady = true; dataReady = true;
dataRepeat = packet.repeat+1; // repeatCount of 0 means send once dataRepeat = repeatCount+1; // repeatCount of 0 means send once
return 0; return 0;
} }

View File

@ -20,7 +20,6 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#include "DCCPacket.h"
#include "driver/rmt.h" #include "driver/rmt.h"
#include "soc/rmt_reg.h" #include "soc/rmt_reg.h"
#include "soc/rmt_struct.h" #include "soc/rmt_struct.h"
@ -35,8 +34,8 @@ class RMTChannel {
RMTChannel(byte pin, bool isMain); RMTChannel(byte pin, bool isMain);
void IRAM_ATTR RMTinterrupt(); void IRAM_ATTR RMTinterrupt();
void RMTprefill(); void RMTprefill();
int RMTfillData(dccPacket packet); //int RMTfillData(dccPacket packet);
//bool RMTfillData(const byte buffer[], byte byteCount, byte repeatCount); int RMTfillData(const byte buffer[], byte byteCount, byte repeatCount);
static RMTChannel mainRMTChannel; static RMTChannel mainRMTChannel;
static RMTChannel progRMTChannel; static RMTChannel progRMTChannel;