Go to the documentation of this file.
51 #ifndef __GR55XX_LL_HMAC_H__
52 #define __GR55XX_LL_HMAC_H__
101 #define LL_HMAC_FLAG_DATAREADY_SHA HMAC_STATUS_DATAREADY_SHA
102 #define LL_HMAC_FLAG_DATAREADY_HMAC HMAC_STATUS_DATAREADY_HMAC
103 #define LL_HMAC_FLAG_DMA_MESSAGEDONE HMAC_STATUS_MESSAGEDONE_DMA
104 #define LL_HMAC_FLAG_DMA_DONE HMAC_STATUS_TRANSDONE_DMA
105 #define LL_HMAC_FLAG_DMA_ERR HMAC_STATUS_TRANSERR_DMA
106 #define LL_HMAC_FLAG_KEY_VALID HMAC_STATUS_KEYVALID
112 #define LL_HMAC_HASH_STANDARD 0x00000000U
113 #define LL_HMAC_HASH_USER (1UL << HMAC_CONFIG_ENABLE_USERHASH)
119 #define LL_HMAC_CALCULATETYPE_HMAC 0x00000000U
120 #define LL_HMAC_CALCULATETYPE_SHA (1UL << HMAC_CONFIG_CALCTYPE_Pos)
126 #define LL_HMAC_KEYTYPE_MCU 0x00000000U
127 #define LL_HMAC_KEYTYPE_AHB (1UL << HMAC_CONFIG_KEYTYPE_Pos)
128 #define LL_HMAC_KEYTYPE_KRAM (2UL << HMAC_CONFIG_KEYTYPE_Pos)
134 #define LL_HMAC_DMA_TRANSIZE_MIN (1)
135 #define LL_HMAC_DMA_TRANSIZE_MAX (512)
156 #define LL_HMAC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
164 #define LL_HMAC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
193 SET_BITS(HMACx->CTRL, HMAC_CTRL_ENABLE);
208 CLEAR_BITS(HMACx->CTRL, HMAC_CTRL_ENABLE);
223 return (READ_BITS(HMACx->CTRL, HMAC_CTRL_ENABLE) == (HMAC_CTRL_ENABLE));
238 SET_BITS(HMACx->CTRL, HMAC_CTRL_START_DMA);
253 CLEAR_BITS(HMACx->CTRL, HMAC_CTRL_START_DMA);
268 return (READ_BITS(HMACx->CTRL, HMAC_CTRL_START_DMA) == (HMAC_CTRL_START_DMA));
283 SET_BITS(HMACx->CTRL, HMAC_CTRL_ENABLE_RKEY);
298 SET_BITS(HMACx->CTRL, HMAC_CTRL_LASTTRANSFER);
313 SET_BITS(HMACx->CONFIG, HMAC_CONFIG_ENABLE_USERHASH);
328 CLEAR_BITS(HMACx->CONFIG, HMAC_CONFIG_ENABLE_USERHASH);
343 return (READ_BITS(HMACx->CONFIG, HMAC_CONFIG_ENABLE_USERHASH) == (HMAC_CONFIG_ENABLE_USERHASH));
358 SET_BITS(HMACx->CONFIG, HMAC_CONFIG_ENDIAN);
373 CLEAR_BITS(HMACx->CONFIG, HMAC_CONFIG_ENDIAN);
388 return (READ_BITS(HMACx->CONFIG, HMAC_CONFIG_ENDIAN) == (HMAC_CONFIG_ENDIAN));
407 MODIFY_REG(HMACx->CONFIG, HMAC_CONFIG_KEYTYPE, type);
425 return (READ_BITS(HMACx->CONFIG, HMAC_CONFIG_KEYTYPE));
440 SET_BITS(HMACx->CONFIG, HMAC_CONFIG_CALCTYPE);
455 CLEAR_BITS(HMACx->CONFIG, HMAC_CONFIG_CALCTYPE);
470 return (READ_BITS(HMACx->CONFIG, HMAC_CONFIG_CALCTYPE) == (HMAC_CONFIG_CALCTYPE));
485 SET_BITS(HMACx->CONFIG, HMAC_CONFIG_PRIVATE);
500 CLEAR_BITS(HMACx->CONFIG, HMAC_CONFIG_PRIVATE);
515 return (READ_BITS(HMACx->CONFIG, HMAC_CONFIG_PRIVATE) == (HMAC_CONFIG_PRIVATE));
536 SET_BITS(HMACx->INTERRUPT, HMAC_INTERRUPT_ENABLE);
551 CLEAR_BITS(HMACx->INTERRUPT, HMAC_INTERRUPT_ENABLE);
566 return (READ_BITS(HMACx->INTERRUPT, HMAC_INTERRUPT_ENABLE) == (HMAC_INTERRUPT_ENABLE));
587 return (READ_BITS(HMACx->STATUS, HMAC_STATUS_DATAREADY_SHA) == HMAC_STATUS_DATAREADY_SHA);
602 return (READ_BITS(HMACx->STATUS, HMAC_STATUS_DATAREADY_HMAC) == HMAC_STATUS_DATAREADY_HMAC);
617 return (READ_BITS(HMACx->STATUS, HMAC_STATUS_MESSAGEDONE_DMA) == HMAC_STATUS_MESSAGEDONE_DMA);
632 return (READ_BITS(HMACx->STATUS, HMAC_STATUS_TRANSDONE_DMA) == HMAC_STATUS_TRANSDONE_DMA);
647 return (READ_BITS(HMACx->STATUS, HMAC_STATUS_TRANSERR_DMA) == HMAC_STATUS_TRANSERR_DMA);
662 return (READ_BITS(HMACx->STATUS, HMAC_STATUS_KEYVALID) == HMAC_STATUS_KEYVALID);
677 return (READ_BITS(HMACx->INTERRUPT, HMAC_INTERRUPT_DONE) == HMAC_INTERRUPT_DONE);
692 CLEAR_BITS(HMACx->INTERRUPT, HMAC_INTERRUPT_DONE);
714 MODIFY_REG(HMACx->TRAN_SIZE, HMAC_TRANSIZE, (block << 6) - 1);
729 return ((READ_BITS(HMACx->TRAN_SIZE, HMAC_TRANSIZE) + 1) >> 6);
745 WRITE_REG(HMACx->RSTART_ADDR, address);
760 return (READ_REG(HMACx->RSTART_ADDR));
776 WRITE_REG(HMACx->WSTART_ADDR, address);
791 return (READ_REG(HMACx->WSTART_ADDR));
813 WRITE_REG(HMACx->USER_HASH[0], hash);
829 WRITE_REG(HMACx->USER_HASH[1], hash);
845 WRITE_REG(HMACx->USER_HASH[2], hash);
861 WRITE_REG(HMACx->USER_HASH[3], hash);
877 WRITE_REG(HMACx->USER_HASH[4], hash);
893 WRITE_REG(HMACx->USER_HASH[5], hash);
909 WRITE_REG(HMACx->USER_HASH[6], hash);
925 WRITE_REG(HMACx->USER_HASH[7], hash);
940 return (READ_REG(HMACx->FIFO_OUT));
956 WRITE_REG(HMACx->MESSAGE_FIFO, data);
972 WRITE_REG(HMACx->KEY[0], key);
988 WRITE_REG(HMACx->KEY[1], key);
1004 WRITE_REG(HMACx->KEY[2], key);
1020 WRITE_REG(HMACx->KEY[3], key);
1036 WRITE_REG(HMACx->KEY[4], key);
1052 WRITE_REG(HMACx->KEY[5], key);
1068 WRITE_REG(HMACx->KEY[6], key);
1084 WRITE_REG(HMACx->KEY[7], key);
1100 WRITE_REG(HMACx->KEY_ADDR, address);
1115 return (READ_REG(HMACx->KEY_ADDR));
1131 WRITE_REG(HMACx->KPORT_MASK, mask);
__STATIC_INLINE void ll_hmac_set_data(hmac_regs_t *HMACx, uint32_t data)
Send data to calculate.
Definition: gr55xx_ll_hmac.h:954
__STATIC_INLINE void ll_hmac_set_key_type(hmac_regs_t *HMACx, uint32_t type)
Set ways to obtain HMAC key.
Definition: gr55xx_ll_hmac.h:405
__STATIC_INLINE uint32_t ll_hmac_is_enabled_private(hmac_regs_t *HMACx)
Indicate whether the private mode is enabled.
Definition: gr55xx_ll_hmac.h:513
__STATIC_INLINE void ll_hmac_enable_read_key(hmac_regs_t *HMACx)
Enable fetch key through AHB/key port.
Definition: gr55xx_ll_hmac.h:281
struct _ll_hmac_init_t ll_hmac_init_t
LL HMAC Init Structure definition.
__STATIC_INLINE void ll_hmac_set_key_port_mask(hmac_regs_t *HMACx, uint32_t mask)
Set HMAC fetch key port mask.
Definition: gr55xx_ll_hmac.h:1129
__STATIC_INLINE uint32_t ll_hmac_is_action_flag_sha_ready(hmac_regs_t *HMACx)
Indicate whether SHA Ready flag is set.
Definition: gr55xx_ll_hmac.h:585
__STATIC_INLINE uint32_t ll_hmac_is_enabled(hmac_regs_t *HMACx)
Indicate whether the HMAC is enabled.
Definition: gr55xx_ll_hmac.h:221
__STATIC_INLINE void ll_hmac_set_user_hash_223_192(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[223:192].
Definition: gr55xx_ll_hmac.h:827
__STATIC_INLINE void ll_hmac_clear_flag_it_done(hmac_regs_t *HMACx)
Clear Done interrupt flag.
Definition: gr55xx_ll_hmac.h:690
__STATIC_INLINE void ll_hmac_disable_dma_start(hmac_regs_t *HMACx)
Disable HMAC DMA mode.
Definition: gr55xx_ll_hmac.h:251
__STATIC_INLINE uint32_t ll_hmac_is_enabled_it_done(hmac_regs_t *HMACx)
Indicate whether Done Interrupt is enabled.
Definition: gr55xx_ll_hmac.h:564
__STATIC_INLINE void ll_hmac_set_key7(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key7.
Definition: gr55xx_ll_hmac.h:1082
__STATIC_INLINE void ll_hmac_disable_sha(hmac_regs_t *HMACx)
Disable SHA mode.
Definition: gr55xx_ll_hmac.h:453
__STATIC_INLINE void ll_hmac_set_key_address(hmac_regs_t *HMACx, uint32_t address)
Set HMAC key address in memory.
Definition: gr55xx_ll_hmac.h:1098
__STATIC_INLINE uint32_t ll_hmac_is_action_flag_key_valid(hmac_regs_t *HMACx)
Indicate whether Key Valid flag is set.
Definition: gr55xx_ll_hmac.h:660
__STATIC_INLINE uint32_t ll_hmac_get_dma_write_address(hmac_regs_t *HMACx)
Get HMAC write address of RAM in DMA mode.
Definition: gr55xx_ll_hmac.h:789
__STATIC_INLINE void ll_hmac_set_key4(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key4.
Definition: gr55xx_ll_hmac.h:1034
__STATIC_INLINE void ll_hmac_enable(hmac_regs_t *HMACx)
Enable HMAC.
Definition: gr55xx_ll_hmac.h:191
__STATIC_INLINE uint32_t ll_hmac_is_enabled_little_endian(hmac_regs_t *HMACx)
Indicate whether the HMAC is in little endian.
Definition: gr55xx_ll_hmac.h:386
__STATIC_INLINE void ll_hmac_set_key1(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key1.
Definition: gr55xx_ll_hmac.h:986
__STATIC_INLINE void ll_hmac_enable_user_hash(hmac_regs_t *HMACx)
Enable user HASH.
Definition: gr55xx_ll_hmac.h:311
__STATIC_INLINE uint32_t ll_hmac_is_enabled_sha(hmac_regs_t *HMACx)
Indicate whether the SHA mode is enabled.
Definition: gr55xx_ll_hmac.h:468
__STATIC_INLINE void ll_hmac_enable_last_transfer(hmac_regs_t *HMACx)
Enable last block transfer in MCU/DMA mode.
Definition: gr55xx_ll_hmac.h:296
__STATIC_INLINE void ll_hmac_enable_little_endian(hmac_regs_t *HMACx)
Enable HMAC in little endian.
Definition: gr55xx_ll_hmac.h:356
error_status_t ll_hmac_init(hmac_regs_t *HMACx, ll_hmac_init_t *p_hmac_init)
Initialize HMAC registers according to the specified parameters in p_hmac_init.
__STATIC_INLINE void ll_hmac_set_dma_transfer_block(hmac_regs_t *HMACx, uint32_t block)
Set HMAC transfer blocks in DMA mode.
Definition: gr55xx_ll_hmac.h:712
__STATIC_INLINE void ll_hmac_set_user_hash_63_32(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[63:32].
Definition: gr55xx_ll_hmac.h:907
__STATIC_INLINE uint32_t ll_hmac_is_enabled_dma_start(hmac_regs_t *HMACx)
Indicate whether the HMAC DMA mode is enabled.
Definition: gr55xx_ll_hmac.h:266
__STATIC_INLINE uint32_t ll_hmac_get_key_type(hmac_regs_t *HMACx)
Get ways to obtain HMAC key.
Definition: gr55xx_ll_hmac.h:423
__STATIC_INLINE void ll_hmac_set_user_hash_31_0(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[31:0].
Definition: gr55xx_ll_hmac.h:923
__STATIC_INLINE void ll_hmac_disable_little_endian(hmac_regs_t *HMACx)
Disable HMAC in little endian.
Definition: gr55xx_ll_hmac.h:371
__STATIC_INLINE uint32_t ll_hmac_is_action_flag_hmac_ready(hmac_regs_t *HMACx)
Indicate whether HMAC Ready flag is set.
Definition: gr55xx_ll_hmac.h:600
__STATIC_INLINE uint32_t ll_hmac_get_key_address(hmac_regs_t *HMACx)
Get HMAC key address in memory.
Definition: gr55xx_ll_hmac.h:1113
__STATIC_INLINE uint32_t ll_hmac_is_action_flag_dma_message_done(hmac_regs_t *HMACx)
Indicate whether DMA Transmit Message Done flag is set.
Definition: gr55xx_ll_hmac.h:615
__STATIC_INLINE uint32_t ll_hmac_is_action_flag_dma_error(hmac_regs_t *HMACx)
Indicate whether DMA Transfer Error flag is set.
Definition: gr55xx_ll_hmac.h:645
__STATIC_INLINE void ll_hmac_set_key2(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key2.
Definition: gr55xx_ll_hmac.h:1002
__STATIC_INLINE void ll_hmac_enable_private(hmac_regs_t *HMACx)
Enable private mode.
Definition: gr55xx_ll_hmac.h:483
__STATIC_INLINE void ll_hmac_set_key3(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key3.
Definition: gr55xx_ll_hmac.h:1018
__STATIC_INLINE void ll_hmac_set_key5(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key5.
Definition: gr55xx_ll_hmac.h:1050
__STATIC_INLINE void ll_hmac_set_user_hash_191_160(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[191:160].
Definition: gr55xx_ll_hmac.h:843
__STATIC_INLINE uint32_t ll_hmac_is_enabled_user_hash(hmac_regs_t *HMACx)
Indicate whether the user HASH is enabled.
Definition: gr55xx_ll_hmac.h:341
void ll_hmac_struct_init(ll_hmac_init_t *p_hmac_init)
Set each field of a ll_hmac_init_t type structure to default value.
__STATIC_INLINE void ll_hmac_disable(hmac_regs_t *HMACx)
Disable HMAC.
Definition: gr55xx_ll_hmac.h:206
__STATIC_INLINE void ll_hmac_disable_user_hash(hmac_regs_t *HMACx)
Disable user HASH.
Definition: gr55xx_ll_hmac.h:326
__STATIC_INLINE uint32_t ll_hmac_is_action_flag_dma_done(hmac_regs_t *HMACx)
Indicate whether DMA Transfer Done flag is set.
Definition: gr55xx_ll_hmac.h:630
__STATIC_INLINE uint32_t ll_hmac_is_action_flag_it_done(hmac_regs_t *HMACx)
Indicate whether Done interrupt flag is set.
Definition: gr55xx_ll_hmac.h:675
uint32_t * p_key
Definition: gr55xx_ll_hmac.h:77
__STATIC_INLINE void ll_hmac_enable_sha(hmac_regs_t *HMACx)
Enable SHA mode.
Definition: gr55xx_ll_hmac.h:438
__STATIC_INLINE void ll_hmac_set_key6(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key6.
Definition: gr55xx_ll_hmac.h:1066
uint32_t * p_hash
Definition: gr55xx_ll_hmac.h:79
error_status_t ll_hmac_deinit(hmac_regs_t *HMACx)
De-initialize HMAC registers (Registers restored to their default values).
__STATIC_INLINE void ll_hmac_enable_it_done(hmac_regs_t *HMACx)
Enable the done interrupt for HMAC.
Definition: gr55xx_ll_hmac.h:534
__STATIC_INLINE uint32_t ll_hmac_get_data(hmac_regs_t *HMACx)
Get abstract from HMAC.
Definition: gr55xx_ll_hmac.h:938
__STATIC_INLINE void ll_hmac_set_user_hash_255_224(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[255:224].
Definition: gr55xx_ll_hmac.h:811
__STATIC_INLINE void ll_hmac_set_dma_write_address(hmac_regs_t *HMACx, uint32_t address)
Set HMAC write address of RAM in DMA mode.
Definition: gr55xx_ll_hmac.h:774
LL HMAC Init Structure definition.
Definition: gr55xx_ll_hmac.h:76
__STATIC_INLINE void ll_hmac_set_user_hash_95_64(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[95:64].
Definition: gr55xx_ll_hmac.h:891
__STATIC_INLINE void ll_hmac_disable_private(hmac_regs_t *HMACx)
Disable private mode.
Definition: gr55xx_ll_hmac.h:498
__STATIC_INLINE void ll_hmac_set_user_hash_127_96(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[127:96].
Definition: gr55xx_ll_hmac.h:875
__STATIC_INLINE void ll_hmac_set_user_hash_159_128(hmac_regs_t *HMACx, uint32_t hash)
Set user HASH[159:128].
Definition: gr55xx_ll_hmac.h:859
__STATIC_INLINE void ll_hmac_set_key0(hmac_regs_t *HMACx, uint32_t key)
Set HMAC key0.
Definition: gr55xx_ll_hmac.h:970
__STATIC_INLINE void ll_hmac_disable_it_done(hmac_regs_t *HMACx)
Disable the done interrupt for HMAC.
Definition: gr55xx_ll_hmac.h:549
__STATIC_INLINE void ll_hmac_set_dma_read_address(hmac_regs_t *HMACx, uint32_t address)
Set HMAC read address of RAM in DMA mode.
Definition: gr55xx_ll_hmac.h:743
__STATIC_INLINE void ll_hmac_enable_dma_start(hmac_regs_t *HMACx)
Enable HMAC DMA mode.
Definition: gr55xx_ll_hmac.h:236
__STATIC_INLINE uint32_t ll_hmac_get_dma_transfer_block(hmac_regs_t *HMACx)
Get HMAC transfer blocks in DMA mode.
Definition: gr55xx_ll_hmac.h:727
__STATIC_INLINE uint32_t ll_hmac_get_dma_read_address(hmac_regs_t *HMACx)
Get HMAC read address of RAM in DMA mode.
Definition: gr55xx_ll_hmac.h:758