STM8S/A Standard Peripherals Firmware Library: stm8s_iwdg.c Source File

STM8S/A

stm8s_iwdg.c
Go to the documentation of this file.
00001 /**
00002   ********************************************************************************
00003   * @file    stm8s_iwdg.c
00004   * @author  MCD Application Team
00005   * @version V2.2.0
00006   * @date    30-September-2014
00007   * @brief   This file contains all the functions for the IWDG peripheral.
00008    ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00012   *
00013   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00014   * You may not use this file except in compliance with the License.
00015   * You may obtain a copy of the License at:
00016   *
00017   *        http://www.st.com/software_license_agreement_liberty_v2
00018   *
00019   * Unless required by applicable law or agreed to in writing, software 
00020   * distributed under the License is distributed on an "AS IS" BASIS, 
00021   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022   * See the License for the specific language governing permissions and
00023   * limitations under the License.
00024   *
00025   ******************************************************************************
00026   */
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm8s_iwdg.h"
00030 
00031 /* Private define ------------------------------------------------------------*/
00032 /* Private macro -------------------------------------------------------------*/
00033 /* Private variables ---------------------------------------------------------*/
00034 /* Private function prototypes -----------------------------------------------*/
00035 /* Private functions ---------------------------------------------------------*/
00036 /* Public functions ----------------------------------------------------------*/
00037 
00038 /** @addtogroup IWDG_Public_Functions
00039   * @{
00040   */
00041 
00042 /**
00043   * @brief  Enables or disables write access to Prescaler and Reload registers.
00044   * @param  IWDG_WriteAccess : New state of write access to Prescaler and Reload
00045   *         registers.  This parameter can be a value of @ref IWDG_WriteAccess_TypeDef.
00046   * @retval None
00047   */
00048 void IWDG_WriteAccessCmd(IWDG_WriteAccess_TypeDef IWDG_WriteAccess)
00049 {
00050   /* Check the parameters */
00051   assert_param(IS_IWDG_WRITEACCESS_MODE_OK(IWDG_WriteAccess));
00052   
00053   IWDG->KR = (uint8_t)IWDG_WriteAccess; /* Write Access */
00054 }
00055 
00056 /**
00057   * @brief  Sets IWDG Prescaler value.
00058   * @note   Write access should be enabled
00059   * @param  IWDG_Prescaler : Specifies the IWDG Prescaler value.
00060   *         This parameter can be a value of @ref IWDG_Prescaler_TypeDef.
00061   * @retval None
00062   */
00063 void IWDG_SetPrescaler(IWDG_Prescaler_TypeDef IWDG_Prescaler)
00064 {
00065   /* Check the parameters */
00066   assert_param(IS_IWDG_PRESCALER_OK(IWDG_Prescaler));
00067   
00068   IWDG->PR = (uint8_t)IWDG_Prescaler;
00069 }
00070 
00071 /**
00072   * @brief  Sets IWDG Reload value.
00073   * @note   Write access should be enabled
00074   * @param  IWDG_Reload : Reload register value.
00075   *         This parameter must be a number between 0 and 0xFF.
00076   * @retval None
00077   */
00078 void IWDG_SetReload(uint8_t IWDG_Reload)
00079 {
00080   IWDG->RLR = IWDG_Reload;
00081 }
00082 
00083 /**
00084   * @brief  Reloads IWDG counter
00085   * @note   Write access should be enabled
00086   * @param  None
00087   * @retval None
00088   */
00089 void IWDG_ReloadCounter(void)
00090 {
00091   IWDG->KR = IWDG_KEY_REFRESH;
00092 }
00093 
00094 /**
00095   * @brief  Enables IWDG.
00096   * @param  None
00097   * @retval None
00098   */
00099 void IWDG_Enable(void)
00100 {
00101   IWDG->KR = IWDG_KEY_ENABLE;
00102 }
00103 
00104 /**
00105   * @}
00106   */
00107   
00108 /**
00109   * @}
00110   */
00111   
00112 
00113 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com