/* * © 2021, Harald Barth. * * This file is part of DCC-EX * * This is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * It is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with CommandStation. If not, see . */ #include "defines.h" #include "DIAG.h" #include "DCCRMT.h" #include "soc/periph_defs.h" #include "driver/periph_ctrl.h" #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4,2,0) #error wrong IDF version #endif void setDCCBit1(rmt_item32_t* item) { item->level0 = 1; item->duration0 = DCC_1_HALFPERIOD; item->level1 = 0; item->duration1 = DCC_1_HALFPERIOD; } void setDCCBit0(rmt_item32_t* item) { item->level0 = 1; item->duration0 = DCC_0_HALFPERIOD; item->level1 = 0; item->duration1 = DCC_0_HALFPERIOD; } void IRAM_ATTR interrupt(rmt_channel_t channel, void *t) { BaseType_t wtf = pdFALSE; RMTPin *tt = (RMTPin *)t; //DIAG(F("interrupt %d"), tt->idleLen); tt->RMTinterrupt(channel,t); rmt_tx_start(channel,true); portYIELD_FROM_ISR(wtf); } RMTPin::RMTPin(byte pin, byte ch, byte plen) { // preamble preambleLen = plen+1; preamble = (rmt_item32_t*)malloc(preambleLen*sizeof(rmt_item32_t)); for (byte n=0; npreambleNext) { rmt_fill_tx_items(channel, obj->preamble, obj->preambleLen, 0); //obj->preambleNext = false; } else { if (obj->dataNext) { rmt_fill_tx_items(channel, obj->packetBits, obj->packetLen, 0); } else { // here we should not get as now we need to send idle packet rmt_fill_tx_items(channel, obj->idle, obj->idleLen, 0); } obj->preambleNext = true; } rmt_tx_start(channel,true); DIAG(F("START")); */ }