From f44aa9bcc54de2bbbd90bdd1ea65c80ccbdf8889 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Mon, 19 Dec 2022 12:27:40 +0800 Subject: [PATCH] i2s: fixed rx update stuck bug --- components/hal/esp32c3/include/hal/i2s_ll.h | 12 ++++-------- components/hal/esp32c6/include/hal/i2s_ll.h | 6 ++++-- components/hal/esp32h4/include/hal/i2s_ll.h | 6 ++++-- components/hal/esp32s3/include/hal/i2s_ll.h | 6 ++++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/components/hal/esp32c3/include/hal/i2s_ll.h b/components/hal/esp32c3/include/hal/i2s_ll.h index 196ecc8eb8..9425d65202 100644 --- a/components/hal/esp32c3/include/hal/i2s_ll.h +++ b/components/hal/esp32c3/include/hal/i2s_ll.h @@ -419,12 +419,10 @@ finish: */ static inline void i2s_ll_tx_start(i2s_dev_t *hw) { - // TODO: solve the bug that can't update - // hw->tx_conf.tx_update = 0; - while (hw->tx_conf.tx_update); + // Have to update registers before start hw->tx_conf.tx_update = 1; - hw->tx_conf.tx_start = 1; while (hw->tx_conf.tx_update); + hw->tx_conf.tx_start = 1; } /** @@ -434,12 +432,10 @@ static inline void i2s_ll_tx_start(i2s_dev_t *hw) */ static inline void i2s_ll_rx_start(i2s_dev_t *hw) { - // TODO: solve the bug that can't update - // hw->rx_conf.rx_update = 0; - while (hw->rx_conf.rx_update); + // Have to update registers before start hw->rx_conf.rx_update = 1; - hw->rx_conf.rx_start = 1; while (hw->rx_conf.rx_update); + hw->rx_conf.rx_start = 1; } /** diff --git a/components/hal/esp32c6/include/hal/i2s_ll.h b/components/hal/esp32c6/include/hal/i2s_ll.h index 3d36a0af89..87d3e13d08 100644 --- a/components/hal/esp32c6/include/hal/i2s_ll.h +++ b/components/hal/esp32c6/include/hal/i2s_ll.h @@ -434,8 +434,9 @@ finish: */ static inline void i2s_ll_tx_start(i2s_dev_t *hw) { - hw->tx_conf.tx_update = 0; + // Have to update registers before start hw->tx_conf.tx_update = 1; + while (hw->tx_conf.tx_update); hw->tx_conf.tx_start = 1; } @@ -446,8 +447,9 @@ static inline void i2s_ll_tx_start(i2s_dev_t *hw) */ static inline void i2s_ll_rx_start(i2s_dev_t *hw) { - hw->rx_conf.rx_update = 0; + // Have to update registers before start hw->rx_conf.rx_update = 1; + while (hw->rx_conf.rx_update); hw->rx_conf.rx_start = 1; } diff --git a/components/hal/esp32h4/include/hal/i2s_ll.h b/components/hal/esp32h4/include/hal/i2s_ll.h index b19165ad77..e9c0f74227 100644 --- a/components/hal/esp32h4/include/hal/i2s_ll.h +++ b/components/hal/esp32h4/include/hal/i2s_ll.h @@ -420,8 +420,9 @@ finish: */ static inline void i2s_ll_tx_start(i2s_dev_t *hw) { - hw->tx_conf.tx_update = 0; + // Have to update registers before start hw->tx_conf.tx_update = 1; + while (hw->tx_conf.tx_update); hw->tx_conf.tx_start = 1; } @@ -432,8 +433,9 @@ static inline void i2s_ll_tx_start(i2s_dev_t *hw) */ static inline void i2s_ll_rx_start(i2s_dev_t *hw) { - hw->rx_conf.rx_update = 0; + // Have to update registers before start hw->rx_conf.rx_update = 1; + while (hw->rx_conf.rx_update); hw->rx_conf.rx_start = 1; } diff --git a/components/hal/esp32s3/include/hal/i2s_ll.h b/components/hal/esp32s3/include/hal/i2s_ll.h index d9c0cf26f2..7660a3efc5 100644 --- a/components/hal/esp32s3/include/hal/i2s_ll.h +++ b/components/hal/esp32s3/include/hal/i2s_ll.h @@ -419,8 +419,9 @@ finish: */ static inline void i2s_ll_tx_start(i2s_dev_t *hw) { - hw->tx_conf.tx_update = 0; + // Have to update registers before start hw->tx_conf.tx_update = 1; + while (hw->tx_conf.tx_update); hw->tx_conf.tx_start = 1; } @@ -431,8 +432,9 @@ static inline void i2s_ll_tx_start(i2s_dev_t *hw) */ static inline void i2s_ll_rx_start(i2s_dev_t *hw) { - hw->rx_conf.rx_update = 0; + // Have to update registers before start hw->rx_conf.rx_update = 1; + while (hw->rx_conf.rx_update); hw->rx_conf.rx_start = 1; }