wdt.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /**
  2. * @file wdt.h
  3. * @brief Watchdog timer (WDT) function prototypes and data types.
  4. */
  5. /* ****************************************************************************
  6. * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included
  16. * in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
  22. * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. * Except as contained in this notice, the name of Maxim Integrated
  27. * Products, Inc. shall not be used except as stated in the Maxim Integrated
  28. * Products, Inc. Branding Policy.
  29. *
  30. * The mere transfer of this software does not imply any licenses
  31. * of trade secrets, proprietary technology, copyrights, patents,
  32. * trademarks, maskwork rights, or any other form of intellectual
  33. * property whatsoever. Maxim Integrated Products, Inc. retains all
  34. * ownership rights.
  35. *
  36. * $Date: 2020-04-20 15:06:58 -0500 (Mon, 20 Apr 2020) $
  37. * $Revision: 53142 $
  38. *
  39. *************************************************************************** */
  40. /* Define to prevent redundant inclusion */
  41. #ifndef _WDT_H_
  42. #define _WDT_H_
  43. /* **** Includes **** */
  44. #include <stdint.h>
  45. #include "mxc_config.h"
  46. #include "mxc_sys.h"
  47. #include "wdt_regs.h"
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. /**
  52. * @defgroup wdt Watchdog Timer (WDT)
  53. * @ingroup periphlibs
  54. * @{
  55. */
  56. /* **** Definitions **** */
  57. /** @brief Watchdog period enumeration.
  58. Used to configure the period of the watchdog interrupt */
  59. typedef enum {
  60. WDT_PERIOD_2_31 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW31, /**< Period 2^31 */
  61. WDT_PERIOD_2_30 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW30, /**< Period 2^30 */
  62. WDT_PERIOD_2_29 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW29, /**< Period 2^29 */
  63. WDT_PERIOD_2_28 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW28, /**< Period 2^28 */
  64. WDT_PERIOD_2_27 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW27, /**< Period 2^27 */
  65. WDT_PERIOD_2_26 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW26, /**< Period 2^26 */
  66. WDT_PERIOD_2_25 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW25, /**< Period 2^25 */
  67. WDT_PERIOD_2_24 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW24, /**< Period 2^24 */
  68. WDT_PERIOD_2_23 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW23, /**< Period 2^23 */
  69. WDT_PERIOD_2_22 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW22, /**< Period 2^22 */
  70. WDT_PERIOD_2_21 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW21, /**< Period 2^21 */
  71. WDT_PERIOD_2_20 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW20, /**< Period 2^20 */
  72. WDT_PERIOD_2_19 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW19, /**< Period 2^19 */
  73. WDT_PERIOD_2_18 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW18, /**< Period 2^18 */
  74. WDT_PERIOD_2_17 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW17, /**< Period 2^17 */
  75. WDT_PERIOD_2_16 = MXC_S_WDT_CTRL_INT_PERIOD_WDT2POW16, /**< Period 2^16 */
  76. } wdt_period_t;
  77. /* **** Function Prototypes **** */
  78. /**
  79. * @brief Initialize the Watchdog Timer
  80. * @param wdt Pointer to the watchdog registers
  81. * @param sys_cfg The system configuration object
  82. */
  83. int WDT_Init(mxc_wdt_regs_t* wdt, sys_cfg_wdt_t sys_cfg);
  84. /**
  85. * @brief Set the period of the watchdog interrupt.
  86. * @param wdt Pointer to watchdog registers.
  87. * @param period Enumeration of the desired watchdog period.
  88. */
  89. void WDT_SetIntPeriod(mxc_wdt_regs_t* wdt, wdt_period_t period);
  90. /**
  91. * @brief Set the period of the watchdog reset.
  92. * @param wdt Pointer to watchdog registers.
  93. * @param period Enumeration of the desired watchdog period.
  94. */
  95. void WDT_SetResetPeriod(mxc_wdt_regs_t* wdt, wdt_period_t period);
  96. /**
  97. * @brief Enable the watchdog timer.
  98. * @param wdt Pointer to watchdog registers.
  99. * @param enable 1 to enable the timer, 0 to disable.
  100. */
  101. void WDT_Enable(mxc_wdt_regs_t* wdt, int enable);
  102. /**
  103. * @brief Enable the watchdog interrupt.
  104. * @param wdt Pointer to watchdog registers.
  105. * @param enable 1 to enable the interrupt, 0 to disable.
  106. */
  107. void WDT_EnableInt(mxc_wdt_regs_t* wdt, int enable);
  108. /**
  109. * @brief Enable the watchdog reset.
  110. * @param wdt Pointer to watchdog registers.
  111. * @param enable 1 to enable the reset, 0 to disable.
  112. */
  113. void WDT_EnableReset(mxc_wdt_regs_t* wdt, int enable);
  114. /**
  115. * @brief Reset the watchdog timer.
  116. * @param wdt Pointer to watchdog registers.
  117. */
  118. void WDT_ResetTimer(mxc_wdt_regs_t* wdt);
  119. /**
  120. * @brief Get the status of the reset flag.
  121. * @param wdt Pointer to watchdog registers.
  122. * @returns 1 if the previous reset was caused by the watchdog, 0 otherwise.
  123. */
  124. int WDT_GetResetFlag(mxc_wdt_regs_t* wdt);
  125. /**
  126. * @brief Clears the reset flag.
  127. * @param wdt Pointer to watchdog registers.
  128. */
  129. void WDT_ClearResetFlag(mxc_wdt_regs_t* wdt);
  130. /**
  131. * @brief Get the status of the interrupt flag.
  132. * @param wdt Pointer to watchdog registers.
  133. * @returns 1 if the interrupt is pending, 0 otherwise.
  134. */
  135. int WDT_GetIntFlag(mxc_wdt_regs_t* wdt);
  136. /**
  137. * @brief Clears the interrupt flag.
  138. * @param wdt Pointer to watchdog registers.
  139. */
  140. void WDT_ClearIntFlag(mxc_wdt_regs_t* wdt);
  141. /**@} end of group wdt */
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif /* _WDT_H_ */