• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  * Description: Provides efuse driver \n
16  *
17  * History: \n
18  * 2024-02-08, Create file. \n
19  */
20 #ifndef EFUSE_USER_H
21 #define EFUSE_USER_H
22 
23 #include <stdint.h>
24 #include "errcode.h"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 #endif /* __cplusplus */
31 
32 /**
33  * @defgroup drivers_driver_efuse eFuse
34  * @ingroup  drivers_driver
35  * @{
36  */
37 
38 /**
39  * @if Eng
40  * @brief  Reads multiple bytes from the eFuse space reserved by the user into the provided buffer.
41  * @param  [in] offset The Start offset address of the eFUSE space to be read in the area reserved for the user,
42            The unit is byte.
43  * @param  [in] buffer The buffer for storing read data.
44  * @param  [in] length The length of the data, in bytes.
45  * @retval ERRCODE_SUCC Success.
46  * @retval Other        Failure. For details, see @ref errcode_t.
47  * @else
48  * @brief  从用户预留的eFuse空间中读取多个字节,进入提供的缓冲区。
49  * @param  [in] offset 待读取的efuse空间在用户预留区域中的起始偏移地址,以字节为单位。
50  * @param  [in] buffer 保存读取数据的缓冲区。
51  * @param  [in] length 数据的长度,以字节为单位。
52  * @retval ERRCODE_SUCC 成功。
53  * @retval Other        失败,参考 @ref errcode_t 。
54  * @endif
55  */
56 errcode_t uapi_efuse_user_read_buffer(uint32_t offset, uint8_t *buffer, uint16_t length);
57 
58 /**
59  * @if Eng
60  * @brief  Writes multiple bytes from the provided buffer to the eFuse space reserved by the user.
61  * @param  [in] offset The start offset address of the eFUSE space to be written in the area reserved for the user.
62            The unit is byte.
63  * @param  [in] buffer A buffer containing the data to be written.
64  * @param  [in] length The length of the data, in bytes.
65  * @retval ERRCODE_SUCC Success.
66  * @retval Other        Failure. For details, see @ref errcode_t.
67  * @else
68  * @brief  从提供的缓冲区向用户预留的eFuse空间写入多个字节。
69  * @param  [in] offset 待写入的efuse空间在用户预留区域中的起始偏移地址,以字节为单位。
70  * @param  [in] buffer 包含要写入的数据的缓冲区。
71  * @param  [in] length 数据的长度,以字节为单位。
72  * @retval ERRCODE_SUCC 成功。
73  * @retval Other        失败,参考 @ref errcode_t 。
74  * @endif
75  */
76 errcode_t uapi_efuse_user_write_buffer(uint32_t offset, const uint8_t *buffer, uint16_t length);
77 
78 #ifdef EFUSE_BIT_OPERATION
79 /**
80  * @if Eng
81  * @brief  Write 1 to the corresponding bit in the eFUSE space reserved for the user.
82  * @param  [in] byte_offset The byte offset address of the bit to be written in the space reserved for the user.
83  * @param  [in] bit_pos The bit position of the bit to be written in the corresponding byte of the user reserved space.
84  * @retval ERRCODE_SUCC Success.
85  * @retval Other        Failure. For details, see @ref errcode_t.
86  * @else
87  * @brief  向用户预留eFuse空间中的对应bit写1。
88  * @param  [in] byte_offset 待写入位在用户预留空间中的字节偏移地址。
89  * @param  [in] bit_pos 待写入位在用户预留空间中对应字节中的bit位置。
90  * @retval ERRCODE_SUCC 成功。
91  * @retval Other        失败,参考 @ref errcode_t 。
92  * @endif
93  */
94 errcode_t uapi_efuse_user_write_bit(uint32_t byte_offset, uint8_t bit_pos);
95 
96 /**
97  * @if Eng
98  * @brief  Read a bit from the eFuse space reserved by the user.
99  * @param  [in] byte_offset The byte offset address of the bit to be read in the space reserved for the user.
100  * @param  [in] bit_pos The bit position of the bit to be read in the corresponding byte of the user reserved space.
101  * @param  [in] value The value of the bit read.
102  * @retval ERRCODE_SUCC Success.
103  * @retval Other        Failure. For details, see @ref errcode_t.
104  * @else
105  * @brief  从用户预留的eFuse空间中读取一位。
106  * @param  [in] byte_offset 待读取位在用户预留空间中的字节偏移地址。
107  * @param  [in] bit_pos 待读取位在用户预留空间中对应字节中的bit位置。
108  * @param  [in] value 读取的位值。
109  * @retval ERRCODE_SUCC 成功。
110  * @retval Other        失败,参考 @ref errcode_t 。
111  * @endif
112  */
113 errcode_t uapi_efuse_user_read_bit(uint32_t byte_offset, uint8_t bit_pos, uint8_t *value);
114 #endif
115 
116 #ifdef __cplusplus
117 #if __cplusplus
118 }
119 #endif /* __cplusplus */
120 #endif /* __cplusplus */
121 
122 #endif
123 
124