at32f413_wdt.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**
  2. **************************************************************************
  3. * @file at32f413_wdt.h
  4. * @brief at32f413 wdt header file
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. /* Define to prevent recursive inclusion -------------------------------------*/
  25. #ifndef __AT32F413_WDT_H
  26. #define __AT32F413_WDT_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f413.h"
  32. /** @addtogroup AT32F413_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup WDT
  36. * @{
  37. */
  38. /** @defgroup WDT_flags_definition
  39. * @brief wdt flag
  40. * @{
  41. */
  42. #define WDT_DIVF_UPDATE_FLAG ((uint16_t)0x0001) /*!< wdt division value update complete flag */
  43. #define WDT_RLDF_UPDATE_FLAG ((uint16_t)0x0002) /*!< wdt reload value update complete flag */
  44. /**
  45. * @}
  46. */
  47. /** @defgroup WDT_exported_types
  48. * @{
  49. */
  50. /**
  51. * @brief wdt division value type
  52. */
  53. typedef enum
  54. {
  55. WDT_CLK_DIV_4 = 0x00, /*!< wdt clock divider value is 4 */
  56. WDT_CLK_DIV_8 = 0x01, /*!< wdt clock divider value is 8 */
  57. WDT_CLK_DIV_16 = 0x02, /*!< wdt clock divider value is 16 */
  58. WDT_CLK_DIV_32 = 0x03, /*!< wdt clock divider value is 32 */
  59. WDT_CLK_DIV_64 = 0x04, /*!< wdt clock divider value is 64 */
  60. WDT_CLK_DIV_128 = 0x05, /*!< wdt clock divider value is 128 */
  61. WDT_CLK_DIV_256 = 0x06 /*!< wdt clock divider value is 256 */
  62. } wdt_division_type;
  63. /**
  64. * @brief wdt cmd value type
  65. */
  66. typedef enum
  67. {
  68. WDT_CMD_LOCK = 0x0000, /*!< disable write protection command */
  69. WDT_CMD_UNLOCK = 0x5555, /*!< enable write protection command */
  70. WDT_CMD_ENABLE = 0xCCCC, /*!< enable wdt command */
  71. WDT_CMD_RELOAD = 0xAAAA /*!< reload command */
  72. } wdt_cmd_value_type;
  73. /**
  74. * @brief type define wdt register all
  75. */
  76. typedef struct
  77. {
  78. /**
  79. * @brief wdt cmd register, offset:0x00
  80. */
  81. union
  82. {
  83. __IO uint32_t cmd;
  84. struct
  85. {
  86. __IO uint32_t cmd : 16;/* [15:0] */
  87. __IO uint32_t reserved1 : 16;/* [31:16] */
  88. } cmd_bit;
  89. };
  90. /**
  91. * @brief wdt div register, offset:0x04
  92. */
  93. union
  94. {
  95. __IO uint32_t div;
  96. struct
  97. {
  98. __IO uint32_t div : 3; /* [2:0] */
  99. __IO uint32_t reserved1 : 29;/* [31:3] */
  100. } div_bit;
  101. };
  102. /**
  103. * @brief wdt rld register, offset:0x08
  104. */
  105. union
  106. {
  107. __IO uint32_t rld;
  108. struct
  109. {
  110. __IO uint32_t rld : 12;/* [11:0] */
  111. __IO uint32_t reserved1 : 20;/* [31:12] */
  112. } rld_bit;
  113. };
  114. /**
  115. * @brief wdt sts register, offset:0x0C
  116. */
  117. union
  118. {
  119. __IO uint32_t sts;
  120. struct
  121. {
  122. __IO uint32_t divf : 1; /* [0] */
  123. __IO uint32_t rldf : 1; /* [1] */
  124. __IO uint32_t reserved1 : 30;/* [31:2] */
  125. } sts_bit;
  126. };
  127. } wdt_type;
  128. /**
  129. * @}
  130. */
  131. #define WDT ((wdt_type *) WDT_BASE)
  132. /** @defgroup WDT_exported_functions
  133. * @{
  134. */
  135. void wdt_enable(void);
  136. void wdt_counter_reload(void);
  137. void wdt_reload_value_set(uint16_t reload_value);
  138. void wdt_divider_set(wdt_division_type division);
  139. void wdt_register_write_enable( confirm_state new_state);
  140. flag_status wdt_flag_get(uint16_t wdt_flag);
  141. /**
  142. * @}
  143. */
  144. /**
  145. * @}
  146. */
  147. /**
  148. * @}
  149. */
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif