wwdt.h 5.8 KB

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