efm32_wdog.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /***************************************************************************//**
  2. * @file
  3. * @brief Watchdog (WDOG) peripheral API for EFM32.
  4. * @author Energy Micro AS
  5. * @version 1.3.0
  6. *******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2010 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * This source code is the property of Energy Micro AS. The source and compiled
  12. * code may only be used on Energy Micro "EFM32" microcontrollers.
  13. *
  14. * This copyright notice may not be removed from the source code nor changed.
  15. *
  16. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  17. * obligation to support this Software. Energy Micro AS is providing the
  18. * Software "AS IS", with no express or implied warranties of any kind,
  19. * including, but not limited to, any implied warranties of merchantability
  20. * or fitness for any particular purpose or warranties against infringement
  21. * of any proprietary rights of a third party.
  22. *
  23. * Energy Micro AS will not be liable for any consequential, incidental, or
  24. * special damages, or any other relief, or for any claim by any third party,
  25. * arising from your use of this Software.
  26. *
  27. ******************************************************************************/
  28. #ifndef __EFM32_WDOG_H
  29. #define __EFM32_WDOG_H
  30. #include <stdbool.h>
  31. #include "efm32.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /***************************************************************************//**
  36. * @addtogroup EFM32_Library
  37. * @{
  38. ******************************************************************************/
  39. /***************************************************************************//**
  40. * @addtogroup WDOG
  41. * @{
  42. ******************************************************************************/
  43. /*******************************************************************************
  44. ******************************** ENUMS ************************************
  45. ******************************************************************************/
  46. /** Watchdog clock selection. */
  47. typedef enum
  48. {
  49. wdogClkSelULFRCO = _WDOG_CTRL_CLKSEL_ULFRCO, /**< Ultra low frequency (1 kHz) clock */
  50. wdogClkSelLFRCO = _WDOG_CTRL_CLKSEL_LFRCO, /**< Low frequency RC oscillator */
  51. wdogClkSelLFXO = _WDOG_CTRL_CLKSEL_LFXO /**< Low frequency crystal oscillator */
  52. } WDOG_ClkSel_TypeDef;
  53. /** Watchdog period selection. */
  54. typedef enum
  55. {
  56. wdogPeriod_9 = 0x0, /**< 9 clock periods */
  57. wdogPeriod_17 = 0x1, /**< 17 clock periods */
  58. wdogPeriod_33 = 0x2, /**< 33 clock periods */
  59. wdogPeriod_65 = 0x3, /**< 65 clock periods */
  60. wdogPeriod_129 = 0x4, /**< 129 clock periods */
  61. wdogPeriod_257 = 0x5, /**< 257 clock periods */
  62. wdogPeriod_513 = 0x6, /**< 513 clock periods */
  63. wdogPeriod_1k = 0x7, /**< 1025 clock periods */
  64. wdogPeriod_2k = 0x8, /**< 2049 clock periods */
  65. wdogPeriod_4k = 0x9, /**< 4097 clock periods */
  66. wdogPeriod_8k = 0xA, /**< 8193 clock periods */
  67. wdogPeriod_16k = 0xB, /**< 16385 clock periods */
  68. wdogPeriod_32k = 0xC, /**< 32769 clock periods */
  69. wdogPeriod_64k = 0xD, /**< 65537 clock periods */
  70. wdogPeriod_128k = 0xE, /**< 131073 clock periods */
  71. wdogPeriod_256k = 0xF /**< 262145 clock periods */
  72. } WDOG_PeriodSel_TypeDef;
  73. /*******************************************************************************
  74. ******************************* STRUCTS ***********************************
  75. ******************************************************************************/
  76. /** Watchdog initialization structure. */
  77. typedef struct
  78. {
  79. /** Enable watchdog when init completed. */
  80. bool enable;
  81. /** Counter shall keep running during debug halt. */
  82. bool debugRun;
  83. /** Counter shall keep running when in EM2. */
  84. bool em2Run;
  85. /** Counter shall keep running when in EM3. */
  86. bool em3Run;
  87. /** Block EMU from entering EM4. */
  88. bool em4Block;
  89. /** Block SW from disabling LFRCO/LFXO oscillators. */
  90. bool swoscBlock;
  91. /** Block SW from modifying the configuration (a reset is needed to reconfigure). */
  92. bool lock;
  93. /** Clock source to use for watchdog. */
  94. WDOG_ClkSel_TypeDef clkSel;
  95. /** Watchdog timeout period. */
  96. WDOG_PeriodSel_TypeDef perSel;
  97. } WDOG_Init_TypeDef;
  98. /** Suggested default config for WDOG init structure. */
  99. #define WDOG_INIT_DEFAULT \
  100. { true, /* Start watchdog when init done */ \
  101. false, /* WDOG not counting during debug halt */ \
  102. false, /* WDOG not counting when in EM2 */ \
  103. false, /* WDOG not counting when in EM3 */ \
  104. false, /* EM4 can be entered */ \
  105. false, /* Do not block disabling LFRCO/LFXO in CMU */ \
  106. false, /* Do not lock WDOG configuration (if locked, reset needed to unlock) */ \
  107. wdogClkSelULFRCO, /* Select 1kHZ WDOG oscillator */ \
  108. wdogPeriod_256k /* Set longest possible timeout period */ \
  109. }
  110. /*******************************************************************************
  111. ***************************** PROTOTYPES **********************************
  112. ******************************************************************************/
  113. void WDOG_Enable(bool enable);
  114. void WDOG_Feed(void);
  115. void WDOG_Init(const WDOG_Init_TypeDef *init);
  116. void WDOG_Lock(void);
  117. /** @} (end addtogroup WDOG) */
  118. /** @} (end addtogroup EFM32_Library) */
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /* __EFM32_WDOG_H */