⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st79_iwdg.c

📁 st公司新出的一款8位单片机st79的lib库
💻 C
字号:
/**
  ********************************************************************************
  * @file st79_iwdg.c
  * @brief This file contains all the functions for the IWDG peripheral.
  * @author STMicroelectronics - MCD & APG Car Body Application Labs
  * @version V0.01
  * @date 04-JUL-2007
  ******************************************************************************
  *
  * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2007 STMicroelectronics</center></h2>
  * @image html logo.bmp
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "st79_iwdg.h"

/* LINKER SECTIONS DEFINITION FOR THIS FILE ONLY */
#pragma section (IWDG_CODE)
#pragma section const {IWDG_CONST}
#pragma section @near [IWDG_URAM]
#pragma section @near {IWDG_IRAM}
#pragma section @tiny [IWDG_UZRAM]
#pragma section @tiny {IWDG_IZRAM}

/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/

/** @addtogroup IWDG_Public_Functions
  * @{
  */

/**
  * @brief Enables or disables write access to Prescaler and Reload registers.
  *
  * @par Full description:
  *  IWDG_WriteAccess: new state of write access to Prescaler and Reload registers.
  *                    This parameter can be one of the following values:
  *                       - IWDG_WriteAccess_Enable: Enable write access to
  *                         Prescaler and Reload registers
  *                       - IWDG_WriteAccess_Disable: Disable write access to
  *                         Prescaler and Reload registers
  * @param[in] IWDG_WriteAccess enable or disable the write access.
  * @retval void None
  * @par Required preconditions:
  * None
  * @par Called functions:
  * None
  * @par Example:
  * This example shows how to call the function:
  * @code
  * Enable write access to Prescaler and Reload registers
  * IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
  * @endcode
  */
void IWDG_WriteAccessCmd(IWDG_WriteAccess_TypeDef IWDG_WriteAccess)
{
  /* Check the parameters */
  assert(IS_IWDG_WRITEACCESS_MODE_OK(IWDG_WriteAccess));
  IWDG->KR = (u8)IWDG_WriteAccess; /* Write Access */
}

/**
  * @brief Sets IWDG Prescaler value.
  * @par Full description:
  * IWDG_Prescaler: specifies the IWDG Prescaler value.
  *                    This parameter can be one of the following values:
  *                       - IWDG_Prescaler_4: IWDG prescaler set to 4
  *                       - IWDG_Prescaler_8: IWDG prescaler set to 8
  *                       - IWDG_Prescaler_16: IWDG prescaler set to 16
  *                       - IWDG_Prescaler_32: IWDG prescaler set to 32
  *                       - IWDG_Prescaler_64: IWDG prescaler set to 64
  *                       - IWDG_Prescaler_128: IWDG prescaler set to 128
  *                       - IWDG_Prescaler_256: IWDG prescaler set to 256
  * @param[in] IWDG_Prescaler set the value of the prescaler register.
  * @retval void None
  * @par Required preconditions:
  * Write access enabled
  * @par Called functions:
  * IWDG_WriteAccessCmd
  * @par Example:
  * This example shows how to call the function:
  * @code
  * IWDG counter clock: 32KHz
  * IWDG_SetPrescaler(IWDG_Prescaler_32);
  * @endcode
  */
void IWDG_SetPrescaler(IWDG_Prescaler_TypeDef IWDG_Prescaler)
{
  /* Check the parameters */
  assert(IS_IWDG_PRESCALER_VALUE_OK(IWDG_Prescaler));
  IWDG->PR = (u8)IWDG_Prescaler;
}

/**
  * @brief Sets IWDG Reload value.
  * @par Full description:
  * Reload: specifies the IWDG Reload value.
  *                    This parameter must be a number between 0 and 0xFF.
  * @param[in] IWDG_Reload reload register value.
  * @retval void None
  * @par Required preconditions:
  * Write access enabled
  * @par Called functions:
  * IWDG_WriteAccessCmd
  * @par Examples:
  * This example shows how to call the function:
  * @code
  * Set counter reload value to 149
  * IWDG_SetReload(149);
  * @endcode
  */
void IWDG_SetReload(u8 IWDG_Reload)
{
  IWDG->RLR = IWDG_Reload;
}

/**
  * @brief Reload IWDG counter
  * @par Full description:
  * Reloads IWDG counter with value defined in the reload register
  *                  (write access to Prescaler and Reload registers disabled).
  * @par Parameters:
  * None
  * @retval void None
  * @par Required preconditions:
  * Write access enabled
  * @par Called functions:
  * None
  * @par Examples:
  * This example shows how to call the function:
  * @code
  * Reload IWDG counter
  * IWDG_ReloadCounter();
  * @endcode
  */
void IWDG_ReloadCounter(void)
{
  IWDG->KR = IWDG_KEY_REFRESH;
}

/**
  * @brief Enable IWDG registers access.
  * @par Full description:
  * Enables IWDG (write access to Prescaler and Reload registers disabled).
  * @par Parameters:
  * None
  * @retval void None
  * @par Required preconditions:
  * None
  * @par Called functions:
  * IWDG_WriteAccessCmd
  * @par Examples:
  * This example shows how to call the function:
  * @code
  * Enable IWDG
  * IWDG_Enable();
  * @endcode
  */
void IWDG_Enable(void)
{
  IWDG->KR = IWDG_KEY_ENABLE;
}

/**
  * @}
  */

/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -