From b6d21fd2c0691f1b3871d70087171ea32c7580a2 Mon Sep 17 00:00:00 2001 From: Gregg Date: Mon, 17 Jan 2022 12:36:02 -0600 Subject: [PATCH] streamlined identification of interrupt masks and memory size --- src/extras/Pixel.cpp | 9 ++++++--- src/extras/Pixel.h | 15 ++------------- src/extras/extras.ino | 4 ++-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/extras/Pixel.cpp b/src/extras/Pixel.cpp index 6699b4d..22998b6 100644 --- a/src/extras/Pixel.cpp +++ b/src/extras/Pixel.cpp @@ -8,10 +8,13 @@ Pixel::Pixel(int pin){ rf=new RFControl(pin,false,false); // set clock to 1/80 usec, no default driver setTiming(0.32, 0.88, 0.64, 0.56, 80.0); // set default timing parameters (suitable for most SK68 and WS28 RGB pixels) - rmt_isr_register(loadData,NULL,0,NULL); // set custom interrupt handler - rmt_set_tx_thr_intr_en(rf->getChannel(),true,8); // enable threshold interrupt (note end-transmission interrupt automatically enabled by rmt_tx_start) + rmt_isr_register(loadData,NULL,0,NULL); // set custom interrupt handler + rmt_set_tx_thr_intr_en(rf->getChannel(),true,8); // enable threshold interrupt to trigger every 8 pulses - txEndMask=TxEndMask(rf->getChannel()); // create bit mask for end-of-transmission interrupt specific to this channel + rmt_set_tx_intr_en(rf->getChannel(),false); // disable end-of-transmission interrupt + txEndMask=RMT.int_ena.val; // save interrupt enable vector + rmt_set_tx_intr_en(rf->getChannel(),true); // enable end-of-transmission interrupt + txEndMask^=RMT.int_ena.val; // find bit that flipped and save as end-of-transmission mask for this channel Serial.printf("%d %d %08X\n",rf->getChannel(),txEndMask,RMT.int_ena.val); diff --git a/src/extras/Pixel.h b/src/extras/Pixel.h index cdb6d21..414554b 100644 --- a/src/extras/Pixel.h +++ b/src/extras/Pixel.h @@ -25,20 +25,9 @@ class Pixel { uint32_t pattern[2]; // storage for zero-bit and one-bit pulses uint32_t resetTime; // minimum time (in usec) between pulse trains uint32_t txEndMask; // mask for end-of-transmission interrupt - - #if defined(CONFIG_IDF_TARGET_ESP32) - const int memSize=64; - #define TxEndMask(chNum) (1<<(chNum*3)) - #elif defined(CONFIG_IDF_TARGET_ESP32S2) - const int memSize=48; - #define TxEndMask(chNum) (1<<(chNum*3)) - #elif defined(CONFIG_IDF_TARGET_ESP32C3) - const int memSize=48; - #define TxEndMask(chNum) (1<