SmartSnippets DA1459x SDK
hw_aes_hash.h
Go to the documentation of this file.
1 
42 #ifndef HW_AES_HASH_H_
43 #define HW_AES_HASH_H_
44 
45 #include <stdbool.h>
46 #include "sdk_defs.h"
47 
48 
49 #if dg_configUSE_HW_AES || dg_configUSE_HW_HASH
50 
54 typedef enum {
55  HW_AES_HASH_STATUS_UNLOCKED = 0,
56  HW_AES_HASH_STATUS_LOCKED_BY_AES = 1,
57  HW_AES_HASH_STATUS_LOCKED_BY_HASH = 2,
59 
79 typedef enum {
80  HW_AES_HASH_IRQ_MASK_INACTIVE = REG_MSK(AES_HASH, CRYPTO_STATUS_REG, CRYPTO_INACTIVE),
81  HW_AES_HASH_IRQ_MASK_WAITING_FOR_INPUT = REG_MSK(AES_HASH, CRYPTO_STATUS_REG, CRYPTO_WAIT_FOR_IN),
83 
93 __STATIC_INLINE void hw_aes_hash_set_input_data_mode(bool wait_more_input)
94 {
95  REG_SETF(AES_HASH, CRYPTO_CTRL_REG, CRYPTO_MORE_IN, wait_more_input);
96 }
97 
103 __STATIC_INLINE bool hw_aes_hash_get_input_data_mode(void)
104 {
105  return REG_GETF(AES_HASH, CRYPTO_CTRL_REG, CRYPTO_MORE_IN);
106 }
107 
113 __STATIC_INLINE void hw_aes_hash_set_input_data_len(uint32_t len)
114 {
115  AES_HASH->CRYPTO_LEN_REG = len;
116 }
117 
123 __STATIC_INLINE uint32_t hw_aes_hash_get_input_data_len(void)
124 {
125  return AES_HASH->CRYPTO_LEN_REG;
126 }
127 
134 __STATIC_INLINE bool hw_aes_hash_waiting_for_input_data(void)
135 {
136  return REG_GETF(AES_HASH, CRYPTO_STATUS_REG, CRYPTO_WAIT_FOR_IN) == 0;
137 }
138 
144 void hw_aes_hash_set_input_data_addr(uint32_t inp_data_addr);
145 
151 void hw_aes_hash_set_output_data_addr(uint32_t out_data_addr);
152 
161 
168 typedef void (*hw_aes_hash_cb)(uint32_t status);
169 
174 __STATIC_INLINE void hw_aes_hash_enable_clock(void)
175 {
177  REG_SET_BIT(CRG_TOP, CLK_AMBA_REG, AES_CLK_ENABLE);
179 }
180 
185 __STATIC_INLINE void hw_aes_hash_disable_clock(void)
186 {
188  REG_CLR_BIT(CRG_TOP, CLK_AMBA_REG, AES_CLK_ENABLE);
190 }
191 
197 __STATIC_INLINE bool hw_aes_hash_clock_is_enabled(void)
198 {
199  return REG_GETF(CRG_TOP, CLK_AMBA_REG, AES_CLK_ENABLE);
200 }
201 
223 __ALWAYS_RETAINED_CODE bool hw_aes_hash_is_active(void);
224 
231 __STATIC_INLINE void hw_aes_hash_start(void)
232 {
233  AES_HASH->CRYPTO_START_REG = 1;
234 }
235 
242 void hw_aes_hash_deinit(void);
243 
254 
262 
263 #endif /* dg_configUSE_HW_AES || dg_configUSE_HW_HASH */
264 
265 
266 #endif /* HW_AES_HASH_H_ */
267 
REG_SETF
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
REG_CLR_BIT
#define REG_CLR_BIT(base, reg, field)
Clear a bit of a register.
Definition: sdk_defs.h:781
hw_aes_hash_clock_is_enabled
__STATIC_INLINE bool hw_aes_hash_clock_is_enabled(void)
Check whether the AES/HASH engine clock is enabled or not.
Definition: hw_aes_hash.h:197
REG_SET_BIT
#define REG_SET_BIT(base, reg, field)
Set a bit of a register.
Definition: sdk_defs.h:766
hw_aes_hash_get_input_data_len
__STATIC_INLINE uint32_t hw_aes_hash_get_input_data_len(void)
Get the input data length.
Definition: hw_aes_hash.h:123
hw_aes_hash_set_input_data_mode
__STATIC_INLINE void hw_aes_hash_set_input_data_mode(bool wait_more_input)
Set AES/HASH engine input data mode.
Definition: hw_aes_hash.h:93
hw_aes_hash_interrupt_disable
void hw_aes_hash_interrupt_disable(void)
Disable interrupt for AES/HASH crypto engine.
hw_aes_hash_deinit
void hw_aes_hash_deinit(void)
De-initialize AES/HASH crypto engine.
sdk_defs.h
Central include header file with platform definitions.
hw_aes_hash_waiting_for_input_data
__STATIC_INLINE bool hw_aes_hash_waiting_for_input_data(void)
Check whether the AES/Hash Engine is waiting for more input data or not.
Definition: hw_aes_hash.h:134
HW_AES_HASH_STATUS
HW_AES_HASH_STATUS
AES/HASH engine status.
Definition: hw_aes_hash.h:54
hw_aes_hash_disable_clock
__STATIC_INLINE void hw_aes_hash_disable_clock(void)
Disable AES/HASH engine clock.
Definition: hw_aes_hash.h:185
hw_aes_hash_get_status
HW_AES_HASH_STATUS hw_aes_hash_get_status(void)
Get the status of the AES/HASH engine.
HW_AES_HASH_IRQ_MASK
HW_AES_HASH_IRQ_MASK
Masks of AES/HASH Engine Interrupt sources.
Definition: hw_aes_hash.h:79
hw_aes_hash_set_input_data_len
__STATIC_INLINE void hw_aes_hash_set_input_data_len(uint32_t len)
Set the input data length.
Definition: hw_aes_hash.h:113
hw_aes_hash_interrupt_enable
void hw_aes_hash_interrupt_enable(hw_aes_hash_cb cb)
Enable interrupt for AES/HASH crypto engine.
REG_MSK
#define REG_MSK(base, reg, field)
Access register field mask.
Definition: sdk_defs.h:583
hw_aes_hash_cb
void(* hw_aes_hash_cb)(uint32_t status)
AES/Hash callback.
Definition: hw_aes_hash.h:168
hw_aes_hash_set_input_data_addr
void hw_aes_hash_set_input_data_addr(uint32_t inp_data_addr)
Set the address of the Input Data.
hw_aes_hash_is_active
__ALWAYS_RETAINED_CODE bool hw_aes_hash_is_active(void)
AES/Hash is active.
GLOBAL_INT_RESTORE
#define GLOBAL_INT_RESTORE()
Macro to restore all interrupts.
Definition: sdk_defs.h:477
REG_GETF
#define REG_GETF(base, reg, field)
Return the value of a register field.
Definition: sdk_defs.h:711
hw_aes_hash_set_output_data_addr
void hw_aes_hash_set_output_data_addr(uint32_t out_data_addr)
Set the address of the Output Data.
hw_aes_hash_enable_clock
__STATIC_INLINE void hw_aes_hash_enable_clock(void)
Enable AES/HASH engine clock.
Definition: hw_aes_hash.h:174
hw_aes_hash_get_input_data_mode
__STATIC_INLINE bool hw_aes_hash_get_input_data_mode(void)
Get AES/HASH engine input data mode.
Definition: hw_aes_hash.h:103
hw_aes_hash_start
__STATIC_INLINE void hw_aes_hash_start(void)
Start AES/HASH engine operation.
Definition: hw_aes_hash.h:231
GLOBAL_INT_DISABLE
#define GLOBAL_INT_DISABLE()
Macro to disable all interrupts.
Definition: sdk_defs.h:452