nu_wwdt.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**************************************************************************//**
  2. * @file nu_wwdt.h
  3. * @version V3.00
  4. * $Revision: 5 $
  5. * $Date: 18/06/07 9:48a $
  6. * @brief M031 series Window Watchdog Timet(WWDT) driver header file
  7. *
  8. * @note
  9. * SPDX-License-Identifier: Apache-2.0
  10. * Copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  11. *****************************************************************************/
  12. #ifndef __NU_WWDT_H__
  13. #define __NU_WWDT_H__
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif
  18. /** @addtogroup Standard_Driver Standard Driver
  19. @{
  20. */
  21. /** @addtogroup WWDT_Driver WWDT Driver
  22. @{
  23. */
  24. /** @addtogroup WWDT_EXPORTED_CONSTANTS WWDT Exported Constants
  25. @{
  26. */
  27. /*---------------------------------------------------------------------------------------------------------*/
  28. /* WWDT Prescale Period Constant Definitions */
  29. /*---------------------------------------------------------------------------------------------------------*/
  30. #define WWDT_PRESCALER_1 (0 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 1 * (64*WWDT_CLK) \hideinitializer */
  31. #define WWDT_PRESCALER_2 (1 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 2 * (64*WWDT_CLK) \hideinitializer */
  32. #define WWDT_PRESCALER_4 (2 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 4 * (64*WWDT_CLK) \hideinitializer */
  33. #define WWDT_PRESCALER_8 (3 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 8 * (64*WWDT_CLK) \hideinitializer */
  34. #define WWDT_PRESCALER_16 (4 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 16 * (64*WWDT_CLK) \hideinitializer */
  35. #define WWDT_PRESCALER_32 (5 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 32 * (64*WWDT_CLK) \hideinitializer */
  36. #define WWDT_PRESCALER_64 (6 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 64 * (64*WWDT_CLK) \hideinitializer */
  37. #define WWDT_PRESCALER_128 (7 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 128 * (64*WWDT_CLK) \hideinitializer */
  38. #define WWDT_PRESCALER_192 (8 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 192 * (64*WWDT_CLK) \hideinitializer */
  39. #define WWDT_PRESCALER_256 (9 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 256 * (64*WWDT_CLK) \hideinitializer */
  40. #define WWDT_PRESCALER_384 (10 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 384 * (64*WWDT_CLK) \hideinitializer */
  41. #define WWDT_PRESCALER_512 (11 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 512 * (64*WWDT_CLK) \hideinitializer */
  42. #define WWDT_PRESCALER_768 (12 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 768 * (64*WWDT_CLK) \hideinitializer */
  43. #define WWDT_PRESCALER_1024 (13 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 1024 * (64*WWDT_CLK) \hideinitializer */
  44. #define WWDT_PRESCALER_1536 (14 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 1536 * (64*WWDT_CLK) \hideinitializer */
  45. #define WWDT_PRESCALER_2048 (15 << WWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 2048 * (64*WWDT_CLK) \hideinitializer */
  46. /*---------------------------------------------------------------------------------------------------------*/
  47. /* WWDT Reload Counter Keyword Constant Definitions */
  48. /*---------------------------------------------------------------------------------------------------------*/
  49. #define WWDT_RELOAD_WORD (0x00005AA5) /*!< Fill this value to WWDT_RLDCNT register to reload WWDT counter \hideinitializer */
  50. /*@}*/ /* end of group WWDT_EXPORTED_CONSTANTS */
  51. /** @addtogroup WWDT_EXPORTED_FUNCTIONS WWDT Exported Functions
  52. @{
  53. */
  54. /**
  55. * @brief Clear WWDT Reset System Flag
  56. *
  57. * @param None
  58. *
  59. * @return None
  60. *
  61. * @details This macro is used to clear WWDT time-out reset system flag.
  62. * \hideinitializer
  63. */
  64. #define WWDT_CLEAR_RESET_FLAG() (WWDT->STATUS = WWDT_STATUS_WWDTRF_Msk)
  65. /**
  66. * @brief Clear WWDT Compared Match Interrupt Flag
  67. *
  68. * @param None
  69. *
  70. * @return None
  71. *
  72. * @details This macro is used to clear WWDT compared match interrupt flag.
  73. * \hideinitializer
  74. */
  75. #define WWDT_CLEAR_INT_FLAG() (WWDT->STATUS = WWDT_STATUS_WWDTIF_Msk)
  76. /**
  77. * @brief Get WWDT Reset System Flag
  78. *
  79. * @param None
  80. *
  81. * @retval 0 WWDT time-out reset system did not occur
  82. * @retval 1 WWDT time-out reset system occurred
  83. *
  84. * @details This macro is used to indicate system has been reset by WWDT time-out reset or not.
  85. * \hideinitializer
  86. */
  87. #define WWDT_GET_RESET_FLAG() ((WWDT->STATUS & WWDT_STATUS_WWDTRF_Msk)? 1 : 0)
  88. /**
  89. * @brief Get WWDT Compared Match Interrupt Flag
  90. *
  91. * @param None
  92. *
  93. * @retval 0 WWDT compare match interrupt did not occur
  94. * @retval 1 WWDT compare match interrupt occurred
  95. *
  96. * @details This macro is used to indicate WWDT counter value matches CMPDAT value or not.
  97. * \hideinitializer
  98. */
  99. #define WWDT_GET_INT_FLAG() ((WWDT->STATUS & WWDT_STATUS_WWDTIF_Msk)? 1 : 0)
  100. /**
  101. * @brief Get WWDT Counter
  102. *
  103. * @param None
  104. *
  105. * @return WWDT Counter Value
  106. *
  107. * @details This macro reflects the current WWDT counter value.
  108. * \hideinitializer
  109. */
  110. #define WWDT_GET_COUNTER() (WWDT->CNT)
  111. /**
  112. * @brief Reload WWDT Counter
  113. *
  114. * @param None
  115. *
  116. * @return None
  117. *
  118. * @details This macro is used to reload the WWDT counter value to 0x3F.
  119. * @note User can only write WWDT_RLDCNT register to reload WWDT counter value when current WWDT counter value \n
  120. * between 0 and CMPDAT value. If user writes WWDT_RLDCNT when current WWDT counter value is larger than CMPDAT, \n
  121. * WWDT reset signal will generate immediately to reset system.
  122. * \hideinitializer
  123. */
  124. #define WWDT_RELOAD_COUNTER() (WWDT->RLDCNT = WWDT_RELOAD_WORD)
  125. void WWDT_Open(uint32_t u32PreScale, uint32_t u32CmpValue, uint32_t u32EnableInt);
  126. /*@}*/ /* end of group WWDT_EXPORTED_FUNCTIONS */
  127. /*@}*/ /* end of group WWDT_Driver */
  128. /*@}*/ /* end of group Standard_Driver */
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif //__NU_WWDT_H__
  133. /*** (C) COPYRIGHT 2018 Nuvoton Technology Corp. ***/