1 /*
2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3 */
4
5 #include <drv/wdt.h>
6 #include "aos/hal/gpio.h"
7 #include "hal_iomux_haas1000.h"
8
9 static gpio_dev_t wdg_gpio = {0, 0, NULL};
10 static int watchdog_flag = 0;
11
csi_wdt_init(csi_wdt_t * wdt,uint32_t idx)12 csi_error_t csi_wdt_init(csi_wdt_t *wdt, uint32_t idx)
13 {
14 if(!wdt)
15 return CSI_ERROR;
16
17 printf("%s - %d\r\n", __func__, __LINE__);
18 wdt->dev.idx = idx;
19
20 if(watchdog_flag == 1) {
21 printf("%s - wdt already init\r\n", __func__);
22 return;
23 }
24
25 if(wdg_gpio.port == 0) {
26 wdg_gpio.port = HAL_IOMUX_PIN_P4_5;
27 wdg_gpio.config = OUTPUT_PUSH_PULL;
28 hal_gpio_init(&wdg_gpio);
29 }
30
31 watchdog_flag = 1;
32
33 return CSI_OK;
34 }
35
csi_wdt_uninit(csi_wdt_t * wdt)36 void csi_wdt_uninit(csi_wdt_t *wdt)
37 {
38 printf("%s - %d\r\n", __func__, __LINE__);
39
40 if(watchdog_flag == 0) {
41 return;
42 }
43
44 hal_gpio_finalize(&wdg_gpio);
45
46 if(wdt) {
47 printf("%s - %d\r\n", __func__, __LINE__);
48 wdt->dev.idx = -1;
49 }
50 }
51
csi_wdt_set_timeout(csi_wdt_t * wdt,uint32_t ms)52 csi_error_t csi_wdt_set_timeout(csi_wdt_t *wdt, uint32_t ms)
53 {
54
55 printf("%s - %d, ignore timeout value set\r\n", __func__, __LINE__);
56
57 return CSI_OK;
58 }
59
csi_wdt_start(csi_wdt_t * wdt)60 csi_error_t csi_wdt_start(csi_wdt_t *wdt)
61 {
62 printf("%s - %d\r\n", __func__, __LINE__);
63 return CSI_OK;
64 }
65
csi_wdt_stop(csi_wdt_t * wdt)66 void csi_wdt_stop(csi_wdt_t *wdt)
67 {
68 printf("%s - %d\r\n", __func__, __LINE__);
69 }
70
csi_wdt_feed(csi_wdt_t * wdt)71 csi_error_t csi_wdt_feed(csi_wdt_t *wdt)
72 {
73 printf("%s - %d\r\n", __func__, __LINE__);
74
75 if(watchdog_flag == 0) {
76 printf("%s - watchdog is not init yet\r\n", __func__);
77 return;
78 }
79
80 hal_gpio_output_toggle(&wdg_gpio);
81
82 return CSI_OK;
83 }
84
wdt_irqhandler(void * Data)85 static uint32_t wdt_irqhandler(void *Data)
86 {
87 printf("%s - %d\r\n", __func__, __LINE__);
88 return CSI_OK;
89 }
90
csi_wdt_attach_callback(csi_wdt_t * wdt,void * callback,void * arg)91 csi_error_t csi_wdt_attach_callback(csi_wdt_t *wdt, void *callback, void *arg)
92 {
93 printf("%s - %d\r\n", __func__, __LINE__);
94 return CSI_OK;
95 }
96
csi_wdt_detach_callback(csi_wdt_t * wdt)97 void csi_wdt_detach_callback(csi_wdt_t *wdt)
98 {
99 printf("%s - %d\r\n", __func__, __LINE__);
100 return;
101 }
102