wwdt.h 6.1 KB

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