nu_wdt.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. * @param[in] u32ResetDelay Configure WDT time-out reset delay period. Valid values are:
  31. * - \ref WDT_RESET_DELAY_1026CLK
  32. * - \ref WDT_RESET_DELAY_130CLK
  33. * - \ref WDT_RESET_DELAY_18CLK
  34. * - \ref WDT_RESET_DELAY_3CLK
  35. * @param[in] u32EnableReset Enable WDT time-out reset system function. Valid values are TRUE and FALSE.
  36. * @param[in] u32EnableWakeup Enable WDT time-out wake-up system function. Valid values are TRUE and FALSE.
  37. *
  38. * @return None
  39. *
  40. * @details This function makes WDT module start counting with different time-out interval, reset delay period and choose to \n
  41. * enable or disable WDT time-out reset system or wake-up system.
  42. * @note Please make sure that Register Write-Protection Function has been disabled before using this function.
  43. */
  44. void WDT_Open(UINT32 u32TimeoutInterval,
  45. UINT32 u32ResetDelay,
  46. UINT32 u32EnableReset,
  47. UINT32 u32EnableWakeup)
  48. {
  49. outpw(REG_WDT_ALTCTL, u32ResetDelay);
  50. outpw(REG_WDT_CTL, u32TimeoutInterval | 0x80 |
  51. (u32EnableReset << 1) |
  52. (u32EnableWakeup << 4));
  53. return;
  54. }
  55. /*@}*/ /* end of group WDT_EXPORTED_FUNCTIONS */
  56. /*@}*/ /* end of group WDT_Driver */
  57. /*@}*/ /* end of group Standard_Driver */