Skip to content

Commit 6c8007f

Browse files
authored
feat(rmt): Refine loop handling in RMT transmission
Updated loop condition to allow for greater than zero looping and added comments for clarity.
1 parent 3641446 commit 6c8007f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cores/esp32/esp32-hal-rmt.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ static bool _rmtWrite(int pin, rmt_data_t *data, size_t num_rmt_symbols, bool bl
355355
retCode = false;
356356
log_w("GPIO %d - RMT Transmission failed.", pin);
357357
} else { // transmit OK
358-
if (loop) {
359-
// Even if loop count is finite number, it shall keep looping ... until a channel canceling or new writing.
360-
bus->rmt_ch_is_looping = true;
361-
358+
if (loop > 0) {
359+
// rmt_ch_is_looping is used as a flag to indicate that RMT is in looping execution in order to
360+
//be cancelled whenever a new _rmtWrite() is executed while it is looping
361+
bus->rmt_ch_is_looping = true;
362362
} else {
363363
if (blocking) {
364364
// wait for transmission confirmation | timeout
@@ -423,6 +423,8 @@ bool rmtWriteLooping(int pin, rmt_data_t *data, size_t num_rmt_symbols) {
423423
}
424424

425425
// Same as rmtWriteLooping(...) but limits number of loops to "loop_count"
426+
// loop_count shall be higher than 1 because 0 means no looping (single trnasmission)
427+
// 1 means infinite looping (it shall use rmtWriteLooping() instead)
426428
bool rmtWriteLoopingCount(int pin, rmt_data_t *data, size_t num_rmt_symbols, uint32_t loop_count) {
427429
if (loop_count <= 1) {
428430
log_w("rmtWriteLoopingCount: Invalid loop_count (%u). Must be greater than 1.", loop_count);

0 commit comments

Comments
 (0)