1 /*
2 * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved.
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
16 #ifdef AT_USER_DEBUG
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include "target_config.h"
22 #if (LOSCFG_USE_SHELL == 1)
23 #include "shell.h"
24 #include "shcmd.h"
25 #endif
26 #include "duet_flash_kv.h"
27 #include "flash.h"
28 #include "duet_flash.h"
29 #include "lega_rtos.h"
30 /*
31 ************************************************************
32 * USER AT CMD START
33 *
34 ************************************************************
35 */
36 #ifdef CFG_HARMONY_SUPPORT
openharmony_init()37 void openharmony_init()
38 {
39 extern void OHOS_SystemInit(void);
40 OHOS_SystemInit();
41 }
42 #endif
at_test_1(int argc,char ** argv)43 int at_test_1(int argc, char **argv)
44 {
45 printf("%s...\n", __func__);
46 return 0;
47 }
48
at_harmony_xts(int argc,char ** argv)49 int at_harmony_xts(int argc, char **argv)
50 {
51 #ifdef CFG_HARMONY_SUPPORT
52 openharmony_init();
53 #endif
54 return 0;
55 }
56
at_hilink_start(int argc,char ** argv)57 int at_hilink_start(int argc, char **argv)
58 {
59 return 0;
60 }
61
at_kv_clear(int argc,char ** argv)62 int at_kv_clear(int argc, char **argv)
63 {
64 lega_rtos_declare_critical();
65 lega_enter_critical_expble();
66 duet_flash_erase(PARTITION_PARAMETER_2, 0, KV_MAX_SIZE);
67 lega_exit_critical_expble();
68
69 printf("kv clear done\r\n");
70 delay(1000);
71 NVIC_SystemReset();
72 return 0;
73 }
74 /*
75 ************************************************************
76 * USER AT CMD END
77 *
78 ************************************************************
79 */
80
lega_at_user_cmd_register(void)81 void lega_at_user_cmd_register(void)
82 {
83 #if (LOSCFG_USE_SHELL == 1)
84 osCmdReg(CMD_TYPE_EX, "at_test1", 0, (CMD_CBK_FUNC)at_test_1);
85 osCmdReg(CMD_TYPE_EX, "at_harmony_xts", 0, (CMD_CBK_FUNC)at_harmony_xts);
86 osCmdReg(CMD_TYPE_EX, "at_hilink_start", 0, (CMD_CBK_FUNC)at_hilink_start);
87 osCmdReg(CMD_TYPE_EX, "kv_clear", 0, (CMD_CBK_FUNC)at_kv_clear);
88 #endif
89 }
90
91 #endif
92