1/**
2 * @file watchdog.h
3 *
4 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __BSP_INC_WATCHDOG_H__
19#define __BSP_INC_WATCHDOG_H__
20
21#include <hi3861_platform_base.h>
22#include <hi_watchdog.h>
23
24/**
25* @ingroup  hct_watchdog
26* @brief Watchdog callback function. CNcomment:看门狗到期回调函数。CNend
27*
28* @par 描述:
29*           Watchdog callback function. CNcomment:看门狗到期回调函数。CNend
30*
31* @attention None.
32* @param  data [IN] type #hi_u32,Callback function parameter passing.CNcomment:回调函数参数传递。CNend
33*
34* @retval None.
35* @par 依赖:
36*            @li watchdog.h:文件用于描述看门狗相关接口。
37* @see 无。
38*/
39typedef hi_void (*hi_watchdog_func)(hi_u32 data);
40
41/**
42 * @ingroup hct_watchdog
43 *
44 * Watchdog mode. CNcomment:看门狗模式。CNend
45 */
46typedef enum {
47    HI_WDG_MODE_NORMAL = 0,
48    HI_WDG_MODE_INTER = 1,
49    HI_WDG_MODE_ERR,
50} hi_wdg_mode;
51
52/**
53* @ingroup  hct_watchdog
54* @brief  Clear the watchdog interrupt.CNcomment:清除看门狗中断。CNend
55*
56* @par 描述:
57*           Clear the watchdog interrupt.CNcomment:清除看门狗中断。CNend
58*
59* @attention 无。
60* @param  无。
61*
62* @retval 无。
63* @par 依赖:
64*            @li watchdog.h:文件用于描述看门狗相关接口。
65* @see  无。
66*/
67HI_EXTERN hi_void hi_watchdog_int_clear(hi_void);
68
69/**
70* @ingroup  hct_watchdog
71* @brief  Configure to enable the watchdog. CNcomment:配置使能看门狗。CNend
72*
73* @par 描述:
74*           Configure to enable the watchdog. CNcomment:配置使能看门狗。CNend
75*
76* @attention 无。
77* @param  mode         [IN] type #hi_wdg_mode ,Watchdog mode. CNcomment:看门狗模式。CNend
78* @param  p_func       [IN] type #hi_watchdog_func,Configure the watchdog to interrupt mode and the function will be
79called to notify the user when the watchdog first expires.
80CNcomment:配置看门狗为中断模式时,看门狗第一次到期时会调用该函数通知用户。CNend
81* @param  data         [IN] type #hi_u32 Callback function enter parameter. CNcomment:回调函数入参。CNend
82* @param  over_time_ms [IN] type #hi_u32,Watchdog expiration time (unit: ms).
83                        Expiration time calculation method: expiration time t = 2^(top+16)*1000/wd_clk,
84                        where wd_clk is the watchdog clock frequency and top range is 0~15.
85                        Therefore, there is a certain error between the expected expiration time and
86                        the actual expiration time.
87                        CNcomment:看门狗到期时间(单位:ms)。
88*                           到期时间计算方法:到期时间t = 2^(top+16)*1000/wd_clk,其中wd_clk为看门狗时钟频率,top取值为0~15。
89*                           因此期望的到期时间与实际到期时间有一定误差。CNend
90*
91* @retval #0           Sunccess.
92* @retval #非0         Failure. For details, see hi_errno.h.
93* @par 依赖:
94*            @li watchdog.h:文件用于描述看门狗相关接口。
95* @see  无。
96*/
97HI_EXTERN hi_u32 hi_watchdog_register(hi_wdg_mode mode, hi_watchdog_func p_func, hi_u32 data, hi_u32 over_time_ms);
98
99HI_EXTERN hi_void watchdog_irq_handler(hi_u32 data);
100
101#endif
102
103