From 215e1391cebf3c57c1b70f5b0f5f3366f6620c8d Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Tue, 28 May 2024 12:24:08 +0530 Subject: [PATCH] fix(hal): updated ecdsa reset api to execute correctly This commit updated API to ensure ECDSA peripheral resets and waits until the state returns to idle. --- components/hal/esp32p4/include/hal/ecdsa_ll.h | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/components/hal/esp32p4/include/hal/ecdsa_ll.h b/components/hal/esp32p4/include/hal/ecdsa_ll.h index 898ce1fd27..f3429cf1b2 100644 --- a/components/hal/esp32p4/include/hal/ecdsa_ll.h +++ b/components/hal/esp32p4/include/hal/ecdsa_ll.h @@ -71,6 +71,16 @@ typedef enum { ECDSA_MODE_SHA_CONTINUE } ecdsa_ll_sha_mode_t; +/** + * @brief Get the state of ECDSA peripheral + * + * @return State of ECDSA + */ +static inline uint32_t ecdsa_ll_get_state(void) +{ + return REG_GET_FIELD(ECDSA_STATE_REG, ECDSA_BUSY); +} + /** * @brief Enable the bus clock for ECDSA peripheral module * @@ -95,6 +105,10 @@ static inline void ecdsa_ll_reset_register(void) // Clear reset on parent crypto, otherwise ECDSA is held in reset HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_crypto = 0; + + while (ecdsa_ll_get_state() != ECDSA_STATE_IDLE) { + ; + } } /** @@ -273,16 +287,6 @@ static inline void ecdsa_ll_set_stage(ecdsa_ll_stage_t stage) } } -/** - * @brief Get the state of ECDSA peripheral - * - * @return State of ECDSA - */ -static inline uint32_t ecdsa_ll_get_state(void) -{ - return REG_GET_FIELD(ECDSA_STATE_REG, ECDSA_BUSY); -} - /** * @brief Set the SHA type *