1 /*
2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3 */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <aos/errno.h>
8 #include <aos/kernel.h>
9 #include "aos/init.h"
10 #include "board.h"
11 #include <k_api.h>
12 #include "aos/cli.h"
13 #include "led.h"
14 #include "hal_gpio.h"
15 #include "hal_iomux_haas1000.h"
16
timer1_func(void * timer,void * arg)17 static void timer1_func(void *timer, void *arg)
18 {
19 static int times = 1;
20 printf("\r\n%.1f s\r\n", times * 0.2);
21 times++;
22 }
23
handle_watchdog_test_cmd(char * pwbuf,int blen,int argc,char ** argv)24 static void handle_watchdog_test_cmd(char *pwbuf, int blen, int argc, char **argv)
25 {
26 aos_timer_t timer1;
27 int status;
28
29 if (argc < 2) {
30 printf("Usage: watchdog stopfeed\n");
31 printf("Example: watchdog stopfeed\n");
32 return;
33 }
34
35 if (0 == strcmp(argv[1], "stopfeed")) {
36 printf("begin stop feed dog, board will reboot in 1.6 s ...\n");
37 status = aos_timer_new(&timer1, timer1_func, NULL, 200, 1);
38 if (status != 0) {
39 printf("create timer error\n");
40 return;
41 }
42 watchdog_stopfeed();
43 } else {
44 printf("Usage: watchdog stopfeed\n");
45 printf("Example: watchdog stopfeed\n");
46 return;
47 }
48 }
49
50 static struct cli_command watchdog_test_cmd = {
51 .name = "watchdog",
52 .help = "watchdog [stopfeed]",
53 .function = handle_watchdog_test_cmd
54 };
55
watchdog_test()56 void watchdog_test()
57 {
58 int ret = 0;
59 printf("\r\n\r\n");
60 printf("***************************************************************\r\n");
61 printf("*********************** watchdog Test *************************\r\n");
62 printf("** How to test: input [watchdog stopfeed] command *************\r\n");
63 printf("***************************************************************\r\n");
64 printf("=====watchdog test : Start=====\r\n");
65
66 aos_cli_register_command(&watchdog_test_cmd);
67 watchdog_stopfeed();
68 }
69