From 353826caccca477ff742dc7a54ee52074b377b7d Mon Sep 17 00:00:00 2001 From: morris Date: Mon, 19 Oct 2020 19:04:54 +0800 Subject: [PATCH] rmt: fix RMT data trancate issue Closes https://github.com/espressif/esp-idf/issues/5992 --- components/soc/esp32/include/hal/rmt_ll.h | 3 ++- components/soc/esp32s2beta/include/hal/rmt_ll.h | 3 ++- components/soc/include/hal/rmt_hal.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/soc/esp32/include/hal/rmt_ll.h b/components/soc/esp32/include/hal/rmt_ll.h index 1749b2be37..159c92585a 100644 --- a/components/soc/esp32/include/hal/rmt_ll.h +++ b/components/soc/esp32/include/hal/rmt_ll.h @@ -270,9 +270,10 @@ static inline void rmt_ll_set_carrier_to_level(rmt_dev_t *dev, uint32_t channel, dev->conf_ch[channel].conf0.carrier_out_lv = level; } +//Writes items to the specified TX channel memory with the given offset and writen length. +//the caller should ensure that (length + off) <= (memory block * RMT_CHANNEL_MEM_WORDS) static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const rmt_item32_t *data, uint32_t length, uint32_t off) { - length = (off + length) > RMT_CHANNEL_MEM_WORDS ? (RMT_CHANNEL_MEM_WORDS - off) : length; for (uint32_t i = 0; i < length; i++) { mem->chan[channel].data32[i + off].val = data[i].val; } diff --git a/components/soc/esp32s2beta/include/hal/rmt_ll.h b/components/soc/esp32s2beta/include/hal/rmt_ll.h index 777c5cf9c4..0bf969a61b 100644 --- a/components/soc/esp32s2beta/include/hal/rmt_ll.h +++ b/components/soc/esp32s2beta/include/hal/rmt_ll.h @@ -263,9 +263,10 @@ static inline void rmt_ll_set_carrier_to_level(rmt_dev_t *dev, uint32_t channel, dev->conf_ch[channel].conf0.carrier_out_lv = level; } +//Writes items to the specified TX channel memory with the given offset and writen length. +//the caller should ensure that (length + off) <= (memory block * RMT_CHANNEL_MEM_WORDS) static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const rmt_item32_t *data, uint32_t length, uint32_t off) { - length = (off + length) > RMT_CHANNEL_MEM_WORDS ? (RMT_CHANNEL_MEM_WORDS - off) : length; for (uint32_t i = 0; i < length; i++) { mem->chan[channel].data32[i + off].val = data[i].val; } diff --git a/components/soc/include/hal/rmt_hal.h b/components/soc/include/hal/rmt_hal.h index 07102b5c71..14c66a0bd3 100644 --- a/components/soc/include/hal/rmt_hal.h +++ b/components/soc/include/hal/rmt_hal.h @@ -134,6 +134,7 @@ uint32_t rmt_hal_receive(rmt_hal_context_t *hal, uint32_t channel, rmt_item32_t * @param src: RMT items to transmit * @param length: length of RMT items to transmit * @param offset: offset of RMT internal memory to store the items + * @note The caller should ensure that (length + offset) <= (memory block * RMT_CHANNEL_MEM_WORDS). */ void rmt_hal_transmit(rmt_hal_context_t *hal, uint32_t channel, const rmt_item32_t *src, uint32_t length, uint32_t offset);