mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-17 23:28:15 +00:00
feat(hmac): use RCC atomic block to enable/reset the HMAC peripheral
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user