stm8s_iwdg.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /**
  2. ******************************************************************************
  3. * @file stm8s_iwdg.h
  4. * @author MCD Application Team
  5. * @version V2.3.0
  6. * @date 16-June-2017
  7. * @brief This file contains all functions prototypes and macros for the IWDG peripheral.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. /* Define to prevent recursive inclusion -------------------------------------*/
  28. #ifndef __STM8S_IWDG_H
  29. #define __STM8S_IWDG_H
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm8s.h"
  32. /** @addtogroup STM8S_StdPeriph_Driver
  33. * @{
  34. */
  35. /** @addtogroup IWDG_Private_Define
  36. * @{
  37. */
  38. /**
  39. * @brief Define used to prevent watchdog reset
  40. */
  41. #define IWDG_KEY_REFRESH ((uint8_t)0xAA) /*!< This value written in the Key register prevent the watchdog reset */
  42. /**
  43. * @brief Define used to start the watchdog counter down
  44. */
  45. #define IWDG_KEY_ENABLE ((uint8_t)0xCC) /*!< This value written in the Key register start the watchdog counting down*/
  46. /**
  47. * @}
  48. */
  49. /** @addtogroup IWDG_Private_Macros
  50. * @{
  51. */
  52. /**
  53. * @brief Macro used by the assert function in order to check the different
  54. * values of the prescaler.
  55. */
  56. #define IS_IWDG_PRESCALER_OK(VALUE) (((VALUE) == IWDG_Prescaler_4 ) || \
  57. ((VALUE) == IWDG_Prescaler_8 ) || \
  58. ((VALUE) == IWDG_Prescaler_16 ) || \
  59. ((VALUE) == IWDG_Prescaler_32 ) || \
  60. ((VALUE) == IWDG_Prescaler_64 ) || \
  61. ((VALUE) == IWDG_Prescaler_128 ) || \
  62. ((VALUE) == IWDG_Prescaler_256))
  63. /**
  64. * @brief Macro used by the assert function in order to check the different
  65. * values of the counter register.
  66. */
  67. #define IS_IWDG_WRITEACCESS_MODE_OK(MODE) (((MODE) == IWDG_WriteAccess_Enable) || ((MODE) == IWDG_WriteAccess_Disable))
  68. /**
  69. * @}
  70. */
  71. /** @addtogroup IWDG_Exported_Types
  72. * @{
  73. */
  74. /** IWDG write access enumeration */
  75. typedef enum
  76. {
  77. IWDG_WriteAccess_Enable = (uint8_t)0x55, /*!< Code 0x55 in Key register, allow write access to Prescaler and Reload registers */
  78. IWDG_WriteAccess_Disable = (uint8_t)0x00 /*!< Code 0x00 in Key register, not allow write access to Prescaler and Reload registers */
  79. } IWDG_WriteAccess_TypeDef;
  80. /** IWDG prescaler enumaration */
  81. typedef enum
  82. {
  83. IWDG_Prescaler_4 = (uint8_t)0x00, /*!< Used to set prescaler register to 4 */
  84. IWDG_Prescaler_8 = (uint8_t)0x01, /*!< Used to set prescaler register to 8 */
  85. IWDG_Prescaler_16 = (uint8_t)0x02, /*!< Used to set prescaler register to 16 */
  86. IWDG_Prescaler_32 = (uint8_t)0x03, /*!< Used to set prescaler register to 32 */
  87. IWDG_Prescaler_64 = (uint8_t)0x04, /*!< Used to set prescaler register to 64 */
  88. IWDG_Prescaler_128 = (uint8_t)0x05, /*!< Used to set prescaler register to 128 */
  89. IWDG_Prescaler_256 = (uint8_t)0x06 /*!< Used to set prescaler register to 256 */
  90. } IWDG_Prescaler_TypeDef;
  91. /**
  92. * @}
  93. */
  94. /** @addtogroup IWDG_Exported_Functions
  95. * @{
  96. */
  97. void IWDG_WriteAccessCmd(IWDG_WriteAccess_TypeDef IWDG_WriteAccess);
  98. void IWDG_SetPrescaler(IWDG_Prescaler_TypeDef IWDG_Prescaler);
  99. void IWDG_SetReload(uint8_t IWDG_Reload);
  100. void IWDG_ReloadCounter(void);
  101. void IWDG_Enable(void);
  102. /**
  103. * @}
  104. */
  105. #endif /* __STM8S_IWDG_H */
  106. /**
  107. * @}
  108. */
  109. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/