]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_wdt.h
Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.
[freertos] / FreeRTOS / Demo / T-HEAD_CB2201_CDK / csi / csi_driver / include / drv_wdt.h
1 /*
2  * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /******************************************************************************
17  * @file     drv_wdt.h
18  * @brief    header file for wdt driver
19  * @version  V1.0
20  * @date     02. June 2017
21  ******************************************************************************/
22
23 #ifndef _CSI_WDT_H_
24 #define _CSI_WDT_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include <stdint.h>
31 #include <drv_common.h>
32
33 /// definition for wdt handle.
34 typedef void *wdt_handle_t;
35
36 /****** WDT Event *****/
37 typedef enum {
38     WDT_EVENT_TIMEOUT       = 0  ///< generate the interrupt
39 } wdt_event_e;
40
41 typedef void (*wdt_event_cb_t)(wdt_event_e event);   ///< Pointer to \ref wdt_event_cb_t : WDT Event call back.
42
43 /**
44 \brief WDT Device Driver Capabilities.
45 */
46 typedef struct {
47     uint32_t interrupt          : 1;      ///< supports interrupt
48 } wdt_capabilities_t;
49
50 /**
51   \brief       get wdt instance count.
52   \return      wdt instance count
53 */
54 int32_t csi_wdt_get_instance_count(void);
55
56 /**
57   \brief       Initialize WDT Interface. 1. Initializes the resources needed for the WDT interface 2.registers event callback function
58   \param[in]   idx   must not exceed return value of csi_wdt_get_instance_count()
59   \param[in]   cb_event  Pointer to \ref wdt_event_cb_t
60   \return      pointer to wdt instance
61 */
62 wdt_handle_t csi_wdt_initialize(int32_t idx, wdt_event_cb_t cb_event);
63
64 /**
65   \brief       De-initialize WDT Interface. stops operation and releases the software resources used by the interface
66   \param[in]   handle wdt handle to operate.
67   \return      error code
68 */
69 int32_t csi_wdt_uninitialize(wdt_handle_t handle);
70
71 /**
72   \brief       Get driver capabilities.
73   \param[in]   handle wdt handle to operate.
74   \return      \ref wdt_capabilities_t
75 */
76 wdt_capabilities_t csi_wdt_get_capabilities(wdt_handle_t handle);
77
78 /**
79   \brief       Set the WDT value.
80   \param[in]   handle wdt handle to operate.
81   \param[in]   value     the timeout value(ms).
82   \return      error code
83 */
84 int32_t csi_wdt_set_timeout(wdt_handle_t handle, uint32_t value);
85
86 /**
87   \brief       Start the WDT.
88   \param[in]   handle wdt handle to operate.
89   \return      error code
90 */
91 int32_t csi_wdt_start(wdt_handle_t handle);
92
93 /**
94   \brief       Stop the WDT.
95   \param[in]   handle wdt handle to operate.
96   \return      error code
97 */
98 int32_t csi_wdt_stop(wdt_handle_t handle);
99
100 /**
101   \brief       Restart the WDT.
102   \param[in]   handle wdt handle to operate.
103   \return      error code
104 */
105 int32_t csi_wdt_restart(wdt_handle_t handle);
106
107 /**
108   \brief       Read the WDT Current value.
109   \param[in]   handle wdt handle to operate.
110   \param[in]   value     Pointer to the Value.
111   \return      error code
112 */
113 int32_t csi_wdt_read_current_value(wdt_handle_t handle, uint32_t *value);
114
115 #ifdef __cplusplus
116 }
117 #endif
118
119 #endif /* _CSI_WDT_H_ */