• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file hi_shell.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_shell Shell
19  *  @ingroup dfx
20  */
21 
22 #ifndef __HI_SHELL_H__
23 #define __HI_SHELL_H__
24 
25 #include <hi_types.h>
26 #include <hi_uart.h>
27 
28 typedef  hi_s32 (*hi_shell_input_func)(hi_u8 *data, hi_u32 data_len);
29 typedef  hi_s32 (*hi_shell_output_func)(const hi_u8 *data, hi_u32 data_len);
30 typedef hi_u32 (*hi_shell_cmd_callback_func)(hi_u32 argc, hi_char **argv);
31 /**
32 * @ingroup  iot_shell
33 * @brief  Shell initialization function.
34 CNcomment:SHELL初始化函数。CNend
35 *
36 * @par 描述:
37 *      Shell initialization function.
38 CNcomment:SHELL初始化函数。CNend
39 *
40 * @attention None.
41 * @param None.
42 *
43 * @retval #0                 Success.
44 * @retval #Other             Failure. For details, see hi_errno.h.
45 * @par 依赖:
46 *           @li hi_shell.h:Describes SHELL APIs.
47 CNcomment:文件用于描述SHELL相关接口。CNend
48 */
49 hi_u32 hi_shell_init(hi_void);
50 
51 /**
52 * @ingroup  iot_shell
53 * @brief  Set taks size of SHELL. CNcomment:设置SHELL相关任务栈大小。CNend
54 *
55 * @par 描述:
56 *         Set taks size of SHELL. CNcomment:设置SHELL相关任务栈大小。CNend
57 *
58 * @attention shell task stack size needs to be set before shell initialization.
59 CNcomment:shell任务栈大小需要在shell初始化之前设置。CNend
60 * @param  channel_task_size      [IN] type #hi_u16 channel task size,task size should not smaller than 0x600.
61 CNcomment:通道任务栈大小,任务栈大小不低于0x600。CNend
62 * @param  process_task_size      [IN] type #hi_u16 process task size,task size should not smaller than 0xc00.
63 CNcomment:处理任务栈大小,任务栈大小不低于0xc00。CNend
64 *
65 * @retval None
66 * @par 依赖:
67 *           @li hi_shell.h:Describes SHELL APIs.
68 CNcomment:文件用于描述SHELL相关接口。CNend
69 */
70 hi_void hi_shell_set_task_size(hi_u16 channel_task_size, hi_u16 process_task_size);
71 
72 /**
73 * @ingroup  iot_shell
74 * @brief  Get shell registered output function.
75 CNcomment:获取SHELL注册的输出函数。CNend
76 *
77 * @par 描述:
78 *      Get shell registered output function.
79 CNcomment:获取SHELL注册的输出函数。CNend
80 *
81 * @attention None.
82 * @param  None.
83 *
84 * @retval #g_shell_output_func   Shell output function.
85 * @par 依赖:
86 *           @li hi_shell.h:Describes SHELL APIs.
87 CNcomment:文件用于描述SHELL相关接口。CNend
88 */
89 hi_shell_output_func hi_shell_get_register_output_func(hi_void);
90 
91 /**
92 * @ingroup  iot_shell
93 * @brief  Register shell input function to replace uart input.
94 CNcomment:注册SHELL输入函数,代替默认从UART读取SHELL输入数据。CNend
95 *
96 * @par 描述:
97 *      Register shell input function to replace uart input.
98 CNcomment:注册SHELL输入函数,代替默认从UART读取SHELL输入数据。CNend
99 *
100 * @attention Should set suitable task size; input func should not continuous read data without break. otherwise,
101 a watchdog may happen.not support register HI_NULL when shell channel is already uart.
102 CNcomment:根据输入函数实现,设置合适的栈大小;输入函数不能持续
103 返回有效数据避免触发看门狗。当SHELL 通道已经是UART时,不支持注
104 册SHELL 输入函数为HI_NULL。CNend
105 * @param  shell_input_func      [IN] type #hi_shell_input_func,shell input function.
106 CNcomment:SHELL输入函数。CNend
107 *
108 * @retval #0                 Success.
109 * @retval #Other             Failure. For details, see hi_errno.h.
110 * @par 依赖:
111 *           @li hi_shell.h:Describes SHELL APIs.
112 CNcomment:文件用于描述SHELL相关接口。CNend
113 */
114 hi_u32 hi_shell_register_input_func(hi_shell_input_func shell_input_func);
115 
116 /**
117 * @ingroup  iot_shell
118 * @brief  Register shell output function to replace uart output.
119 CNcomment:注册SHELL输出函数,代替默认从UART输出SHELL相关数据。CNend
120 *
121 * @par 描述:
122 *      Register shell output function to replace uart output.
123 CNcomment:注册SHELL输出函数,代替默认从UART输出SHELL相关数据。CNend
124 *
125 * @attention Should set suitable task size according to implementation of output func.
126 CNcomment:根据输出函数实现,设置合适的栈大小。CNend
127 * @param  shell_output_func      [IN] type #hi_shell_output_func,shell output function.
128 CNcomment:SHELL输出函数。CNend
129 *
130 * @retval None
131 * @par 依赖:
132 *           @li hi_shell.h:Describes SHELL APIs.
133 CNcomment:文件用于描述SHELL相关接口。CNend
134 */
135 hi_void hi_shell_register_output_func(hi_shell_output_func shell_output_func);
136 
137 /**
138 * @ingroup  iot_shell
139 * @brief  Set whether to check the UART busy status when low power vote.
140 CNcomment:设置低功耗投票时是否检查UART busy状态。CNend
141 *
142 * @par 描述:
143 *      Set whether to check the UART busy status when low power vote.
144 CNcomment:设置低功耗投票时是否检查UART busy状态。CNend
145 *
146 * @attention UART busy status is not checked by default.
147 CNcomment:默认低功耗睡眠投票时不检查UART busy状态。CNend
148 * @param  enable         [IN] type #hi_bool,enable status. CNcomment:设置是否检查UART busy状态。CNend
149 *
150 * @retval None
151 * @par 依赖:
152 *           @li hi_diag.h:Describes SHELL APIs.
153 CNcomment:文件用于描述SHELL相关接口。CNend
154 */
155 hi_void hi_shell_set_check_uart_busy(hi_bool enable);
156 
157 /**
158 * @ingroup  iot_shell
159 * @brief  Registration shell command processing function.CNcomment:注册shell命令处理函数。CNend
160 *
161 * @par 描述:Registration shell command processing function.CNcomment:注册shell命令处理函数。CNend
162 *
163 * @attention:Only the first 32 command line arguments are recognized, and the remaining parts are not recognized.
164 CNcomment:仅识别前32个shell命令行参数,32个之后的命令行参数将不被识别。CNend
165 * @param  cmd_key       [IN] type #hi_char*,Register command name, the length must be less than 16 bytes.
166 CNcomment:shell命令名称,命令长度不能大于16字节。CNend
167 * @param  cmd_callback  [IN] type #hi_shell_cmd_callback_func,Shell command processing function.
168 CNcomment:shell命令处理函数。CNend
169 *
170 * @retval #HI_ERR_SUCCESS         Success.
171 * @retval #Other     Failure. For details, see hi_errno.h.
172 * @par 依赖:
173 *           @li hi_shell.h:Describes SHELL APIs. CNcomment:文件用于描述SHELL相关接口。CNend
174 * @see  None
175 */
176 hi_u32 hi_shell_cmd_register(hi_char *cmd_key, hi_shell_cmd_callback_func cmd_callback);
177 
178 #endif
179