• 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. \n
14  *
15  * Description: Provides at common service api header for product \n
16  */
17 
18 #ifndef AT_PRODUCT_H
19 #define AT_PRODUCT_H
20 
21 #include "at.h"
22 
23 /**
24  * @defgroup middleware_utils_at_product Product
25  * @ingroup  middleware_utils_at
26  * @{
27  */
28 
29 /**
30  * @if Eng
31  * @brief  Declare AT msg queue create function type.
32  * @else
33  * @brief  声明AT命令消息队列创建接口类型。
34  * @endif
35  */
36 typedef void(*at_msg_queue_create_func_t)(uint32_t msg_count, uint32_t msg_size, unsigned long *queue_id);
37 
38 /**
39  * @if Eng
40  * @brief  Declare AT msg queue write function type.
41  * @else
42  * @brief  声明AT命令消息队列写接口类型。
43  * @endif
44  */
45 typedef uint32_t(*at_msg_queue_write_func_t)(unsigned long queue_id, void *msg_ptr,
46                                              uint32_t msg_size, uint32_t timeout);
47 
48 /**
49  * @if Eng
50  * @brief  Declare AT msg queue read function type.
51  * @else
52  * @brief  声明AT命令消息队列读接口类型。
53  * @endif
54  */
55 typedef uint32_t(*at_msg_queue_read_func_t)(unsigned long queue_id, void *buf_ptr,
56                                             uint32_t *buf_size, uint32_t timeout);
57 
58 /**
59  * @if Eng
60  * @brief  Declare AT log function type.
61  * @else
62  * @brief  声明AT命令日志接口类型。
63  * @endif
64  */
65 typedef uint32_t(*at_log_func_t)(const char *buf, uint16_t buf_size, uint8_t level);
66 
67 /**
68  * @if Eng
69  * @brief  Declare AT task pause function type.
70  * @else
71  * @brief  声明AT命令任务暂停接口类型。
72  * @endif
73  */
74 typedef void(*at_task_pause_func_t)(void);
75 
76 /**
77  * @if Eng
78  * @brief  Declare AT malloc function type.
79  * @else
80  * @brief  声明AT命令内存申请函数类型。
81  * @endif
82  */
83 typedef void*(*at_malloc_func_t)(uint32_t);
84 
85 /**
86  * @if Eng
87  * @brief  Declare AT free function type.
88  * @else
89  * @brief  声明AT命令内存释放函数类型。
90  * @endif
91  */
92 typedef void(*at_free_func_t)(void*);
93 
94 /**
95  * @if Eng
96  * @brief  Declare AT timeout callback function type.
97  * @else
98  * @brief  声明AT定时器回调函数类型。
99  * @endif
100  */
101 typedef void(*at_timer_callback_func_t)(void *argument);
102 
103 /**
104  * @if Eng
105  * @brief  Declare AT timeout create function type.
106  * @else
107  * @brief  声明AT定时器创建函数类型。
108  * @endif
109  */
110 typedef void*(*at_timer_create_func_t)(at_timer_callback_func_t callback, void *argument);
111 
112 /**
113  * @if Eng
114  * @brief  Declare AT timeout start function type.
115  * @else
116  * @brief  声明AT定时器启动函数类型。
117  * @endif
118  */
119 typedef void(*at_timer_start_func_t)(void *timer_handle, uint32_t time_us);
120 
121 /**
122  * @if Eng
123  * @brief  Declare AT timeout stop function type.
124  * @else
125  * @brief  声明AT定时器删除函数类型。
126  * @endif
127  */
128 typedef void(*at_timer_delete_func_t)(void *timer_handle);
129 
130 /**
131  * @if Eng
132  * @brief  Declare AT channel creating one mutex function type.
133  * @else
134  * @brief  声明AT命令创建互斥锁函数类型。
135  * @endif
136  */
137 typedef void*(*at_create_mutex_func_t)(void);
138 
139 /**
140  * @if Eng
141  * @brief  Declare AT channel acquiring one mutex function type.
142  * @else
143  * @brief  声明AT命令获取互斥锁函数类型。
144  * @endif
145  */
146 typedef void(*at_acquire_mutex_func_t)(void*);
147 
148 /**
149  * @if Eng
150  * @brief  Declare AT channel releasing one mutex function type.
151  * @else
152  * @brief  声明AT命令释放互斥锁函数类型。
153  * @endif
154  */
155 typedef void(*at_release_mutex_func_t)(void*);
156 
157 /**
158  * @if Eng
159  * @brief  Declare AT channel write function type.
160  * @else
161  * @brief  声明AT命令写函数类型。
162  * @endif
163  */
164 typedef void(*at_write_func_t)(const char*);
165 
166 /**
167  * @if Eng
168  * @brief  Declare AT command attribute handling function type.
169  * @else
170  * @brief  声明AT命令属性解析处理函数类型。
171  * @endif
172  */
173 typedef bool(*at_cmd_attr_func_t)(uint16_t attr);
174 
175 /**
176  * @if Eng
177  * @brief  Declare the list of basic functions on which AT depends.
178  * @else
179  * @brief  声明AT依赖的基础函数清单。
180  * @endif
181  */
182 typedef struct at_base_api_t {
183     at_malloc_func_t malloc_func;
184     at_free_func_t free_func;
185     at_msg_queue_create_func_t msg_queue_create_func;
186     at_msg_queue_write_func_t msg_queue_write_func;
187     at_msg_queue_read_func_t msg_queue_read_func;
188     at_task_pause_func_t task_pause_func;
189 #ifdef CONFIG_AT_SUPPORT_LOG
190     at_log_func_t log_func;
191 #endif
192 #ifdef CONFIG_AT_SUPPORT_CMD_ATTR
193     at_cmd_attr_func_t cmd_attr_func;
194 #endif
195 #ifdef CONFIG_AT_SUPPORT_ASYNCHRONOUS
196     at_timer_create_func_t timer_create_func;
197     at_timer_start_func_t timer_start_func;
198     at_timer_delete_func_t timer_delete_func;
199 #endif
200 #ifdef CONFIG_AT_SUPPORT_NOTIFY_REPORT
201     at_create_mutex_func_t create_mutex_func;
202     at_acquire_mutex_func_t acquire_mutex_func;
203     at_release_mutex_func_t release_mutex_func;
204 #endif
205 } at_base_api_t;
206 
207 #ifdef CONFIG_AT_SUPPORT_ASYNCHRONOUS
208 /**
209  * @if Eng
210  * @brief  Register AT command default abort func.
211  * @param  [in]  func AT command default abort func.
212  * @retval ERRCODE_SUCC Success.
213  * @retval Other Failure. For details, see @ref errcode_t
214  * @else
215  * @brief  注册AT命令默认打断函数。
216  * @param  [in]  func AT命令默认打断函数。
217  * @retval ERRCODE_SUCC 成功。
218  * @retval Other 失败,参考 @ref errcode_t
219  * @endif
220  */
221 errcode_t uapi_at_cmd_default_abort_register(at_abort_func_t func);
222 #endif
223 
224 /**
225  * @if Eng
226  * @brief  Register at base api func list.
227  * @param  [in]  base_api The at base api func list.
228  * @retval ERRCODE_SUCC Success.
229  * @retval Other Failure. For details, see @ref errcode_t
230  * @else
231  * @brief  注册AT所需的基础函数。
232  * @param  [in]  base_api 基础函数列表. see @ref at_base_api_t
233  * @retval ERRCODE_SUCC 成功。
234  * @retval Other 失败,参考 @ref errcode_t
235  * @endif
236  */
237 errcode_t uapi_at_base_api_register(at_base_api_t base_api);
238 
239 /**
240  * @if Eng
241  * @brief  Register write interface for channel.
242  * @param  [in]  id The channel id. see @ref at_channel_id_t
243  * @param  [in]  func The write interface. see @ref at_write_func_t
244  * @retval ERRCODE_SUCC Success.
245  * @retval Other Failure. For details, see @ref errcode_t
246  * @else
247  * @brief  为特定通道注册写接口。
248  * @param  [in]  id 通道号, 参考 @ref at_channel_id_t
249  * @param  [in]  func 写接口, 参考 @ref at_write_func_t
250  * @retval ERRCODE_SUCC 成功。
251  * @retval Other 失败,参考 @ref errcode_t
252  * @endif
253  */
254 errcode_t uapi_at_channel_write_register(at_channel_id_t id, at_write_func_t func);
255 
256 /**
257  * @if Eng
258  * @brief  Sending data to the AT module through a specific channel.
259  * @param  [in]  id The channel id. see @ref at_channel_id_t
260  * @param  [in]  data The address of data.
261  * @param  [in]  len The length of data.
262  * @retval ERRCODE_SUCC Success.
263  * @retval Other Failure. For details, see @ref errcode_t
264  * @else
265  * @brief  通过特定通道向模块发送数据。
266  * @param  [in]  id 通道号, 参考 @ref at_channel_id_t
267  * @param  [in]  data 数据起始地址。
268  * @param  [in]  len 数据长度。
269  * @retval ERRCODE_SUCC 成功。
270  * @retval Other 失败,参考 @ref errcode_t
271  * @endif
272  */
273 errcode_t uapi_at_channel_data_recv(at_channel_id_t id, uint8_t* data, uint32_t len);
274 
275 /**
276  * @if Eng
277  * @brief  AT module main processing function.
278  * @param  [in]  unused Reserved parameters.
279  * @else
280  * @brief  AT模块主处理函数。
281  * @param  [in]  unused 预留参数。
282  * @endif
283  */
284 void uapi_at_msg_main(void* unused);
285 
286 /**
287  * @}
288  */
289 #endif
290