HPM SDK
HPMicro Software Development Kit
hpm_otp_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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 
43 enum {
45 };
46 
47 /***********************************************************************************************************************
48  * Prototypes
49  **********************************************************************************************************************/
50 #ifdef __cpluscplus
51 extern "C" {
52 #endif
53 
57  void otp_init(void);
58 
62  void otp_deinit(void);
63 
69  uint32_t otp_read_from_shadow(uint32_t addr);
70 
76  uint32_t otp_read_from_ip(uint32_t addr);
77 
85  hpm_stat_t otp_program(uint32_t addr, const uint32_t *src, uint32_t num_of_words);
86 
93 
100  hpm_stat_t otp_lock_otp(uint32_t addr, otp_lock_option_t lock_option);
101 
102 
109  hpm_stat_t otp_lock_shadow(uint32_t addr, otp_lock_option_t lock_option);
110 
118  hpm_stat_t otp_set_configurable_region(uint32_t start, uint32_t num_of_words);
119 
126  hpm_stat_t otp_write_shadow_register(uint32_t addr, uint32_t val);
127 
128 
129 #ifdef __cpluscplus
130 }
131 #endif
139 #endif
140 
uint32_t hpm_stat_t
Definition: hpm_common.h:126
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:135
@ status_group_otp
Definition: hpm_common.h:150
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_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
@ otp_write_disallowed
Definition: hpm_otp_drv.h:43