nu_wdt.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**************************************************************************//**
  2. * @file wdt.c
  3. * @version V3.00
  4. * @brief M480 series WDT driver source file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2016-2020 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #include "NuMicro.h"
  10. /** @addtogroup Standard_Driver Standard Driver
  11. @{
  12. */
  13. /** @addtogroup WDT_Driver WDT Driver
  14. @{
  15. */
  16. /** @addtogroup WDT_EXPORTED_FUNCTIONS WDT Exported Functions
  17. @{
  18. */
  19. /**
  20. * @brief Initialize WDT and start counting
  21. *
  22. * @param[in] u32TimeoutInterval Time-out interval period of WDT module. Valid values are:
  23. * - \ref WDT_TIMEOUT_2POW4
  24. * - \ref WDT_TIMEOUT_2POW6
  25. * - \ref WDT_TIMEOUT_2POW8
  26. * - \ref WDT_TIMEOUT_2POW10
  27. * - \ref WDT_TIMEOUT_2POW12
  28. * - \ref WDT_TIMEOUT_2POW14
  29. * - \ref WDT_TIMEOUT_2POW16
  30. * - \ref WDT_TIMEOUT_2POW18
  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_t u32TimeoutInterval,
  46. uint32_t u32ResetDelay,
  47. uint32_t u32EnableReset,
  48. uint32_t u32EnableWakeup)
  49. {
  50. WDT->ALTCTL = u32ResetDelay;
  51. WDT->CTL = u32TimeoutInterval | WDT_CTL_WDTEN_Msk |
  52. (u32EnableReset << WDT_CTL_RSTEN_Pos) |
  53. (u32EnableWakeup << WDT_CTL_WKEN_Pos);
  54. return;
  55. }
  56. /*@}*/ /* end of group WDT_EXPORTED_FUNCTIONS */
  57. /*@}*/ /* end of group WDT_Driver */
  58. /*@}*/ /* end of group Standard_Driver */
  59. /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/