nu_wdt.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**************************************************************************//**
  2. * @file wdt.c
  3. * @brief NUC980 series WDT driver source file
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. * @copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  7. *****************************************************************************/
  8. #include "nu_wdt.h"
  9. /** @addtogroup Standard_Driver Standard Driver
  10. @{
  11. */
  12. /** @addtogroup WDT_Driver WDT Driver
  13. @{
  14. */
  15. /** @addtogroup WDT_EXPORTED_FUNCTIONS WDT Exported Functions
  16. @{
  17. */
  18. /**
  19. * @brief Initialize WDT and start counting
  20. *
  21. * @param[in] u32TimeoutInterval Time-out interval period of WDT module. Valid values are:
  22. * - \ref WDT_TIMEOUT_2POW4
  23. * - \ref WDT_TIMEOUT_2POW6
  24. * - \ref WDT_TIMEOUT_2POW8
  25. * - \ref WDT_TIMEOUT_2POW10
  26. * - \ref WDT_TIMEOUT_2POW12
  27. * - \ref WDT_TIMEOUT_2POW14
  28. * - \ref WDT_TIMEOUT_2POW16
  29. * - \ref WDT_TIMEOUT_2POW18
  30. * * \ref WDT_TIMEOUT_2POW20
  31. * @param[in] u32ResetDelay Configure WDT time-out reset delay period. Valid values are:
  32. * - \ref WDT_RESET_DELAY_1026CLK
  33. * - \ref WDT_RESET_DELAY_130CLK
  34. * - \ref WDT_RESET_DELAY_18CLK
  35. * - \ref WDT_RESET_DELAY_3CLK
  36. * @param[in] u32EnableReset Enable WDT time-out reset system function. Valid values are TRUE and FALSE.
  37. * @param[in] u32EnableWakeup Enable WDT time-out wake-up system function. Valid values are TRUE and FALSE.
  38. *
  39. * @return None
  40. *
  41. * @details This function makes WDT module start counting with different time-out interval, reset delay period and choose to \n
  42. * enable or disable WDT time-out reset system or wake-up system.
  43. * @note Please make sure that Register Write-Protection Function has been disabled before using this function.
  44. */
  45. void WDT_Open(UINT32 u32TimeoutInterval,
  46. UINT32 u32ResetDelay,
  47. UINT32 u32EnableReset,
  48. UINT32 u32EnableWakeup)
  49. {
  50. outpw(REG_WDT_ALTCTL, u32ResetDelay);
  51. outpw(REG_WDT_CTL, u32TimeoutInterval | 0x80 |
  52. (u32EnableReset << 1) |
  53. (u32EnableWakeup << 4));
  54. return;
  55. }
  56. /*@}*/ /* end of group WDT_EXPORTED_FUNCTIONS */
  57. /*@}*/ /* end of group WDT_Driver */
  58. /*@}*/ /* end of group Standard_Driver */