11bd4fe43Sopenharmony_ci/**
21bd4fe43Sopenharmony_ci * @file watchdog.h
31bd4fe43Sopenharmony_ci *
41bd4fe43Sopenharmony_ci * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
51bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
61bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License.
71bd4fe43Sopenharmony_ci * You may obtain a copy of the License at
81bd4fe43Sopenharmony_ci *
91bd4fe43Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
101bd4fe43Sopenharmony_ci *
111bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
121bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
131bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and
151bd4fe43Sopenharmony_ci * limitations under the License.
161bd4fe43Sopenharmony_ci */
171bd4fe43Sopenharmony_ci
181bd4fe43Sopenharmony_ci#ifndef __BSP_INC_WATCHDOG_H__
191bd4fe43Sopenharmony_ci#define __BSP_INC_WATCHDOG_H__
201bd4fe43Sopenharmony_ci
211bd4fe43Sopenharmony_ci#include <hi3861_platform_base.h>
221bd4fe43Sopenharmony_ci#include <hi_watchdog.h>
231bd4fe43Sopenharmony_ci
241bd4fe43Sopenharmony_ci/**
251bd4fe43Sopenharmony_ci* @ingroup  hct_watchdog
261bd4fe43Sopenharmony_ci* @brief Watchdog callback function. CNcomment:看门狗到期回调函数。CNend
271bd4fe43Sopenharmony_ci*
281bd4fe43Sopenharmony_ci* @par 描述:
291bd4fe43Sopenharmony_ci*           Watchdog callback function. CNcomment:看门狗到期回调函数。CNend
301bd4fe43Sopenharmony_ci*
311bd4fe43Sopenharmony_ci* @attention None.
321bd4fe43Sopenharmony_ci* @param  data [IN] type #hi_u32,Callback function parameter passing.CNcomment:回调函数参数传递。CNend
331bd4fe43Sopenharmony_ci*
341bd4fe43Sopenharmony_ci* @retval None.
351bd4fe43Sopenharmony_ci* @par 依赖:
361bd4fe43Sopenharmony_ci*            @li watchdog.h:文件用于描述看门狗相关接口。
371bd4fe43Sopenharmony_ci* @see 无。
381bd4fe43Sopenharmony_ci*/
391bd4fe43Sopenharmony_citypedef hi_void (*hi_watchdog_func)(hi_u32 data);
401bd4fe43Sopenharmony_ci
411bd4fe43Sopenharmony_ci/**
421bd4fe43Sopenharmony_ci * @ingroup hct_watchdog
431bd4fe43Sopenharmony_ci *
441bd4fe43Sopenharmony_ci * Watchdog mode. CNcomment:看门狗模式。CNend
451bd4fe43Sopenharmony_ci */
461bd4fe43Sopenharmony_citypedef enum {
471bd4fe43Sopenharmony_ci    HI_WDG_MODE_NORMAL = 0,
481bd4fe43Sopenharmony_ci    HI_WDG_MODE_INTER = 1,
491bd4fe43Sopenharmony_ci    HI_WDG_MODE_ERR,
501bd4fe43Sopenharmony_ci} hi_wdg_mode;
511bd4fe43Sopenharmony_ci
521bd4fe43Sopenharmony_ci/**
531bd4fe43Sopenharmony_ci* @ingroup  hct_watchdog
541bd4fe43Sopenharmony_ci* @brief  Clear the watchdog interrupt.CNcomment:清除看门狗中断。CNend
551bd4fe43Sopenharmony_ci*
561bd4fe43Sopenharmony_ci* @par 描述:
571bd4fe43Sopenharmony_ci*           Clear the watchdog interrupt.CNcomment:清除看门狗中断。CNend
581bd4fe43Sopenharmony_ci*
591bd4fe43Sopenharmony_ci* @attention 无。
601bd4fe43Sopenharmony_ci* @param  无。
611bd4fe43Sopenharmony_ci*
621bd4fe43Sopenharmony_ci* @retval 无。
631bd4fe43Sopenharmony_ci* @par 依赖:
641bd4fe43Sopenharmony_ci*            @li watchdog.h:文件用于描述看门狗相关接口。
651bd4fe43Sopenharmony_ci* @see  无。
661bd4fe43Sopenharmony_ci*/
671bd4fe43Sopenharmony_ciHI_EXTERN hi_void hi_watchdog_int_clear(hi_void);
681bd4fe43Sopenharmony_ci
691bd4fe43Sopenharmony_ci/**
701bd4fe43Sopenharmony_ci* @ingroup  hct_watchdog
711bd4fe43Sopenharmony_ci* @brief  Configure to enable the watchdog. CNcomment:配置使能看门狗。CNend
721bd4fe43Sopenharmony_ci*
731bd4fe43Sopenharmony_ci* @par 描述:
741bd4fe43Sopenharmony_ci*           Configure to enable the watchdog. CNcomment:配置使能看门狗。CNend
751bd4fe43Sopenharmony_ci*
761bd4fe43Sopenharmony_ci* @attention 无。
771bd4fe43Sopenharmony_ci* @param  mode         [IN] type #hi_wdg_mode ,Watchdog mode. CNcomment:看门狗模式。CNend
781bd4fe43Sopenharmony_ci* @param  p_func       [IN] type #hi_watchdog_func,Configure the watchdog to interrupt mode and the function will be
791bd4fe43Sopenharmony_cicalled to notify the user when the watchdog first expires.
801bd4fe43Sopenharmony_ciCNcomment:配置看门狗为中断模式时,看门狗第一次到期时会调用该函数通知用户。CNend
811bd4fe43Sopenharmony_ci* @param  data         [IN] type #hi_u32 Callback function enter parameter. CNcomment:回调函数入参。CNend
821bd4fe43Sopenharmony_ci* @param  over_time_ms [IN] type #hi_u32,Watchdog expiration time (unit: ms).
831bd4fe43Sopenharmony_ci                        Expiration time calculation method: expiration time t = 2^(top+16)*1000/wd_clk,
841bd4fe43Sopenharmony_ci                        where wd_clk is the watchdog clock frequency and top range is 0~15.
851bd4fe43Sopenharmony_ci                        Therefore, there is a certain error between the expected expiration time and
861bd4fe43Sopenharmony_ci                        the actual expiration time.
871bd4fe43Sopenharmony_ci                        CNcomment:看门狗到期时间(单位:ms)。
881bd4fe43Sopenharmony_ci*                           到期时间计算方法:到期时间t = 2^(top+16)*1000/wd_clk,其中wd_clk为看门狗时钟频率,top取值为0~15。
891bd4fe43Sopenharmony_ci*                           因此期望的到期时间与实际到期时间有一定误差。CNend
901bd4fe43Sopenharmony_ci*
911bd4fe43Sopenharmony_ci* @retval #0           Sunccess.
921bd4fe43Sopenharmony_ci* @retval #非0         Failure. For details, see hi_errno.h.
931bd4fe43Sopenharmony_ci* @par 依赖:
941bd4fe43Sopenharmony_ci*            @li watchdog.h:文件用于描述看门狗相关接口。
951bd4fe43Sopenharmony_ci* @see  无。
961bd4fe43Sopenharmony_ci*/
971bd4fe43Sopenharmony_ciHI_EXTERN hi_u32 hi_watchdog_register(hi_wdg_mode mode, hi_watchdog_func p_func, hi_u32 data, hi_u32 over_time_ms);
981bd4fe43Sopenharmony_ci
991bd4fe43Sopenharmony_ciHI_EXTERN hi_void watchdog_irq_handler(hi_u32 data);
1001bd4fe43Sopenharmony_ci
1011bd4fe43Sopenharmony_ci#endif
1021bd4fe43Sopenharmony_ci
103