gr55xx_hal_efuse.h
Go to the documentation of this file.
1
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_EFUSE_H__
53 #define __GR55xx_HAL_EFUSE_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_hal_def.h"
61 #include "gr55xx_ll_efuse.h"
62
63 /* Exported types ------------------------------------------------------------*/
75 typedef enum
76 {
77 HAL_EFUSE_STATE_RESET = 0x00,
78 HAL_EFUSE_STATE_READY = 0x01,
79 HAL_EFUSE_STATE_BUSY = 0x02,
80 HAL_EFUSE_STATE_ERROR = 0x04
81 } hal_efuse_state_t;
97 typedef struct _efuse_init
98 {
99 uint32_t info_mode;
101 } efuse_init_t;
102
112 typedef struct _efuse_handle
113 {
114 efuse_regs_t *p_instance;
116 efuse_init_t init;
118 __IO hal_lock_t lock;
120 __IO hal_efuse_state_t state;
122 __IO uint32_t error_code;
124 } efuse_handle_t;
134 typedef struct _keyram_mask
135 {
136 uint32_t aes_mask;
138 uint32_t hmac_mask;
140 uint32_t present_mcu_mask;
142 uint32_t present_xip_mask;
144 uint32_t efuse_mask;
146 uint32_t enc_key_low;
148 uint32_t enc_key_high;
149 } keyram_mask_t;
150
167 typedef struct _hal_efuse_callback
168 {
169 void (*efuse_msp_init)(efuse_handle_t *p_efuse);
170 void (*efuse_msp_deinit)(efuse_handle_t *p_efuse);
171 } hal_efuse_callback_t;
172
182 /* Exported macro ------------------------------------------------------------*/
190 #define HAL_EFUSE_ERROR_NONE ((uint32_t)0x00000000)
191 #define HAL_EFUSE_ERROR_TIMEOUT ((uint32_t)0x00000001)
192 #define HAL_EFUSE_ERROR_INVALID_PARAM ((uint32_t)0x00000002)
198 #define EFUSE_FLAG_WRITE_KEYRAM_BUSY LL_EFUSE_WRITE_KEYRAM_BUSY
199 #define EFUSE_FLAG_READ_TRIM_DONE LL_EFUSE_READ_TRIM_DONE
200 #define EFUSE_FLAG_CRC_CHECK_DONE LL_EFUSE_CRC_CHECK_DONE
201 #define EFUSE_FLAG_CRC_CHECK_SUCCESS LL_EFUSE_CRC_CHECK_SUCCESS
202 #define EFUSE_FLAG_INIT_CHECK_DONE LL_EFUSE_INIT_CHECK_DONE
203 #define EFUSE_FLAG_INIT_CHECK_SUCCESS LL_EFUSE_INIT_CHECK_SUCCESS
204 #define EFUSE_FLAG_WRITE_DONE LL_EFUSE_WRITE_DONE
205 #define EFUSE_FLAG_TEST_DONE LL_EFUSE_TEST_DONE
211 #define EFUSE_OFFSET_USER_DSVD (0x0000UL)
212 #define EFUSE_OFFSET_BBLK_TRIM (0x0020UL)
213 #define EFUSE_OFFSET_BBLK_CONFIG (0x005CUL)
214 #define EFUSE_OFFSET_BBLK_SWD (0x0060UL)
215 #define EFUSE_OFFSET_BBLK_EncMode (0x0062UL)
216 #define EFUSE_OFFSET_BBLK_CRC32 (0x0064UL)
217 #define EFUSE_OFFSET_BBLK_CHIP_ID (0x0068UL)
218 #define EFUSE_OFFSET_BBLK_PRODUCT_ID (0x006EUL)
219 #define EFUSE_OFFSET_BBLK_FW_PUBLICKEY (0x0070UL)
220 #define EFUSE_OFFSET_BBLK_ROOT_PUBLICKEY (0x0080UL)
221 #define EFUSE_OFFSET_BBLK_ECC_KEY (0x0090UL)
222 #define EFUSE_OFFSET_BBLK_FW_KEY (0x00B0UL)
223 #define EFUSE_OFFSET_BBLK_HMAC_KEY (0x00D0UL)
224 #define EFUSE_OFFSET_BBLK_DATA_KEY (0x00F0UL)
225 #define EFUSE_OFFSET_MBLK_TRIM (0x0110UL)
226 #define EFUSE_OFFSET_MBLK_CONFIG (0x014CUL)
227 #define EFUSE_OFFSET_MBLK_SWD (0x0150UL)
228 #define EFUSE_OFFSET_MBLK_EncMode (0x0152UL)
229 #define EFUSE_OFFSET_MBLK_CRC32 (0x0154UL)
230 #define EFUSE_OFFSET_MBLK_CHIP_ID (0x0158UL)
231 #define EFUSE_OFFSET_MBLK_PRODUCT_ID (0x015EUL)
232 #define EFUSE_OFFSET_MBLK_FW_PUBLICKEY (0x0160UL)
233 #define EFUSE_OFFSET_MBLK_ROOT_PUBLICKEY (0x0170UL)
234 #define EFUSE_OFFSET_MBLK_ECC_KEY (0x0180UL)
235 #define EFUSE_OFFSET_MBLK_FW_KEY (0x01A0UL)
236 #define EFUSE_OFFSET_MBLK_HMAC_KEY (0x01C0UL)
237 #define EFUSE_OFFSET_MBLK_DATA_KEY (0x01E0UL)
238 #define EFUSE_OFFSET_END (0x0200UL)
243 /* Exported macro ------------------------------------------------------------*/
244
252 #define __HAL_EFUSE_ENABLE_MAIN_BACKUP(__HANDLE__) ll_efuse_enable_main_backup((__HANDLE__)->p_instance)
253
258 #define __HAL_EFUSE_DISABLE_MAIN_BACKUP(__HANDLE__) ll_efuse_disable_main_backup((__HANDLE__)->p_instance)
259
264 #define __HAL_EFUSE_ENABLE_PGENB(__HANDLE__) ll_efuse_enable_pgenb((__HANDLE__)->p_instance)
265
270 #define __HAL_EFUSE_DISABLE_PGENB(__HANDLE__) ll_efuse_disable_pgenb((__HANDLE__)->p_instance)
271
286 #define __HAL_EFUSE_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
287
291 /* Exported functions --------------------------------------------------------*/
333 hal_status_t hal_efuse_init(efuse_handle_t *p_efuse);
334
347 hal_status_t hal_efuse_deinit(efuse_handle_t *p_efuse);
348
359 void hal_efuse_msp_init(efuse_handle_t *p_efuse);
360
371 void hal_efuse_msp_deinit(efuse_handle_t *p_efuse);
372
398 hal_status_t hal_efuse_write(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t *p_data, uint32_t nword);
399
417 hal_status_t hal_efuse_read(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t *p_data, uint32_t nword);
418
432 hal_status_t hal_efuse_write_keyram(efuse_handle_t *p_efuse, keyram_mask_t *p_mask);
433
446 hal_status_t hal_efuse_initial_value_check(efuse_handle_t *p_efuse);
447
465 hal_status_t hal_efuse_crc_calculate(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t nword, uint32_t *p_result);
466
484 hal_status_t hal_efuse_read_trim(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t *p_data, uint32_t nword);
485
498 hal_status_t hal_efuse_set_main_backup(efuse_handle_t *p_efuse);
499
504 #ifdef __cplusplus
505 }
506 #endif
507
508 #endif /* __GR55xx_HAL_EFUSE_H__ */
509
hal_efuse_read
hal_status_t hal_efuse_read(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t *p_data, uint32_t nword)
Read the eFuse memory data.
hal_efuse_set_main_backup
hal_status_t hal_efuse_set_main_backup(efuse_handle_t *p_efuse)
Set the main or backup info of the eFuse memory.
gr55xx_ll_efuse.h
Header file containing functions prototypes of eFuse LL library.
_keyram_mask::present_xip_mask
uint32_t present_xip_mask
Definition: gr55xx_hal_efuse.h:142
efuse_handle_t
struct _efuse_handle efuse_handle_t
eFuse handle Structure definition
_keyram_mask::aes_mask
uint32_t aes_mask
Definition: gr55xx_hal_efuse.h:136
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_efuse_handle
eFuse handle Structure definition
Definition: gr55xx_hal_efuse.h:113
_efuse_init::info_mode
uint32_t info_mode
Definition: gr55xx_hal_efuse.h:99
_keyram_mask::present_mcu_mask
uint32_t present_mcu_mask
Definition: gr55xx_hal_efuse.h:140
efuse_init_t
struct _efuse_init efuse_init_t
eFuse init Structure definition
_efuse_handle::init
efuse_init_t init
Definition: gr55xx_hal_efuse.h:116
_keyram_mask
eFuse Keyram Structure definition
Definition: gr55xx_hal_efuse.h:135
_hal_efuse_callback::efuse_msp_init
void(* efuse_msp_init)(efuse_handle_t *p_efuse)
Definition: gr55xx_hal_efuse.h:169
hal_efuse_callback_t
struct _hal_efuse_callback hal_efuse_callback_t
HAL_EFUSE Callback function definition.
hal_efuse_crc_calculate
hal_status_t hal_efuse_crc_calculate(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t nword, uint32_t *p_result)
Calculate CRC of the eFuse memory data.
hal_efuse_write
hal_status_t hal_efuse_write(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t *p_data, uint32_t nword)
Write the eFuse memory data.
HAL_EFUSE_STATE_RESET
@ HAL_EFUSE_STATE_RESET
Definition: gr55xx_hal_efuse.h:77
hal_efuse_init
hal_status_t hal_efuse_init(efuse_handle_t *p_efuse)
Initialize the eFuse according to the specified parameters in the efuse_init_t and initialize the ass...
hal_efuse_read_trim
hal_status_t hal_efuse_read_trim(efuse_handle_t *p_efuse, uint32_t word_offset, uint32_t *p_data, uint32_t nword)
Read trim from eFuse memory data.
_keyram_mask::hmac_mask
uint32_t hmac_mask
Definition: gr55xx_hal_efuse.h:138
_hal_efuse_callback
HAL_EFUSE Callback function definition.
Definition: gr55xx_hal_efuse.h:168
_efuse_handle::p_instance
efuse_regs_t * p_instance
Definition: gr55xx_hal_efuse.h:114
_efuse_init
eFuse init Structure definition
Definition: gr55xx_hal_efuse.h:98
keyram_mask_t
struct _keyram_mask keyram_mask_t
eFuse Keyram Structure definition
hal_efuse_msp_deinit
void hal_efuse_msp_deinit(efuse_handle_t *p_efuse)
De-initialize the eFuse MSP.
hal_efuse_initial_value_check
hal_status_t hal_efuse_initial_value_check(efuse_handle_t *p_efuse)
Check the eFuse memory with 0, if memory are all 0, return HAL_OK, then return HAL_ERROR.
_keyram_mask::enc_key_low
uint32_t enc_key_low
Definition: gr55xx_hal_efuse.h:146
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
HAL_EFUSE_STATE_READY
@ HAL_EFUSE_STATE_READY
Definition: gr55xx_hal_efuse.h:78
_keyram_mask::efuse_mask
uint32_t efuse_mask
Definition: gr55xx_hal_efuse.h:144
_efuse_handle::state
__IO hal_efuse_state_t state
Definition: gr55xx_hal_efuse.h:120
_keyram_mask::enc_key_high
uint32_t enc_key_high
Definition: gr55xx_hal_efuse.h:148
_efuse_handle::error_code
__IO uint32_t error_code
Definition: gr55xx_hal_efuse.h:122
hal_efuse_deinit
hal_status_t hal_efuse_deinit(efuse_handle_t *p_efuse)
De-initialize the eFuse peripheral.
hal_efuse_msp_init
void hal_efuse_msp_init(efuse_handle_t *p_efuse)
Initialize the eFuse MSP.
HAL_EFUSE_STATE_BUSY
@ HAL_EFUSE_STATE_BUSY
Definition: gr55xx_hal_efuse.h:79
HAL_EFUSE_STATE_ERROR
@ HAL_EFUSE_STATE_ERROR
Definition: gr55xx_hal_efuse.h:80
hal_efuse_state_t
hal_efuse_state_t
HAL eFuse State Enumerations definition.
Definition: gr55xx_hal_efuse.h:76
hal_efuse_write_keyram
hal_status_t hal_efuse_write_keyram(efuse_handle_t *p_efuse, keyram_mask_t *p_mask)
Read the key from eFuse memory and write to keyram.
_hal_efuse_callback::efuse_msp_deinit
void(* efuse_msp_deinit)(efuse_handle_t *p_efuse)
Definition: gr55xx_hal_efuse.h:170
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_efuse_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_efuse.h:118