Skip to content

Commit 95be9e8

Browse files
committed
Further fix for channels, the done handler wasn't quite right
1 parent ba32cc3 commit 95be9e8

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ void ESP32RMTController::startOnChannel(int channel)
432432

433433
if (FASTLED_RMT_BUILTIN_DRIVER) {
434434
// -- Use the built-in RMT driver to send all the data in one shot
435-
rmt_register_tx_end_callback(doneOnChannel, 0);
435+
rmt_register_tx_end_callback(doneOnRMTChannel, (void *) channel);
436436
rmt_write_items(mRMT_channel, mBuffer, mBufferSize, false);
437437
} else {
438438
// -- Use our custom driver to send the data incrementally
@@ -475,13 +475,20 @@ void ESP32RMTController::tx_start()
475475

476476
}
477477

478+
// In the case of the build-in driver, they specify the RMT channel
479+
// so we use the arg instead
480+
void ESP32RMTController::doneOnRMTChannel(rmt_channel_t channel, void * arg)
481+
{
482+
doneOnChannel((int) arg, (void *) 0);
483+
}
484+
478485
// -- A controller is done
479486
// This function is called when a controller finishes writing
480487
// its data. It is called either by the custom interrupt
481488
// handler (below), or as a callback from the built-in
482489
// interrupt handler. It is static because we don't know which
483490
// controller is done until we look it up.
484-
void ESP32RMTController::doneOnChannel(rmt_channel_t channel, void * arg)
491+
void ESP32RMTController::doneOnChannel(int channel, void * arg)
485492
{
486493

487494
// -- Turn off output on the pin
@@ -546,7 +553,7 @@ void IRAM_ATTR ESP32RMTController::interruptHandler(void *arg)
546553
else if (intr_st & BIT(tx_done_bit)) {
547554

548555
RMT.int_clr.val |= BIT(tx_done_bit);
549-
doneOnChannel(rmt_channel_t(rmt_channel), 0);
556+
doneOnChannel(channel, 0);
550557

551558
}
552559
}

components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,15 @@ class ESP32RMTController
274274
// handler (below), or as a callback from the built-in
275275
// interrupt handler. It is static because we don't know which
276276
// controller is done until we look it up.
277-
static void IRAM_ATTR doneOnChannel(rmt_channel_t channel, void * arg);
277+
static void IRAM_ATTR doneOnChannel(int channel, void * arg);
278+
279+
// -- A controller is done
280+
// This function is called when a controller finishes writing
281+
// its data. It is called either by the custom interrupt
282+
// handler (below), or as a callback from the built-in
283+
// interrupt handler. It is static because we don't know which
284+
// controller is done until we look it up.
285+
static void IRAM_ATTR doneOnRMTChannel(rmt_channel_t rmt_channel, void * arg);
278286

279287
// -- Custom interrupt handler
280288
// This interrupt handler handles two cases: a controller is

0 commit comments

Comments
 (0)