1 /* 2 * Copyright (C) 2017-2019 Alibaba Group Holding Limited 3 */ 4 5 /****************************************************************************** 6 * @file drv_wdt.h 7 * @brief header file for wdt driver 8 * @version V1.0 9 * @date 02. June 2017 10 * @model wdt 11 ******************************************************************************/ 12 13 #ifndef _CSI_WDT_H_ 14 #define _CSI_WDT_H_ 15 16 17 #include <stdint.h> 18 #include <drv/common.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 /// definition for wdt handle. 24 typedef void *wdt_handle_t; 25 26 /****** WDT Event *****/ 27 typedef enum { 28 WDT_EVENT_TIMEOUT = 0 ///< generate the interrupt 29 } wdt_event_e; 30 31 typedef void (*wdt_event_cb_t)(int32_t idx, wdt_event_e event); ///< Pointer to \ref wdt_event_cb_t : WDT Event call back. 32 33 /** 34 \brief Initialize WDT Interface. 1. Initializes the resources needed for the WDT interface 2.registers event callback function 35 \param[in] idx wdt index 36 \param[in] cb_event event call back function \ref wdt_event_cb_t 37 \return pointer to wdt instance 38 */ 39 wdt_handle_t csi_wdt_initialize(int32_t idx, wdt_event_cb_t cb_event); 40 41 /** 42 \brief De-initialize WDT Interface. stops operation and releases the software resources used by the interface 43 \param[in] handle wdt handle to operate. 44 \return error code 45 */ 46 int32_t csi_wdt_uninitialize(wdt_handle_t handle); 47 48 /** 49 \brief control wdt power. 50 \param[in] handle wdt handle to operate. 51 \param[in] state power state.\ref csi_power_stat_e. 52 \return error code 53 */ 54 int32_t csi_wdt_power_control(wdt_handle_t handle, csi_power_stat_e state); 55 56 /** 57 \brief Set the WDT value. 58 \param[in] handle wdt handle to operate. 59 \param[in] value the timeout value(ms). 60 \return error code 61 */ 62 int32_t csi_wdt_set_timeout(wdt_handle_t handle, uint32_t value); 63 64 /** 65 \brief Start the WDT. 66 \param[in] handle wdt handle to operate. 67 \return error code 68 */ 69 int32_t csi_wdt_start(wdt_handle_t handle); 70 71 /** 72 \brief Stop the WDT. 73 \param[in] handle wdt handle to operate. 74 \return error code 75 */ 76 int32_t csi_wdt_stop(wdt_handle_t handle); 77 78 /** 79 \brief Restart the WDT. 80 \param[in] handle wdt handle to operate. 81 \return error code 82 */ 83 int32_t csi_wdt_restart(wdt_handle_t handle); 84 85 /** 86 \brief Read the WDT Current value. 87 \param[in] handle wdt handle to operate. 88 \param[out] value Pointer to the Value. 89 \return error code 90 */ 91 int32_t csi_wdt_read_current_value(wdt_handle_t handle, uint32_t *value); 92 93 #ifdef __cplusplus 94 } 95 #endif 96 97 #endif /* _CSI_WDT_H_ */ 98