• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
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 #pragma once
16 
17 #include <common/bk_include.h>
18 #include <driver/wdt_types.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 /* @brief Overview about this API header
26  *
27  */
28 
29 /**
30  * @brief WDT API
31  * @defgroup bk_api_wdt WDT API group
32  * @{
33  */
34 
35 /**
36  * @brief     Init the WDT driver
37  *
38  * This API init the resoure common:
39  *   - Init WDT driver control memory
40  *
41  * @attention 1. This API should be called before any other WDT APIs.
42  *
43  * @return
44  *    - BK_OK: succeed
45  *    - others: other errors.
46  */
47 bk_err_t bk_wdt_driver_init(void);
48 
49 /**
50  * @brief     Deinit the WDT driver
51  *
52  * This API free all resource related to WDT and power down WDT.
53  *
54  * @return
55  *    - BK_OK: succeed
56  *    - others: other errors.
57  */
58 bk_err_t bk_wdt_driver_deinit(void);
59 
60 /**
61  * @brief     Start the WDT
62  *
63  * This API start the WDT:
64  *  - Power up the WDT
65  *  - Init the watch dog timer period
66  *
67  * @param timeout_ms WDT period
68  *
69  * @return
70  *    - BK_OK: succeed
71  *    - BK_ERR_WDT_DRIVER_NOT_INIT: WDT driver not init
72  *    - BK_ERR_WDT_INVALID_PERIOD: WDT invalid period
73  *    - others: other errors.
74  */
75 bk_err_t bk_wdt_start(uint32_t timeout_ms);
76 
77 /**
78  * @brief     Stop the WDT
79  *
80  * This API stop the WDT:
81  *   - Reset all configuration of WDT to default value
82  *   - Power down the WDT
83  *
84  * @return
85  *    - BK_OK: succeed
86  *    - others: other errors.
87  */
88 bk_err_t bk_wdt_stop(void);
89 
90 /**
91  * @brief     Feed the WDT
92  *
93  * @return
94  *    - BK_OK: succeed
95  *    - others: other errors.
96  */
97 bk_err_t bk_wdt_feed(void);
98 
99 /**
100  * @brief   Get feed watchdog time
101  *
102  * @return
103  *    - BK_OK: succeed
104  *    - others: other errors.
105  */
106 uint32_t bk_wdt_get_feed_time(void);
107 
108 /**
109  * @brief  set feed watchdog time
110  *
111  * @return
112  *    - NULL
113  *
114  */
115 void bk_wdt_set_feed_time(uint32_t dw_set_time);
116 
117 /**
118  * @brief   Get wdt driver init flag
119  *
120  * @return
121  *    - BK_OK: succeed
122  *    - others: other errors.
123  */
124 bool bk_wdt_is_driver_inited(void);
125 
126 /**
127  * @}
128  */
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134