nu_wwdt.h 6.2 KB

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