/****************************************************************************** * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved. * * This software component is licensed by XHSC under BSD 3-Clause license * (the "License"); You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ******************************************************************************/ /****************************************************************************** * @file wdt.c * * @brief Source file for WDT functions * * @author MADS Team * ******************************************************************************/ /******************************************************************************/ /* Include files */ /******************************************************************************/ #include "board.h" //#include "ddl.h" #include "wdg_drv.h" /** ****************************************************************************** ** \defgroup WdtGroup ** ******************************************************************************/ //@{ /******************************************************************************/ /* Local function prototypes ('static') */ /******************************************************************************/ /** ****************************************************************************** ** \brief WDT溢出时间设置函数 ** ** \param [in] u8LoadValue 溢出时间 ** ** \retval 无 ** ******************************************************************************/ void Wdt_WriteWdtLoad(uint8_t u8LoadValue) { M0P_WDT->CON_f.WOV = u8LoadValue; } /** ****************************************************************************** ** \brief WDT喂狗 ** ** \param [in] 无 ** ** \retval Ok ** ******************************************************************************/ void feed_dog(void) { M0P_WDT->RST = 0x1E; M0P_WDT->RST = 0xE1; } void watchdog_init(en_wdt_func_t enFunc,en_wdt_time_t enTime) { ///< 开启WDT外设时钟 //SetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN0)), SysctrlPeripheralWdt, TRUE); *((volatile uint32_t *)(&(M0P_SYSCTRL->PERI_CLKEN0))) |= ((1UL)<<15); // Sysctrl_SetPeripheralGate(SysctrlPeripheralWdt,TRUE); M0P_WDT->CON_f.WOV = enTime; M0P_WDT->CON_f.WINT_EN = enFunc; } //@} // WdtGroup