stm8s_iwdg.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. ********************************************************************************
  3. * @file stm8s_iwdg.c
  4. * @author MCD Application Team
  5. * @version V2.3.0
  6. * @date 16-June-2017
  7. * @brief This file contains all the functions 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. /* Includes ------------------------------------------------------------------*/
  28. #include "stm8s_iwdg.h"
  29. /* Private define ------------------------------------------------------------*/
  30. /* Private macro -------------------------------------------------------------*/
  31. /* Private variables ---------------------------------------------------------*/
  32. /* Private function prototypes -----------------------------------------------*/
  33. /* Private functions ---------------------------------------------------------*/
  34. /* Public functions ----------------------------------------------------------*/
  35. /** @addtogroup IWDG_Public_Functions
  36. * @{
  37. */
  38. /**
  39. * @brief Enables or disables write access to Prescaler and Reload registers.
  40. * @param IWDG_WriteAccess : New state of write access to Prescaler and Reload
  41. * registers. This parameter can be a value of @ref IWDG_WriteAccess_TypeDef.
  42. * @retval None
  43. */
  44. void IWDG_WriteAccessCmd(IWDG_WriteAccess_TypeDef IWDG_WriteAccess)
  45. {
  46. /* Check the parameters */
  47. assert_param(IS_IWDG_WRITEACCESS_MODE_OK(IWDG_WriteAccess));
  48. IWDG->KR = (uint8_t)IWDG_WriteAccess; /* Write Access */
  49. }
  50. /**
  51. * @brief Sets IWDG Prescaler value.
  52. * @note Write access should be enabled
  53. * @param IWDG_Prescaler : Specifies the IWDG Prescaler value.
  54. * This parameter can be a value of @ref IWDG_Prescaler_TypeDef.
  55. * @retval None
  56. */
  57. void IWDG_SetPrescaler(IWDG_Prescaler_TypeDef IWDG_Prescaler)
  58. {
  59. /* Check the parameters */
  60. assert_param(IS_IWDG_PRESCALER_OK(IWDG_Prescaler));
  61. IWDG->PR = (uint8_t)IWDG_Prescaler;
  62. }
  63. /**
  64. * @brief Sets IWDG Reload value.
  65. * @note Write access should be enabled
  66. * @param IWDG_Reload : Reload register value.
  67. * This parameter must be a number between 0 and 0xFF.
  68. * @retval None
  69. */
  70. void IWDG_SetReload(uint8_t IWDG_Reload)
  71. {
  72. IWDG->RLR = IWDG_Reload;
  73. }
  74. /**
  75. * @brief Reloads IWDG counter
  76. * @note Write access should be enabled
  77. * @param None
  78. * @retval None
  79. */
  80. void IWDG_ReloadCounter(void)
  81. {
  82. IWDG->KR = IWDG_KEY_REFRESH;
  83. }
  84. /**
  85. * @brief Enables IWDG.
  86. * @param None
  87. * @retval None
  88. */
  89. void IWDG_Enable(void)
  90. {
  91. IWDG->KR = IWDG_KEY_ENABLE;
  92. }
  93. /**
  94. * @}
  95. */
  96. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/