HPM SDK
HPMicro Software Development Kit
hpm_otp_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2023 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef HPM_OTP_DRV_H
8 #define HPM_OTP_DRV_H
9 
16 #include "hpm_common.h"
17 
18 /***********************************************************************************************************************
19  * Definitions
20  **********************************************************************************************************************/
24 typedef enum {
29 } otp_region_t;
30 
34 typedef enum {
41 
42 enum {
44 };
45 
46 /***********************************************************************************************************************
47  * Prototypes
48  **********************************************************************************************************************/
49 #ifdef __cpluscplus
50 extern "C" {
51 #endif
52 
56 void otp_init(void);
57 
61 void otp_deinit(void);
62 
68 uint32_t otp_read_from_shadow(uint32_t addr);
69 
75 uint32_t otp_read_from_ip(uint32_t addr);
76 
84 hpm_stat_t otp_program(uint32_t addr, const uint32_t *src, uint32_t num_of_words);
85 
92 
99 hpm_stat_t otp_lock_otp(uint32_t addr, otp_lock_option_t lock_option);
100 
107 hpm_stat_t otp_lock_shadow(uint32_t addr, otp_lock_option_t lock_option);
108 
116 hpm_stat_t otp_set_configurable_region(uint32_t start, uint32_t num_of_words);
117 
124 hpm_stat_t otp_write_shadow_register(uint32_t addr, uint32_t val);
125 
126 
127 #ifdef __cpluscplus
128 }
129 #endif
137 #endif
uint32_t hpm_stat_t
Definition: hpm_common.h:123
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:132
@ status_group_otp
Definition: hpm_common.h:147
uint32_t otp_read_from_ip(uint32_t addr)
Read the specified OTP word from OTP IP bus.
Definition: hpm_otp_drv.c:45
hpm_stat_t otp_lock_shadow(uint32_t addr, otp_lock_option_t lock_option)
OTP lock shadow.
Definition: hpm_otp_drv.c:117
hpm_stat_t otp_program(uint32_t addr, const uint32_t *src, uint32_t num_of_words)
Program a word to specified OTP field.
Definition: hpm_otp_drv.c:54
hpm_stat_t otp_set_configurable_region(uint32_t start, uint32_t num_of_words)
Set the configurable region range.
Definition: hpm_otp_drv.c:139
void otp_deinit(void)
De-initialize OTP controller.
Definition: hpm_otp_drv.c:30
hpm_stat_t otp_write_shadow_register(uint32_t addr, uint32_t val)
Definition: hpm_otp_drv.c:156
void otp_init(void)
Initialize OTP controller.
Definition: hpm_otp_drv.c:25
otp_region_t
OTP region definitions.
Definition: hpm_otp_drv.h:24
hpm_stat_t otp_reload(otp_region_t region)
Reload a OTP region.
Definition: hpm_otp_drv.c:80
otp_lock_option_t
OTP lock options.
Definition: hpm_otp_drv.h:34
hpm_stat_t otp_lock_otp(uint32_t addr, otp_lock_option_t lock_option)
Change the Software lock permission.
Definition: hpm_otp_drv.c:95
uint32_t otp_read_from_shadow(uint32_t addr)
Read the OTP word from shadow register.
Definition: hpm_otp_drv.c:35
@ otp_write_disallowed
Definition: hpm_otp_drv.h:43
@ otp_region3_mask
Definition: hpm_otp_drv.h:28
@ otp_region0_mask
Definition: hpm_otp_drv.h:25
@ otp_region1_mask
Definition: hpm_otp_drv.h:26
@ otp_region2_mask
Definition: hpm_otp_drv.h:27
@ otp_no_lock
Definition: hpm_otp_drv.h:35
@ otp_permanent_no_lock
Definition: hpm_otp_drv.h:37
@ otp_disable_access
Definition: hpm_otp_drv.h:38
@ otp_read_only
Definition: hpm_otp_drv.h:36
@ otp_lock_option_max
Definition: hpm_otp_drv.h:39