wdg_drv.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /******************************************************************************
  2. * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by XHSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. * @file wdt.c
  12. *
  13. * @brief Source file for WDT functions
  14. *
  15. * @author MADS Team
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************/
  19. /* Include files */
  20. /******************************************************************************/
  21. #include "board.h"
  22. //#include "ddl.h"
  23. #include "wdg_drv.h"
  24. /**
  25. ******************************************************************************
  26. ** \defgroup WdtGroup
  27. **
  28. ******************************************************************************/
  29. //@{
  30. /******************************************************************************/
  31. /* Local function prototypes ('static') */
  32. /******************************************************************************/
  33. /**
  34. ******************************************************************************
  35. ** \brief WDT溢出时间设置函数
  36. **
  37. ** \param [in] u8LoadValue 溢出时间
  38. **
  39. ** \retval 无
  40. **
  41. ******************************************************************************/
  42. void Wdt_WriteWdtLoad(uint8_t u8LoadValue)
  43. {
  44. M0P_WDT->CON_f.WOV = u8LoadValue;
  45. }
  46. /**
  47. ******************************************************************************
  48. ** \brief WDT喂狗
  49. **
  50. ** \param [in] 无
  51. **
  52. ** \retval Ok
  53. **
  54. ******************************************************************************/
  55. void feed_dog(void)
  56. {
  57. M0P_WDT->RST = 0x1E;
  58. M0P_WDT->RST = 0xE1;
  59. }
  60. void watchdog_init(en_wdt_func_t enFunc,en_wdt_time_t enTime)
  61. {
  62. ///< 开启WDT外设时钟
  63. //SetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN0)), SysctrlPeripheralWdt, TRUE);
  64. *((volatile uint32_t *)(&(M0P_SYSCTRL->PERI_CLKEN0))) |= ((1UL)<<15);
  65. // Sysctrl_SetPeripheralGate(SysctrlPeripheralWdt,TRUE);
  66. M0P_WDT->CON_f.WOV = enTime;
  67. M0P_WDT->CON_f.WINT_EN = enFunc;
  68. }
  69. //@} // WdtGroup