at32f415_wdt.h 4.6 KB

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