feat(hmac): use RCC atomic block to enable/reset the HMAC peripheral

This commit is contained in:
harshal.patil
2023-09-15 16:58:40 +05:30
parent 1c6ff8ce9f
commit 18b93e9564
10 changed files with 181 additions and 10 deletions

View File

@@ -12,9 +12,11 @@
#pragma once
#include <stdbool.h>
#include <string.h>
#include "soc/system_reg.h"
#include "soc/system_struct.h"
#include "soc/hwcrypto_reg.h"
#include "hal/hmac_types.h"
@@ -30,6 +32,33 @@
extern "C" {
#endif
/**
* @brief Enable the bus clock for HMAC peripheral module
*
* @param true to enable the module, false to disable the module
*/
static inline void hmac_ll_enable_bus_clock(bool enable)
{
SYSTEM.perip_clk_en1.reg_crypto_hmac_clk_en = enable;
}
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
#define hmac_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; hmac_ll_enable_bus_clock(__VA_ARGS__)
/**
* @brief Reset the HMAC peripheral module
*/
static inline void hmac_ll_reset_register(void)
{
SYSTEM.perip_rst_en1.reg_crypto_hmac_rst = 1;
SYSTEM.perip_rst_en1.reg_crypto_hmac_rst = 0;
}
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
#define hmac_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; hmac_ll_reset_register(__VA_ARGS__)
/**
* Makes the peripheral ready for use, after enabling it.
*/