• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * @file hi_boot_rom.h
3  *
4  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /** @defgroup iot_romboot BootRom */
19 #ifndef _HI_BOOT_ROM_H_
20 #define _HI_BOOT_ROM_H_
21 #include <hi_types.h>
22 #include <hi_boot_err.h>
23 #include <hi3861_platform.h>
24 #include <boot_rom.h>
25 
26 /** @defgroup iot_reg Registers APIs
27 * @ingroup  iot_romboot
28 */
29 /**
30 * @ingroup iot_reg
31 *
32 */
33 #define hi_reg_write(addr, val)            (*(volatile hi_u32*)(uintptr_t)(addr) = (val))
34 
35 /**
36 * @ingroup iot_reg
37 *
38 */
39 #define hi_reg_read(addr, val)             ((val) = *(volatile hi_u32*)(uintptr_t)(addr))
40 
41 /**
42 * @ingroup iot_reg
43 *
44 */
45 #define hi_reg_write16(addr, val)          (*(volatile hi_u16*)(uintptr_t)(addr) = (val))
46 
47 /**
48 * @ingroup iot_reg
49 *
50 */
51 #define hi_reg_read16(addr, val)           ((val) = *(volatile hi_u16*)(uintptr_t)(addr))
52 
53 /**
54 * @ingroup iot_reg
55 *
56 */
57 #define hi_reg_read_val32(addr)            (*(volatile hi_u32*)(uintptr_t)(addr))
58 
59 /**
60 * @ingroup iot_reg
61 *
62 */
63 #define hi_reg_read_val16(addr)            (*(volatile hi_u16*)(uintptr_t)(addr))
64 
65 /**
66 * @ingroup iot_reg
67 *
68 */
69 #define hi_reg_setbitmsk(addr, msk)        ((hi_reg_read_val32(addr)) |= (msk))
70 
71 /**
72 * @ingroup iot_reg
73 *
74 */
75 #define hi_reg_clrbitmsk(addr, msk)        ((hi_reg_read_val32(addr)) &= ~(msk))
76 
77 /**
78 * @ingroup iot_reg
79 *
80 */
81 #define hi_reg_clrbit(addr, pos)           ((hi_reg_read_val32(addr)) &= ~((hi_u32)(1) << (pos)))
82 
83 /**
84 * @ingroup iot_reg
85 *
86 */
87 #define hi_reg_setbit(addr, pos)           ((hi_reg_read_val32(addr)) |= ((hi_u32)(1) << (pos)))
88 
89 /**
90 * @ingroup iot_reg
91 *
92 */
93 #define hi_reg_clrbits(addr, pos, bits)    (hi_reg_read_val32(addr) &= ~((((hi_u32)1 << (bits)) - 1) << (pos)))
94 
95 /**
96 * @ingroup iot_reg
97 *
98 */
99 #define hi_reg_clrbits16(addr, pos, bits)  (hi_reg_read_val16(addr) &= ~((((unsigned short)1 << (bits)) - 1) << (pos)))
100 
101 /**
102 * @ingroup iot_reg
103 *
104 */
105 #define hi_reg_clrbit16(addr, pos)       ((hi_reg_read_val16(addr)) &= ~((unsigned short)(1) << (pos)))
106 
107 /**
108 * @ingroup iot_reg
109 *
110 */
111 #define hi_reg_setbit16(addr, pos)       ((hi_reg_read_val16(addr)) |= ((unsigned short)(1) << (pos)))
112 
113 /** @defgroup iot_time time APIs
114 * @ingroup iot_romboot
115 */
116 /**
117 * @ingroup  iot_time
118 * @brief  Delay, in microseconds.CNcomment:延时,毫秒级。CNend
119 *
120 * @par 描述:
121 *           Delay operation implemented by software based on the system clock, blocking the CPU.
122 CNcomment:延时操作,阻塞CPU。CNend
123 *
124 * @attention None
125 *
126 * @param  msecs                [IN] type #hi_u32,delay period (unit: millisecond).
127 CNcomment:延时时间(单位:ms)。CNend
128 *
129 * @retval  None
130 * @par 依赖:
131 *            @li hi_boot_rom.h:Describes BootRom APIs.CNcomment:文件包含BootRom相关接口。CNend
132 * @see  None
133 */
134 hi_void mdelay(hi_u32 msecs);
135 
136 /**
137 * @ingroup  iot_time
138 * @brief  Delay, in microseconds.CNcomment:延时,微秒级。CNend
139 *
140 * @par 描述:
141 *           Delay operation implemented by software based on the system clock, blocking the CPU.
142 CNcomment:延时操作,阻塞CPU。CNend
143 *
144 * @attention None
145 *
146 * @param  usecs                [IN] type #hi_u32,delay period (unit: microsecond).
147 CNcomment:延时时间(单位:μs)。CNend
148 *
149 * @retval  None
150 * @par 依赖:
151 *            @li hi_boot_rom.h:Describes BootRom APIs.CNcomment:文件包含BootRom相关接口。CNend
152 * @see  None
153 */
154 hi_void udelay(hi_u32 usecs);
155 
156 extern hi_u32 memcmp(const hi_void *cs, const hi_void *ct, hi_u32 count);
157 
158 /** @defgroup iot_secure_c Secure C library APIs
159 * @ingroup iot_romboot
160 */
161 /**
162 * @ingroup  iot_secure_c
163 * @brief  Sets the size of the destination buffer to a specific value.
164 CNcomment:设置目的缓冲区为特定值。CNend
165 *
166 * @par 描述: Sets the size of the destination buffer to a specific value.
167 CNcomment:设置目的缓冲区为特定值。CNend
168 * @attention None
169 *
170 * @param dest     [IN] type #hi_void *, Destination buffer.CNcomment:目的缓冲区。CNend
171 * @param dest_max [IN] type #hi_u32, Size of the destination buffer.CNcomment:目的缓冲区大小。CNend
172 * @param c        [IN] type #hi_u8, Specific value.CNcomment:特定值。CNend
173 * @param count    [IN] type #hi_u32, Number of specific values set in destination buffer.
174 CNcomment:目的缓冲区设置特定值的个数。CNend
175 * @param  check_sum [IN] type #hi_u32,Exclusive or of the above four parameter values,used as security check.
176 *                 example:check_sum = (uintptr_t)dest ^ (uintptr_t)dest_max ^ (uintptr_t)c ^ (uintptr_t)count.
177 CNcomment:上面4个参数值的异或,用作安全检查,
178 示例:check_sum = (uintptr_t)dest ^ (uintptr_t)dest_max ^ (uintptr_t)c ^ (uintptr_t)count。CNend
179 *
180 * @retval #EOK Success
181 * @retval #Other Failure
182 *
183 * @par 依赖:
184 * @li hi_boot_rom.h: This file declares the APIs.CNcomment:该接口声明所在的头文件。CNend
185 * @see None
186 */
187 hi_u32 memset_s(hi_void *dest, hi_u32 dest_max, hi_u8 c, hi_u32 count, hi_u32 check_sum);
188 
189 /**
190 * @ingroup  iot_secure_c
191 * @brief  Copies the data from the source buffer to the destination buffer.
192 CNcomment:复制源缓冲区的数据到目的缓冲区。CNend
193 *
194 * @par 描述: Copies the data from the source buffer to the destination buffer.
195 CNcomment:复制源缓冲区的数据到目的缓冲区。CNend
196 * @attention None
197 *
198 * @param dest     [IN] type #hi_void *, Destination buffer.CNcomment:目的缓冲区。CNend
199 * @param dest_max [IN] type #hi_u32, Size of the destination buffer.CNcomment:目的缓冲区大小。CNend
200 * @param src      [IN] type #const hi_void *, Source buffer.CNcomment:源缓冲区。CNend
201 * @param count    [IN] type #hi_u32, Number of characters copied from the source buffer.
202 CNcomment:从源缓冲区中复制的字符数。CNend
203 * @param  check_sum [IN] type #hi_u32,Exclusive or of the above four parameter values,used as security check.
204 *               example:check_sum = (uintptr_t)dest ^ (uintptr_t)dest_max ^ (uintptr_t)src ^ (uintptr_t)count.
205 CNcomment:上面4个参数值的异或,用作安全检查,
206 示例:check_sum = (uintptr_t)dest ^ (uintptr_t)dest_max ^ (uintptr_t)src ^ (uintptr_t)count。CNend
207 *
208 * @retval #EOK Success
209 * @retval #Other Failure
210 *
211 * @par 依赖:
212 * @li hi_boot_rom.h: This file declares the APIs.CNcomment:该接口声明所在的头文件。CNend
213 * @see None
214 */
215 hi_u32 memcpy_s(hi_void *dest, hi_u32 dest_max, const hi_void *src, hi_u32 count, hi_u32 check_sum);
216 
217 /** @defgroup iot_dfx Debug APIs
218 * @ingroup iot_romboot
219 */
220 /**
221  * @ingroup iot_dfx
222  *
223  * Print error code type, 0x3615 and its previous value cannot be modified.
224  CNcomment:打印错误码类型,0x3615及之前的值不可修改。CNend
225  */
226 typedef enum {
227     HI_PRINT_ERRNO_UART_INIT = 0x3600,              /* UART authentication initialization failed */
228     HI_PRINT_ERRNO_LOADER_ERR = 0x3601,             /* Failed to load loaderboot */
229     HI_PRINT_ERRNO_BOOT_DECRYPT_ERR = 0x3602,       /* Boot decryption failed */
230     HI_PRINT_ERRNO_BOOT_LEN_ERR = 0x3603,           /* Boot length check failed */
231     HI_PRINT_ERRNO_BOOT_HEAD_ERR = 0x3604,          /* Boot header verification failed */
232     HI_PRINT_ERRNO_BOOT_SECURE_BOOT_ERR = 0x3605,   /* Secure boot read failed */
233     HI_PRINT_ERRNO_BOOT_ROOT_KEY_LEN_ERR = 0x3606,  /* Rootkye length incorrect */
234     HI_PRINT_ERRNO_BOOT_ROOT_KEY_ERR = 0x3607,      /* Rootkey certificate failed */
235     HI_PRINT_ERRNO_BOOT_READ_ENCPT_ERR = 0x3608,    /* Secure flag read failed */
236     HI_PRINT_ERRNO_BOOT_SUB_KEY_LEN_ERR = 0x3609,   /* Subkey length incorrect */
237     HI_PRINT_ERRNO_BOOT_SUB_KEY_CAT_ERR = 0x360A,   /* Subkey category is incorrect */
238     HI_PRINT_ERRNO_BOOT_SUB_KEY_RSIM_ERR = 0x360B,  /* Subkey rsim verification failed */
239     HI_PRINT_ERRNO_BOOT_SUB_KEY_ERR = 0x360C,       /* Subkey authentication failed */
240     HI_PRINT_ERRNO_BOOT_CODE_VERIFY_ERR = 0x360D,   /* Code verification failed */
241     HI_PRINT_ERRNO_BOOT_DIE_ID_ERR = 0x360E,        /* Die ID verification failed */
242     HI_PRINT_ERRNO_BOOT_VER_ERR = 0x360F,           /* Flash boot version number verification failed */
243     HI_PRINT_ERRNO_BOOT_GET_TAIL_ERR = 0x3610,      /* Failed to get flash tail address */
244     HI_PRINT_ERRNO_BOOT_BACKUP_TAIL_ERR = 0x3611,   /* Backup flash boot magic word and length verification failed */
245     HI_PRINT_ERRNO_BOOT_MAIN_CHECK_ERR = 0x3612,    /* Fail to check the integrity of the main flashboot
246                                                        in non-secure boot */
247     HI_PRINT_ERRNO_BOOT_BACKUP_CHECK_ERR = 0x3613,  /* Fail to check the integrity of the backup flashboot
248                                                        in non-secure boot */
249     HI_PRINT_ERRNO_MALLOC_EXAUST_ERR = 0x3614,      /* Out of heap memory */
250     HI_PRINT_ERRNO_MALLOC_STRUCT_ERR = 0x3615,      /* Heap memory management structure destroyed */
251     HI_PRINT_ERRNO_NO_ENCPT_CNT_LEFT_ERR = 0x3616,  /* Flash encryption burn out times */
252     HI_PRINT_ERRNO_CRYPTO_PREPARE_ERR = 0x3617,     /* Flash encryption and decryption preparation failed */
253     HI_PRINT_ERRNO_CRYPTO_KEY_EMPTY_ERR = 0x3618,   /* Flash encryption and decryption work key is empty */
254     HI_PRINT_ERRNO_CRYPTO_KEY_INVALID_ERR = 0x3619, /* Flash encryption and decryption work key is invalid */
255     HI_PRINT_ERRNO_CRYPTO_KEY_SAVE_ERR = 0x361A,    /* Flash encryption and decryption work key save failed */
256     HI_PRINT_ERRNO_CRYPTO_KEY_DECRYPT_ERR = 0x361B, /* Flash encryption and decryption work key decryption failed */
257     HI_PRINT_ERRNO_CRYPTO_FW_DECRYPT_ERR = 0x361C,  /* Flash encryption and decryption kernel encryption failed */
258     HI_PRINT_ERRNO_CRYPTO_FW_ENCRYPT_ERR = 0x361D,  /* Flash encryption and decryption kernel decryption failed */
259     HI_PRINT_ERRNO_CRYPTO_NV_ENCRYPT_ERR = 0x361E,  /* Flash encryption and decryption NV area encryption failed */
260     HI_PRINT_ERRNO_CRYPTO_CHECK_KERNEL_ERR = 0x361F,  /* Flash encryption and decryption check kernel failed */
261     HI_PRINT_ERRNO_CRYPTO_KERNEL_ADDR_ERR = 0x3620, /* Flash encryption and decryption check kernel addr failed */
262     HI_PRINT_ERRNO_UPG_CRYPTO_PREPARE_ERR = 0x3621, /* Upg file decryption preparation failed */
263     HI_PRINT_ERRNO_UPG_CRYPTO_DECRYPT_ERR = 0x3622, /* Upg file decryption failed */
264     HI_PRINT_ERRNO_CRYPTO_SALT_EMPTY_ERR = 0x3623,  /* Flash encryption and decryption root key salt is empty */
265     HI_PRINT_ERRNO_IDX_MAX,                         /* Error code type maximum */
266 } hi_print_errno;
267 
268 /**
269 * @ingroup  iot_dfx
270 * @brief  The error code is forced to be printed out in romboot. The hi_print_errno definition cannot be modified.
271 CNcomment:romboot中强制打印输出错误码,不可修改hi_print_errno定义。CNend
272 *
273 * @par 描述:
274 *           Force to print out error codes to help users locate errors.
275 CNcomment:强制打印输出错误码,帮助用户定位错误。CNend
276 *
277 * @attention None.
278 *
279 * @param  print_errno [IN] type #hi_u32, error code.
280 *
281 * @retval None.
282 * @par 依赖:
283 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
284 * @see  boot_puthex|boot_msg0|boot_msg1|boot_msg2|boot_msg4.
285 */
286 hi_void boot_put_errno(hi_u32 print_errno);
287 
288 /**
289 * @ingroup  iot_dfx
290 * @brief  Output hexadecimal number.CNcomment:输出16进制数。CNend
291 *
292 * @par 描述:
293 *           Output hexadecimal number.CNcomment:输出16进制数。CNend
294 *
295 * @attention None.
296 *
297 * @param  h [IN] type #hi_u32,  Hexadecimal number to output.
298 * @param  print0 [IN] type #hi_bool, HI_TRUE: fill 0 to 4 bytes when printing. HI_FALSE: do not fill 0 alignment.
299 *
300 * @retval None.
301 * @par 依赖:
302 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
303 * @see  boot_put_errno|boot_msg0|boot_msg1|boot_msg2|boot_msg4.
304 */
305 hi_void boot_puthex(hi_u32 h, hi_bool print0);
306 
307 /**
308 * @ingroup  iot_dfx
309 * @brief  Printout information, string only.CNcomment:打印输出信息,只输出字符串。CNend
310 *
311 * @par 描述:
312 *           Printout information, string only.CNcomment:打印输出信息,只输出字符串。CNend
313 *
314 * @attention None.
315 *
316 * @param  s [IN] type #hi_char*,  String to output.
317 *
318 * @retval None.
319 * @par 依赖:
320 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
321 * @see  boot_put_errno|boot_puthex|boot_msg1|boot_msg2|boot_msg4.
322 */
323 hi_void boot_msg0(const hi_char *s);
324 
325 /**
326 * @ingroup  iot_dfx
327 * @brief  Print out information, output string and 1 values.CNcomment:打印输出信息,输出字符串及1个数值。CNend
328 *
329 * @par 描述:
330 *           Print out information, output string and 1 values.CNcomment:打印输出信息,输出字符串及1个数值。CNend
331 *
332 * @attention None.
333 *
334 * @param  s [IN] type #hi_char*,  String to output.
335 * @param  h [IN] type #hi_u32,  Value to be output, hexadecimal.
336 *
337 * @retval None.
338 * @par 依赖:
339 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
340 * @see  boot_put_errno|boot_puthex|boot_msg0|boot_msg2|boot_msg4.
341 */
342 hi_void boot_msg1(const hi_char *s, hi_u32 h);
343 
344 /**
345 * @ingroup  iot_dfx
346 * @brief  Print out information, output string and 2 values.CNcomment:打印输出信息,输出字符串及2个数值。CNend
347 *
348 * @par 描述:
349 *           Print out information, output string and 2 values.CNcomment:打印输出信息,输出字符串及2个数值。CNend
350 *
351 * @attention None.
352 *
353 * @param  s [IN] type #hi_char*,  String to output.
354 * @param  h1 [IN] type #hi_u32,  Value to be output 1, hexadecimal.
355 * @param  h2 [IN] type #hi_u32,  Value to be output 2, hexadecimal.
356 *
357 * @retval None.
358 * @par 依赖:
359 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
360 * @see  boot_put_errno|boot_puthex|boot_msg0|boot_msg1|boot_msg4.
361 */
362 hi_void boot_msg2(const hi_char *s, hi_u32 h1, hi_u32 h2);
363 
364 /**
365 * @ingroup  iot_dfx
366 * @brief  Print out information, output string and 4 values.CNcomment:打印输出信息,输出字符串及4个数值。CNend
367 *
368 * @par 描述:
369 *           Print out information, output string and 4 values.CNcomment:打印输出信息,输出字符串及4个数值。CNend
370 *
371 * @attention None.
372 *
373 * @param  s [IN] type #hi_char*,  String to output.
374 * @param  h1 [IN] type #hi_u32,  Value to be output 1, hexadecimal.
375 * @param  h2 [IN] type #hi_u32,  Value to be output 2, hexadecimal.
376 * @param  h3 [IN] type #hi_u32,  Value to be output 3, hexadecimal.
377 * @param  h4 [IN] type #hi_u32,  Value to be output 4, hexadecimal.
378 *
379 * @retval None.
380 * @par 依赖:
381 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
382 * @see  boot_put_errno|boot_puthex|boot_msg0|boot_msg1|boot_msg2.
383 */
384 hi_void boot_msg4(const hi_char *s, hi_u32 h1, hi_u32 h2, hi_u32 h3, hi_u32 h4);
385 
386 /** @defgroup iot_uart Uart APIs
387 * @ingroup iot_romboot
388 */
389 /**
390  * @ingroup iot_uart
391  *
392  * Uart ID. CNcomment:串口号。CNend
393  */
394 typedef enum {
395     UART0 = 0,    /* uart0 */
396     UART1 = 1,    /* uart1 */
397     UART2 = 2,    /* uart2 */
398     UART_MAX = 3,
399 } hi_uart;
400 
401 /**
402  * @ingroup iot_uart
403  *
404  * Uart parameter struct. CNcomment:串口参数结构体。CNend
405  */
406 typedef struct {
407     hi_u32 baudrate;          /* Baud rate */
408     hi_uchar databit;         /* 5; 6; 7; 8 */
409     hi_uchar stopbit;         /* 1:stop_bit 1;  2: stop_bit 2. */
410     hi_uchar parity;          /* 0: None; 1:Odd; 2:Even */
411     hi_uchar flow_ctrl;       /* 0: None; 1:rts&&cts. 2:only rts; 3:only cts */
412     hi_uchar fifoline_tx_int; /* 0:tx FIFO≤1/8full; 1:tx FIFO≤1/4full; 2:tx FIFO≤1/2full;
413                                  3:tx FIFO≤3/4full; 4:tx FIFO≤7/8full */
414     hi_uchar fifoline_rx_int; /* 0:rx FIFO≥1/8full; 1:rx FIFO≥1/4full; 2:rx FIFO≥1/2full;
415                                  3:rx FIFO≥3/4full; 4:rx FIFO≥7/8full */
416     hi_uchar fifoline_rts;    /* 0:rx FIFO≥1/8full; 1:rx FIFO≥1/4full; 2:rx FIFO≥1/2full;
417                                  3:rx FIFO≥3/4full; 4:rx FIFO≥7/8full */
418     hi_uchar pad;
419 } uart_param_stru;
420 
421 /**
422 * @ingroup  iot_uart
423 * @brief  Serial output forbidden.CNcomment:串口输出禁言。CNend
424 *
425 * @par 描述:
426 *           Serial output forbidden.CNcomment:串口输出禁言。CNend
427 *
428 * @attention None.
429 *
430 * @param  None.
431 *
432 * @retval None.
433 * @par 依赖:
434 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
435 * @see  serial_cancel_mute.
436 */
437 hi_void serial_set_mute(hi_void);
438 
439 /**
440 * @ingroup  iot_uart
441 * @brief  Cancel serial output forbidden.CNcomment:串口输出取消禁言。CNend
442 *
443 * @par 描述:
444 *           Cancel serial output forbidden.CNcomment:串口输出取消禁言。CNend
445 *
446 * @attention None.
447 *
448 * @param  None.
449 *
450 * @retval None.
451 * @par 依赖:
452 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
453 * @see  serial_set_mute.
454 */
455 hi_void serial_cancel_mute(hi_void);
456 
457 /**
458 * @ingroup  iot_uart
459 * @brief  Serial port initialization.CNcomment:串口初始化。CNend
460 *
461 * @par 描述:
462 *           Serial port initialization.CNcomment:串口初始化。CNend
463 *
464 * @attention None.
465 *
466 * @param  uart_num [IN] type #hi_uart, Uart ID.
467 * @param  default_uart_param [IN] type #uart_param_stru, Uart parameters.
468 *
469 * @retval #HI_ERR_FAILURE Failure.
470 * @retval #HI_ERR_SUCCESS Success.
471 * @par 依赖:
472 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
473 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
474 */
475 hi_u32 serial_init(hi_uart uart_num, uart_param_stru default_uart_param);
476 
477 /**
478 * @ingroup  iot_uart
479 * @brief  Serial output single character.CNcomment:串口输出单个字符。CNend
480 *
481 * @par 描述:
482 *           Serial output single character.CNcomment:串口输出单个字符。CNend
483 *
484 * @attention None.
485 *
486 * @param  c [IN] type #const hi_char, Char to output.
487 *
488 * @retval None.
489 * @par 依赖:
490 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
491 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
492 */
493 hi_void serial_putc(const hi_char c);
494 
495 /**
496 * @ingroup  iot_uart
497 * @brief  Serial output string.CNcomment:串口输出字符串。CNend
498 *
499 * @par 描述:
500 *           Serial output string.CNcomment:串口输出字符串。CNend
501 *
502 * @attention None.
503 *
504 * @param  s [IN] type #const hi_char*, String to output.
505 *
506 * @retval None.
507 * @par 依赖:
508 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
509 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
510 */
511 hi_void serial_puts(const hi_char *s);
512 
513 /**
514 * @ingroup  iot_uart
515 * @brief  Serial output character buffer, specify buffer length.CNcomment:串口输出字符缓冲区,指定缓冲区长度。CNend
516 *
517 * @par 描述:
518 *           Serial output character buffer, specify buffer length.CNcomment:串口输出字符缓冲区,指定缓冲区长度。CNend
519 *
520 * @attention The difference between the serial_puts() function is that the serial_puts function is for strings and
521 *            stops the output when '\ 0' is encountered. However, this interface is not affected by '\ 0' for a
522 *            specified length of character buffer.CNcomment:与serial_puts()函数的区别是:serial_puts函数是针对字符串,
523 *            遇到'\0'后停止输出;而本接口针对指定长度的字符缓冲区,不受'\0'影响。CNend
524 * @param  buffer [IN] type #const hi_char*,  String to output.
525 * @param  length [IN] type #hi_s32,          Length of string to be output.
526 *
527 * @retval None.
528 * @par 依赖:
529 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
530 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
531 */
532 hi_void serial_put_buf(const hi_char *buffer, hi_s32 length);
533 
534 /**
535 * @ingroup  iot_uart
536 * @brief  Read a character from the serial port.CNcomment:从串口读取一个字符。CNend
537 *
538 * @par 描述:
539 *           Read a character from the serial port.CNcomment:从串口读取一个字符。CNend
540 *
541 * @attention This function is a blocking interface. If the serial port does not receive characters, it will wait.
542 CNcomment:本函数为阻塞接口,如果串口没有接收到字符,会一直等待。CNend
543 * @param  None.
544 *
545 * @retval #Character    Characters read from serial port.
546 * @retval #-1           Failure.
547 * @par 依赖:
548 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
549 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
550 */
551 hi_u8 serial_getc(hi_void);
552 
553 /**
554 * @ingroup  iot_uart
555 * @brief  Whether the serial port has characters to be received.CNcomment:串口是否有字符待接收。CNend
556 *
557 * @par 描述:
558 *           Whether the serial port has characters to be received.CNcomment:串口是否有字符待接收。CNend
559 *
560 * @attention None.
561 * @param  None.
562 *
563 * @retval #0     Not received date from serial port.
564 * @retval #1     Received date from serial port.
565 * @par 依赖:
566 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
567 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
568 */
569 hi_s32 serial_tstc(hi_void);
570 
571 /**
572 * @ingroup  iot_uart
573 * @brief  Output hexadecimal number to serial port.CNcomment:向串口输出16进制数。CNend
574 *
575 * @par 描述:
576 *           向串口输出16进制数.CNcomment:向串口输出16进制数。CNend
577 *
578 * @attention None.
579 * @param  h         [IN] type #hi_u32,Hexadecimal number to be output.CNcomment:待输出的16进制数。CNend
580 * @param  print_all [IN] type #hi_u8 *,Whether to fill in 0, Align according to 4 bytes. 1 : fill, 0 : not to fill.
581 CNcomment:打印时前面是否补0,按照4字节对齐,1表示补,0表示不补。CNend
582 *
583 * @retval None.
584 * @par 依赖:
585 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
586 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
587 */
588 hi_void serial_puthex(hi_u32 h, hi_bool print_all);
589 
590 /**
591 * @ingroup  iot_uart
592 * @brief  Read a character from the serial port, and end if it is not read after waiting for the specified time.
593 CNcomment:从串口读取一个字符,等待指定时间后没有读到则结束。CNend
594 *
595 * @par 描述:
596 *           Read a character from the serial port, and end if it is not read after waiting for the specified time.
597 CNcomment:从串口读取一个字符,等待指定时间后没有读到则结束。CNend
598 *
599 * @attention None.
600 * @param  timeout_us    [IN] type #hi_u32,Specify timeout in us.CNcomment:指定超时时间,单位:us。CNend
601 * @param  ch            [IN] type #hi_u8 *,Output character.CNcomment:输出字符。CNend
602 *
603 * @retval #HI_ERR_FAILURE Failure.
604 * @retval #HI_ERR_SUCCESS Success.
605 * @par 依赖:
606 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
607 * @see  serial_init|serial_putc|serial_puts|serial_put_buf|serial_getc|serial_tstc|serial_puthex。
608 */
609 hi_u32 serial_getc_timeout(hi_u32 timeout_us, hi_u8 *ch);
610 
611 /** @defgroup iot_mem Memory APIs
612 * @ingroup iot_romboot
613 */
614 /**
615 * @ingroup  iot_mem
616 *
617 * Dynamic memory management module initialization interface function pointer.
618 CNcomment:动态内存管理模块初始化接口函数指针。CNend
619 */
620 typedef hi_void (*malloc_init_func)(hi_u32 heap_start_addr, hi_u32 heap_end_addr, hi_u32 check_sum);
621 
622 /**
623 * @ingroup  iot_mem
624 *
625 * Request dynamic memory interface function pointer.CNcomment:申请动态内存接口函数指针。CNend
626 */
627 typedef hi_void *(*malloc_func)(hi_u32 size);
628 
629 /**
630 * @ingroup  iot_mem
631 *
632 * Release dynamic memory interface function pointer.CNcomment:释放动态内存接口函数指针。CNend
633 */
634 typedef hi_u32 (*free_func)(hi_void *addr);
635 
636 /**
637 * @ingroup  iot_mem
638 *
639 * Input parameter of hi_register_malloc interface.
640 */
641 typedef struct {
642     malloc_init_func init;   /* Initialize heap memory interface */
643     malloc_func boot_malloc; /* Request heap memory interface */
644     free_func boot_free;     /* Release heap memory interface */
645 } hi_malloc_func;
646 
647 /**
648 * @ingroup  iot_mem
649 * @brief  To register malloc management related functions, be sure to register before using other interfaces.
650 CNcomment:注册malloc管理相关函数,务必先注册再使用其他接口。CNend
651 *
652 * @par 描述:
653 *           Support users to adapt memory management functions.CNcomment:支持用户自己适配内存管理函数。CNend
654 *
655 * @attention None.
656 * @param  addr      [IN] type #uintptr_t,Heap start address.CNcomment:堆空间起始地址。CNend
657 * @param  funcs     [IN] type #const hi_malloc_func *,Request memory related interface register structure pointer.
658 CNcomment:申请内存相关接口注册结构体指针。CNend
659 *
660 * @retval #HI_ERR_FAILURE Failure.
661 * @retval #HI_ERR_SUCCESS Success.
662 * @par 依赖:
663 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
664 * @see  boot_malloc_init|boot_malloc|boot_free。
665 */
666 hi_u32 hi_register_malloc(uintptr_t addr, const hi_malloc_func *funcs);
667 
668 /**
669 * @ingroup  iot_mem
670 * @brief  Heap initialize.CNcomment:堆空间初始化。CNend
671 *
672 * @par 描述:
673 *           Heap initialize.CNcomment:堆空间初始化。CNend
674 *
675 * @attention None.
676 * @param  heap_start_addr    [IN] type #uintptr_t,Heap start address.CNcomment:堆空间起始地址。CNend
677 * @param  heap_end_addr      [IN] type #uintptr_t,Heap end address.CNcomment:堆空间结束地址。CNend
678 * @param  check_sum          [IN] type #hi_u32,Exclusive or of start address and end address.
679 CNcomment:起始地址与结束地址的异或。CNend
680 *
681 * @retval #HI_ERR_FAILURE Failure.
682 * @retval #HI_ERR_SUCCESS Success.
683 * @par 依赖:
684 *            @li hi_boot_rom.h:Describes Boot APIs.CNcomment:文件用于描述Boot模块接口。CNend
685 * @see  boot_malloc_init。
686 */
687 hi_void boot_malloc_init(uintptr_t heap_start_addr, uintptr_t heap_end_addr, hi_u32 check_sum);
688 
689 /**
690 * @ingroup  iot_mem
691 * @brief  Dynamically applies for memory.CNcomment:动态申请内存。CNend
692 *
693 * @par 描述:
694 *           Dynamically applies for memory.CNcomment:动态申请内存。CNend
695 *
696 * @attention None.
697 * @param  size    [IN] type #hi_u32,Requested memory size (unit: byte)
698 CNcomment:申请内存大小(单位:byte)。CNend
699 *
700 * @retval #Other    Success
701 * @retval #HI_NULL  Failure. The memory is insufficient.
702 * @par 依赖:
703 *            @li hi_boot_rom.h:Describes memory APIs.CNcomment:文件用于描述内存相关接口。CNend
704 * @see  boot_free。
705 */
706 hi_void *boot_malloc(hi_u32 size);
707 
708 /**
709 * @ingroup  iot_mem
710 * @brief  Releases the memory that is dynamically applied for.CNcomment:释放动态申请的内存。CNend
711 *
712 * @par 描述:
713 *          Releases the memory that is dynamically applied for.CNcomment:释放动态申请的内存。CNend
714 *
715 * @attention None.
716 * @param  addr    [IN] type #hi_void *,Start address of the requested memory. The validity of the address is ensured
717 *                 by the caller.CNcomment:所申请内存的首地址,地址合法性由调用者保证。CNend
718 *
719 * @retval None.
720 * @par 依赖:
721 *            @li hi_boot_rom.h:Describes memory APIs.CNcomment:文件用于描述内存相关接口。CNend
722 * @see  boot_malloc。
723 */
724 hi_u32 boot_free(hi_void *addr);
725 
726 /** @defgroup iot_watchdog Watchdog APIs
727  * @ingroup iot_romboot
728  */
729 /**
730  * @ingroup iot_watchdog
731  * The default watchdog configuration time is 26 seconds. The time cannot be modified after romboot is started,
732    users can call hi_watchdog_enable interface to reconfigure in flashboot.CNcomment:默认看门狗配置时间为26秒。
733    romboot启动后时间不可以修改,用户可以在flashboot中调用hi_watchdog_enable接口重新配置。CNend
734  */
735 #define WDG_TIME_US 26000000 /* 默认看门狗配置时间为26秒 */
736 
737 /**
738 * @ingroup  iot_watchdog
739 * @brief Enables the watchdog.CNcomment:使能看门狗。CNend
740 *
741 * @par 描述:
742 *          Enables the watchdog.CNcomment:使能看门狗。CNend
743 *
744 * @attention None
745 * @param  None
746 *
747 * @retval None
748 * @par 依赖:
749 *            @li hi_boot_rom.h:describes the watchdog APIs.CNcomment:文件用于描述看门狗相关接口。CNend
750 * @see None
751 */
752 hi_void hi_watchdog_enable(hi_u32 over_time_us);
753 
754 /**
755 * @ingroup  iot_watchdog
756 * @brief Feeds the watchdog.CNcomment:喂狗。CNend
757 *
758 * @par 描述: Feeds the watchdog.CNcomment:喂狗。CNend
759 *
760 * @attention None
761 * @param  None
762 *
763 * @retval None
764 * @par 依赖:
765 *            @li hi_boot_rom.h:describes the watchdog APIs.CNcomment:文件用于描述看门狗相关接口。CNend
766 * @see None
767 */
768 hi_void hi_watchdog_feed(hi_void);
769 
770 /**
771 * @ingroup  iot_watchdog
772 * @brief Disables the watchdog.CNcomment:关闭看门狗。CNend
773 *
774 * @par 描述:
775 *           @li Disable the clock enable control of the watchdog.CNcomment:禁止WatchDog时钟使能控制位。CNend
776 *           @li Mask the watchdog reset function.CNcomment:屏蔽WatchDog复位功能。CNend
777 *
778 * @attention None
779 * @param  None
780 *
781 * @retval None
782 * @par 依赖:
783 *            @li hi_boot_rom.h:describes the watchdog APIs.CNcomment:文件用于描述看门狗相关接口。CNend
784 * @see None
785 */
786 hi_void hi_watchdog_disable(hi_void);
787 
788 /** @defgroup iot_crc16 CRC16 APIs
789 * @ingroup iot_romboot
790 */
791 /**
792 * @ingroup  iot_crc16
793 * @brief  Generates a 16-bit CRC value.CNcomment:生成16位CRC校验值。CNend
794 *
795 * @par 描述:
796 *           Generates a 16-bit CRC value.CNcomment:生成16位CRC校验值。CNend
797 *
798 * @attention None
799 * @param  crc_start         [IN] type #hi_u16,The CRC initial value.CNcomment:CRC初始值。CNend
800 * @param  buf               [IN] type #hi_u8*,Pointer to the buffer to be verified.
801 CNcomment:被校验Buffer指针。CNend
802 * @param  len               [IN] type #hi_u32,Length of the buffer to be verified (unit: Byte).
803 CNcomment:被校验Buffer长度(单位:byte)。CNend
804 *
805 * @retval #HI_ERR_SUCCESS   Success
806 * @retval #Other            Failure. For details, see hi_boot_err.h.
807 *
808 * @par 依赖:
809 *            @li hi_boot_rom.h:Describes CRC APIs.CNcomment:文件包含CRC校验接口。CNend
810 * @see  None
811 */
812 hi_u16 hi_crc16(hi_u16 crc_start, hi_u8 *buf, hi_u32 len);
813 
814 /** @defgroup iot_io IO APIs
815  * @ingroup iot_romboot
816  */
817 /**
818 * @ingroup iot_io
819 *
820 * GPIO ID.
821 */
822 typedef enum {
823     HI_GPIO_IDX_0,   /* GPIO0 */
824     HI_GPIO_IDX_1,   /* GPIO1 */
825     HI_GPIO_IDX_2,   /* GPIO2 */
826     HI_GPIO_IDX_3,   /* GPIO3 */
827     HI_GPIO_IDX_4,   /* GPIO4 */
828     HI_GPIO_IDX_5,   /* GPIO5 */
829     HI_GPIO_IDX_6,   /* GPIO6 */
830     HI_GPIO_IDX_7,   /* GPIO7 */
831     HI_GPIO_IDX_8,   /* GPIO8 */
832     HI_GPIO_IDX_9,   /* GPIO9 */
833     HI_GPIO_IDX_10,  /* GPIO10 */
834     HI_GPIO_IDX_11,  /* GPIO11 */
835     HI_GPIO_IDX_12,  /* GPIO12 */
836     HI_GPIO_IDX_13,  /* GPIO13 */
837     HI_GPIO_IDX_14,  /* GPIO14 */
838     HI_GPIO_IDX_MAX, /* Maximum value, cannot be used. CNcomment:最大值,不可输入使用。CNend */
839 } hi_gpio_idx;
840 
841 /**
842  * @ingroup iot_io
843  *
844  * GPIO pin ID. CNcomment:IO硬件管脚编号。CNend
845  */
846 typedef enum {
847     HI_IO_NAME_GPIO_0,  /* GPIO0 */
848     HI_IO_NAME_GPIO_1,  /* GPIO1 */
849     HI_IO_NAME_GPIO_2,  /* GPIO2 */
850     HI_IO_NAME_GPIO_3,  /* GPIO3 */
851     HI_IO_NAME_GPIO_4,  /* GPIO4 */
852     HI_IO_NAME_GPIO_5,  /* GPIO5 */
853     HI_IO_NAME_GPIO_6,  /* GPIO6 */
854     HI_IO_NAME_GPIO_7,  /* GPIO7 */
855     HI_IO_NAME_GPIO_8,  /* GPIO8 */
856     HI_IO_NAME_GPIO_9,  /* GPIO9 */
857     HI_IO_NAME_GPIO_10, /* GPIO10 */
858     HI_IO_NAME_GPIO_11, /* GPIO11 */
859     HI_IO_NAME_GPIO_12, /* GPIO12 */
860     HI_IO_NAME_GPIO_13, /* GPIO13 */
861     HI_IO_NAME_GPIO_14, /* GPIO14 */
862     HI_IO_NAME_SFC_CSN, /* SFC_CSN */
863     HI_IO_NAME_SFC_IO1, /* SFC_IO1 */
864     HI_IO_NAME_SFC_IO2, /* SFC_IO2 */
865     HI_IO_NAME_SFC_IO0, /* SFC_IO0 */
866     HI_IO_NAME_SFC_CLK, /* SFC_CLK */
867     HI_IO_NAME_SFC_IO3, /* SFC_IO3 */
868     HI_IO_NAME_MAX,
869 } hi_io_name;
870 
871 /**
872  * @ingroup iot_io
873  *
874  * GPIO pull-up configuration.CNcomment:IO上下拉功能CNend
875  */
876 typedef enum {
877     HI_IO_PULL_NONE,    /*  No pull. CNcomment:无拉。CNend */
878     HI_IO_PULL_UP,      /*  pull up. CNcomment:上拉。CNend */
879     HI_IO_PULL_DOWN,    /*  pull down. CNcomment:下拉。CNend */
880     HI_IO_PULL_MAX,     /*  Invalid value. CNcomment:无效值。CNend */
881 } hi_io_pull;
882 
883 /**
884  * @ingroup iot_io
885  *
886  * GPIO_0 pin function.CNcomment:GPIO_0管脚功能。CNend
887  */
888 typedef enum {
889     HI_IO_FUNC_GPIO_0_GPIO,
890     HI_IO_FUNC_GPIO_0_UART1_TXD = 2,
891     HI_IO_FUNC_GPIO_0_SPI0_CK,
892     HI_IO_FUNC_GPIO_0_JTAG_TDO,
893     HI_IO_FUNC_GPIO_0_PWM3_OUT,
894     HI_IO_FUNC_GPIO_0_I2C1_SDA,
895 } hi_io_func_gpio_0;
896 
897 /**
898 * @ingroup iot_io
899 *
900 * GPIO_1 pin function.CNcomment:GPIO_1管脚功能。CNend
901 */
902 typedef enum {
903     HI_IO_FUNC_GPIO_1_GPIO,
904     HI_IO_FUNC_GPIO_1_UART1_RXD = 2,
905     HI_IO_FUNC_GPIO_1_SPI0_RXD,
906     HI_IO_FUNC_GPIO_1_JTAG_TCK,
907     HI_IO_FUNC_GPIO_1_PWM4_OUT,
908     HI_IO_FUNC_GPIO_1_I2C1_SCL,
909     HI_IO_FUNC_GPIO_1_BT_FREQ,
910 } hi_io_func_gpio_1;
911 
912 /**
913 * @ingroup iot_io
914 *
915 * GPIO_2 pin function.CNcomment:GPIO_2管脚功能。CNend
916 */
917 typedef enum {
918     HI_IO_FUNC_GPIO_2_GPIO,
919     HI_IO_FUNC_GPIO_2_UART1_RTS_N = 2,
920     HI_IO_FUNC_GPIO_2_SPI0_TXD,
921     HI_IO_FUNC_GPIO_2_JTAG_TRSTN,
922     HI_IO_FUNC_GPIO_2_PWM2_OUT,
923     HI_IO_FUNC_GPIO_2_SSI_CLK = 7,
924 } hi_io_func_gpio_2;
925 
926 /**
927 * @ingroup iot_io
928 *
929 * GPIO_3 pin function.CNcomment:GPIO_3管脚功能。CNend
930 */
931 typedef enum {
932     HI_IO_FUNC_GPIO_3_GPIO,
933     HI_IO_FUNC_GPIO_3_UART0_TXD,
934     HI_IO_FUNC_GPIO_3_UART1_CTS_N,
935     HI_IO_FUNC_GPIO_3_SPI0_CSN,
936     HI_IO_FUNC_GPIO_3_JTAG_TDI,
937     HI_IO_FUNC_GPIO_3_PWM5_OUT,
938     HI_IO_FUNC_GPIO_3_I2C1_SDA,
939     HI_IO_FUNC_GPIO_3_SSI_DATA,
940 } hi_io_func_gpio_3;
941 
942 /**
943 * @ingroup iot_io
944 *
945 * GPIO_4 pin function.CNcomment:GPIO_4管脚功能。CNend
946 */
947 typedef enum {
948     HI_IO_FUNC_GPIO_4_GPIO,
949     HI_IO_FUNC_GPIO_4_UART0_RXD = 2,
950     HI_IO_FUNC_GPIO_4_JTAG_TMS = 4,
951     HI_IO_FUNC_GPIO_4_PWM1_OUT,
952     HI_IO_FUNC_GPIO_4_I2C1_SCL,
953 } hi_io_func_gpio_4;
954 
955 /**
956 * @ingroup iot_io
957 *
958 * GPIO_5 pin function.CNcomment:GPIO_5管脚功能。CNend
959 */
960 typedef enum {
961     HI_IO_FUNC_GPIO_5_GPIO,
962     HI_IO_FUNC_GPIO_5_UART1_RXD = 2,
963     HI_IO_FUNC_GPIO_5_SPI0_CSN,
964     HI_IO_FUNC_GPIO_5_PWM2_OUT = 5,
965     HI_IO_FUNC_GPIO_5_I2S0_MCLK,
966     HI_IO_FUNC_GPIO_5_BT_STATUS,
967 } hi_io_func_gpio_5;
968 
969 /**
970 * @ingroup iot_io
971 *
972 * GPIO_6 pin function.CNcomment:GPIO_6管脚功能。CNend
973 */
974 typedef enum {
975     HI_IO_FUNC_GPIO_6_GPIO,
976     HI_IO_FUNC_GPIO_6_UART1_TXD = 2,
977     HI_IO_FUNC_GPIO_6_SPI0_CK,
978     HI_IO_FUNC_GPIO_6_PWM3_OUT = 5,
979     HI_IO_FUNC_GPIO_6_I2S0_TX,
980     HI_IO_FUNC_GPIO_6_COEX_SWITCH,
981 } hi_io_func_gpio_6;
982 
983 /**
984 * @ingroup iot_io
985 *
986 * GPIO_7 pin function.CNcomment:GPIO_7管脚功能。CNend
987 */
988 typedef enum {
989     HI_IO_FUNC_GPIO_7_GPIO,
990     HI_IO_FUNC_GPIO_7_UART1_CTS_N = 2,
991     HI_IO_FUNC_GPIO_7_SPI0_RXD,
992     HI_IO_FUNC_GPIO_7_PWM0_OUT = 5,
993     HI_IO_FUNC_GPIO_7_I2S0_BCLK,
994     HI_IO_FUNC_GPIO_7_BT_ACTIVE,
995 } hi_io_func_gpio_7;
996 
997 /**
998 * @ingroup iot_io
999 *
1000 * GPIO_8 pin function.CNcomment:GPIO_8管脚功能。CNend
1001 */
1002 typedef enum {
1003     HI_IO_FUNC_GPIO_8_GPIO,
1004     HI_IO_FUNC_GPIO_8_UART1_RTS_N = 2,
1005     HI_IO_FUNC_GPIO_8_SPI0_TXD,
1006     HI_IO_FUNC_GPIO_8_PWM1_OUT = 5,
1007     HI_IO_FUNC_GPIO_8_I2S0_WS,
1008     HI_IO_FUNC_GPIO_8_WLAN_ACTIVE,
1009 } hi_io_func_gpio_8;
1010 
1011 /**
1012 * @ingroup iot_io
1013 *
1014 * GPIO_9 pin function.CNcomment:GPIO_9管脚功能。CNend
1015 */
1016 typedef enum {
1017     HI_IO_FUNC_GPIO_9_GPIO,
1018     HI_IO_FUNC_GPIO_9_I2C0_SCL,
1019     HI_IO_FUNC_GPIO_9_UART2_RTS_N,
1020     HI_IO_FUNC_GPIO_9_SDIO_D2,
1021     HI_IO_FUNC_GPIO_9_SPI1_TXD,
1022     HI_IO_FUNC_GPIO_9_PWM0_OUT,
1023     HI_IO_FUNC_GPIO_9_I2S0_MCLK = 7,
1024 } hi_io_func_gpio_9;
1025 
1026 /**
1027 * @ingroup iot_io
1028 *
1029 * GPIO_10 pin function.CNcomment:GPIO_10管脚功能。CNend
1030 */
1031 typedef enum {
1032     HI_IO_FUNC_GPIO_10_GPIO,
1033     HI_IO_FUNC_GPIO_10_I2C0_SDA,
1034     HI_IO_FUNC_GPIO_10_UART2_CTS_N,
1035     HI_IO_FUNC_GPIO_10_SDIO_D3,
1036     HI_IO_FUNC_GPIO_10_SPI1_CK,
1037     HI_IO_FUNC_GPIO_10_PWM1_OUT,
1038     HI_IO_FUNC_GPIO_10_I2S0_TX = 7,
1039 } hi_io_func_gpio_10;
1040 
1041 /**
1042 * @ingroup iot_io
1043 *
1044 * GPIO_11 pin function.CNcomment:GPIO_11管脚功能。CNend
1045 */
1046 typedef enum {
1047     HI_IO_FUNC_GPIO_11_GPIO,
1048     HI_IO_FUNC_GPIO_11_UART2_TXD = 2,
1049     HI_IO_FUNC_GPIO_11_SDIO_CMD,
1050     HI_IO_FUNC_GPIO_11_SPI1_RXD,
1051     HI_IO_FUNC_GPIO_11_PWM2_OUT,
1052     HI_IO_FUNC_GPIO_11_RF_TX_EN_EXT,
1053     HI_IO_FUNC_GPIO_11_I2S0_RX,
1054 } hi_io_func_gpio_11;
1055 
1056 /**
1057 * @ingroup iot_io
1058 *
1059 * GPIO_12 pin function.CNcomment:GPIO_12管脚功能。CNend
1060 */
1061 typedef enum {
1062     HI_IO_FUNC_GPIO_12_GPIO,
1063     HI_IO_FUNC_GPIO_12_UART2_RXD = 2,
1064     HI_IO_FUNC_GPIO_12_SDIO_CLK,
1065     HI_IO_FUNC_GPIO_12_SPI1_CSN,
1066     HI_IO_FUNC_GPIO_12_PWM3_OUT,
1067     HI_IO_FUNC_GPIO_12_RF_RX_EN_EXT,
1068     HI_IO_FUNC_GPIO_12_I2S0_BCLK,
1069 } hi_io_func_gpio_12;
1070 
1071 /**
1072 * @ingroup iot_io
1073 *
1074 * GPIO_13 pin function.CNcomment:GPIO_13管脚功能。CNend
1075 */
1076 typedef enum {
1077     HI_IO_FUNC_GPIO_13_SSI_DATA,
1078     HI_IO_FUNC_GPIO_13_UART0_TXD,
1079     HI_IO_FUNC_GPIO_13_UART2_RTS_N,
1080     HI_IO_FUNC_GPIO_13_SDIO_D0,
1081     HI_IO_FUNC_GPIO_13_GPIO,
1082     HI_IO_FUNC_GPIO_13_PWM4_OUT,
1083     HI_IO_FUNC_GPIO_13_I2C0_SDA,
1084     HI_IO_FUNC_GPIO_13_I2S0_WS,
1085 } hi_io_func_gpio_13;
1086 
1087 /**
1088 * @ingroup iot_io
1089 *
1090 * GPIO_14 pin function.CNcomment:GPIO_14管脚功能。CNend
1091 */
1092 typedef enum {
1093     HI_IO_FUNC_GPIO_14_SSI_CLK,
1094     HI_IO_FUNC_GPIO_14_UART0_RXD,
1095     HI_IO_FUNC_GPIO_14_UART2_CTS_N,
1096     HI_IO_FUNC_GPIO_14_SDIO_D1,
1097     HI_IO_FUNC_GPIO_14_GPIO,
1098     HI_IO_FUNC_GPIO_14_PWM5_OUT,
1099     HI_IO_FUNC_GPIO_14_I2C0_SCL,
1100 } hi_io_func_gpio_14;
1101 
1102 /**
1103 * @ingroup iot_io
1104 *
1105 * SFC_CSN pin function.CNcomment:SFC_CSN管脚功能。CNend
1106 */
1107 typedef enum {
1108     HI_IO_FUNC_SFC_CSN_SFC_CSN,
1109     HI_IO_FUNC_SFC_CSN_SDIO_D2,
1110     HI_IO_FUNC_SFC_CSN_GPIO9,
1111     HI_IO_FUNC_SFC_CSN_SPI0_TXD = 4,
1112 } hi_io_func_sfc_csn;
1113 
1114 /**
1115 * @ingroup iot_io
1116 *
1117 * SFC_DO pin function.CNcomment:SFC_DO管脚功能。CNend
1118 */
1119 typedef enum {
1120     HI_IO_FUNC_SFC_IO_1_SFC_DO,
1121     HI_IO_FUNC_SFC_IO_1_SDIO_D3,
1122     HI_IO_FUNC_SFC_IO_1_GPIO10,
1123     HI_IO_FUNC_SFC_IO_1_SPI0_CK = 4,
1124 } hi_io_func_sfc_io_1;
1125 
1126 /**
1127 * @ingroup iot_io
1128 *
1129 * SFC_WPN pin function.CNcomment:SFC_WPN管脚功能。CNend
1130 */
1131 typedef enum {
1132     HI_IO_FUNC_SFC_IO_2_SFC_WPN,
1133     HI_IO_FUNC_SFC_IO_2_SDIO_CMD,
1134     HI_IO_FUNC_SFC_IO_2_GPIO11,
1135     HI_IO_FUNC_SFC_IO_2_RF_TX_EN_EXT,
1136     HI_IO_FUNC_SFC_IO_2_SPI0_RXD,
1137 } hi_io_func_sfc_io_2;
1138 
1139 /**
1140 * @ingroup iot_io
1141 *
1142 * SFC_DI pin function.CNcomment:SFC_DI管脚功能。CNend
1143 */
1144 typedef enum {
1145     HI_IO_FUNC_SFC_IO_0_SFC_DI,
1146     HI_IO_FUNC_SFC_IO_0_SDIO_CLK,
1147     HI_IO_FUNC_SFC_IO_0_GPIO12,
1148     HI_IO_FUNC_SFC_IO_0_RF_RX_EN_EXT,
1149     HI_IO_FUNC_SFC_IO_0_SPI0_CSN,
1150 } hi_io_func_sfc_io_0;
1151 
1152 /**
1153 * @ingroup iot_io
1154 *
1155 * SFC_CLK pin function.CNcomment:SFC_CLK管脚功能。CNend
1156 */
1157 typedef enum {
1158     HI_IO_FUNC_SFC_CLK_SFC_CLK,
1159     HI_IO_FUNC_SFC_CLK_SDIO_D0,
1160     HI_IO_FUNC_SFC_CLK_GPIO13,
1161     HI_IO_FUNC_SFC_CLK_SSI_DATA = 4,
1162 } hi_io_func_sfc_clk;
1163 
1164 /**
1165 * @ingroup iot_io
1166 *
1167 * SFC_HOLDN pin function.CNcomment:SFC_HOLDN管脚功能。CNend
1168 */
1169 typedef enum {
1170     HI_IO_FUNC_SFC_IO_3_SFC_HOLDN,
1171     HI_IO_FUNC_SFC_IO_3_SDIO_D1,
1172     HI_IO_FUNC_SFC_IO_3_GPIO14,
1173     HI_IO_FUNC_SFC_IO_3_SSI_CLK = 4,
1174 } hi_io_func_sfc_io_3;
1175 
1176 /**
1177 * @ingroup  iot_io
1178 * @brief Sets the I/O multiplexing.CNcomment:配置某个IO的复用功能。CNend
1179 *
1180 * @par 描述:
1181 *           Sets the I/O multiplexing.CNcomment:配置某个IO的复用功能。CNend
1182 *
1183 * @attention None
1184 * @param  id  [IN] type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend
1185 * @param  val [IN] type #hi_u8,I/O multiplexing.See the functions below: CNcomment:IO复用功能。
1186 根据待设置的硬件管脚,从如下枚举中选择相应功能。CNend
1187                         hi_io_func_gpio_0,
1188                         hi_io_func_gpio_1,
1189                         hi_io_func_gpio_2,
1190                         hi_io_func_gpio_3,
1191                         hi_io_func_gpio_4,
1192                         hi_io_func_gpio_5,
1193                         hi_io_func_gpio_6,
1194                         hi_io_func_gpio_7,
1195                         hi_io_func_gpio_8,
1196                         hi_io_func_gpio_9,
1197                         hi_io_func_gpio_10,
1198                         hi_io_func_gpio_11,
1199                         hi_io_func_gpio_12,
1200                         hi_io_func_gpio_13,
1201                         hi_io_func_gpio_14,
1202                         hi_io_func_sfc_csn,
1203                         hi_io_func_sfc_io_1,
1204                         hi_io_func_sfc_io_2,
1205                         hi_io_func_sfc_io_0,
1206                         hi_io_func_sfc_clk,
1207                         hi_io_func_sfc_io_3
1208 *
1209 * @retval #HI_ERR_SUCCESS       Success
1210 * @retval #HI_ERR_GPIO_INVALID_PARAMETER     Failure. Input invalid.
1211 * @par 依赖:
1212 *           @li hi_boot_rom.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend
1213 * @see  hi_io_set_func。
1214 */
1215 hi_u32 hi_io_set_func(hi_io_name id, hi_u8 val);
1216 
1217 /**
1218 * @ingroup  iot_io
1219 * @brief Enables the I/O pull-up.CNcomment:设置某个IO上下拉功能。CNend
1220 *
1221 * @par 描述:
1222 *           Enables the I/O pull-up.CNcomment:设置某个IO上下拉功能。CNend
1223 *
1224 * @attention None
1225 * @param  id  [IN]  type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend
1226 * @param  val [IN]  type #hi_io_pull,I/O pull-up enable.CNcomment:待设置的上下拉状态。CNend
1227 *
1228 * @retval #HI_ERR_SUCCESS       Success
1229 * @retval #HI_ERR_GPIO_INVALID_PARAMETER     Failure. Input invalid.
1230 * @par 依赖:
1231 *           @li hi_boot_rom.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend
1232 * @see  hi_io_get_pull。
1233 */
1234 hi_u32 hi_io_set_pull(hi_io_name id, hi_io_pull val);
1235 #endif
1236 
1237