From f520e0968acd8a1a053ed66b0cdef1d6534bc72e Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 24 Nov 2019 19:42:41 -0500 Subject: [PATCH] Fix inability to use all buffers in RMT With the >= used let's say you have four RMT inputs, each using 2 channels wide for their receive buffer. This is 4*2 = 8 buffers which is the number of hardware buffers (MAX_CHANNELS). But, for the fourth input the starting buffer will be 6 (this is correct, the buffers used for each input are 0-1, 2-3, 4-5, 6-7). But, 6+2 = 8 which is MAX_CHANNELS. This is valid but the >= would match against it and abort. It is correct to only abort if the value i+j is only greater than MAX_CHANNELS. Thus, a simple one character fix. Delete the equals sign. --- cores/esp32/esp32-hal-rmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-rmt.c b/cores/esp32/esp32-hal-rmt.c index 0a614226c29..a3ac1c5763e 100644 --- a/cores/esp32/esp32-hal-rmt.c +++ b/cores/esp32/esp32-hal-rmt.c @@ -483,7 +483,7 @@ rmt_obj_t* rmtInit(int pin, bool tx_not_rx, rmt_reserve_memsize_t memsize) break; } } - if (i == MAX_CHANNELS || i+j >= MAX_CHANNELS || j != buffers) { + if (i == MAX_CHANNELS || i+j > MAX_CHANNELS || j != buffers) { xSemaphoreGive(g_rmt_block_lock); return NULL; }