streamlined identification of interrupt masks and memory size

This commit is contained in:
Gregg 2022-01-17 12:36:02 -06:00
parent 89f0d0dd94
commit b6d21fd2c0
3 changed files with 10 additions and 18 deletions

View File

@ -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);

View File

@ -26,18 +26,7 @@ class Pixel {
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<<chNum)
#else
const int memSize=0;
#endif
const int memSize=sizeof(RMTMEM.chan[0].data32)/4; // determine size (in pulses) of one channel
static void loadData(void *arg); // interrupt handler
volatile static pixel_status_t status; // storage for volatile information modified in interupt handler

View File

@ -95,9 +95,9 @@ void setup() {
Serial.println("\n\nHomeSpan Pixel Example\n");
Pixel px0(10);
// Pixel px0(10);
Pixel px(1);
Pixel px1(0);
// Pixel px1(0);
uint32_t colors[20];