STM8L15x Standard Peripherals Drivers: stm8l15x_rst.c Source File

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_rst.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm8l15x_rst.c
00004   * @author  MCD Application Team
00005   * @version V1.5.0
00006   * @date    13-May-2011
00007   * @brief   This file provides firmware functions to manage the following 
00008   *          functionalities of the RST peripheral:
00009   *           - Flag management
00010   *           - NRST Pin configuration
00011   *
00012   *  @verbatim
00013   *               
00014   *          ===================================================================
00015   *                               RST specific features
00016   *          ===================================================================
00017   *
00018   *           When a reset occurs, there is a reset phase from the external pin 
00019   *           pull-down to the internal reset signal release. During this phase,
00020   *           the microcontroller sets some hardware configurations before going
00021   *           to the reset vector.
00022   *           At the end of this phase, most of the registers are configured with
00023   *           their �reset state� values. 
00024   *           During the reset phase, some pin configurations may be different from
00025   *           their �reset state� configuration.
00026   *           
00027   *           The NRST pin is an input and can be configured as open-drain output
00028   *           using the RST_GPOutputEnable() function 
00029   *
00030   *  @endverbatim
00031   *    
00032   ******************************************************************************
00033   * @attention
00034   *
00035   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00036   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00037   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00038   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00039   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00040   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00041   *
00042   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
00043   ******************************************************************************  
00044   */
00045 
00046 /* Includes ------------------------------------------------------------------*/
00047 
00048 #include "stm8l15x_rst.h"
00049 
00050 /** @addtogroup STM8L15x_StdPeriph_Driver
00051   * @{
00052   */
00053 
00054 /** @defgroup RST 
00055   * @brief RST driver modules
00056   * @{
00057   */ 
00058 /* Private define ------------------------------------------------------------*/
00059 #define RST_CR_MASK  0xD0 /*!< Enable the GPIO */
00060 /* Private macro -------------------------------------------------------------*/
00061 /* Private variables ---------------------------------------------------------*/
00062 /* Private function prototypes -----------------------------------------------*/
00063 /* Private functions ---------------------------------------------------------*/
00064 
00065 /** @defgroup RST_Private_Functions
00066   * @{
00067   */
00068 
00069 /** @defgroup RST_Group1 Flag management functions
00070  *  @brief   Flag management functions 
00071  *
00072 @verbatim   
00073  ===============================================================================
00074                        Flag management functions
00075  ===============================================================================  
00076 
00077 @endverbatim
00078   * @{
00079   */
00080 
00081 /**
00082   * @brief   Checks whether the specified RST flag is set or not.
00083   * @param   RST_Flag : specify the reset flag to check.
00084   *          This parameter can be one of the following values:
00085   *            @arg RST_FLAG_PORF: POR reset flag
00086   *            @arg RST_FLAG_SWIMF: SWIM reset flag
00087   *            @arg RST_FLAG_ILLOPF: Illegal opcode reset flag
00088   *            @arg RST_FLAG_IWDGF: Independent watchdog reset flag 
00089   *            @arg RST_FLAG_WWDGF: Window watchdog reset flag
00090   *            @arg RST_FLAG_BORF: BOR reset flag
00091   * @retval The new state of RST_Flag (SET or RESET).
00092   */
00093 FlagStatus RST_GetFlagStatus(RST_FLAG_TypeDef RST_Flag)
00094 {
00095   /* Check the parameters */
00096   assert_param(IS_RST_FLAG(RST_Flag));
00097 
00098   /* Get flag status */
00099 
00100   return ((FlagStatus)((uint8_t)RST->SR & (uint8_t)RST_Flag));
00101 }
00102 
00103 /**
00104   * @brief  Clears the specified RST flag.
00105   * @param   RST_Flag : specify the reset flag to check.
00106   *          This parameter can be one of the following values:
00107   *            @arg RST_FLAG_PORF: POR reset flag
00108   *            @arg RST_FLAG_SWIMF: SWIM reset flag
00109   *            @arg RST_FLAG_ILLOPF: Illegal opcode reset flag
00110   *            @arg RST_FLAG_IWDGF: Independent watchdog reset flag 
00111   *            @arg RST_FLAG_WWDGF: Window watchdog reset flag
00112   *            @arg RST_FLAG_BORF: BOR reset flag
00113   * @retval None
00114   */
00115 void RST_ClearFlag(RST_FLAG_TypeDef RST_Flag)
00116 {
00117   /* Check the parameters */
00118   assert_param(IS_RST_FLAG(RST_Flag));
00119 
00120   RST->SR = (uint8_t)RST_Flag;
00121 }
00122 
00123 /**
00124   * @}
00125   */
00126   
00127 /** @defgroup RST_Group2 NRST Pin configuration function
00128  *  @brief   NRST Pin configuration function 
00129  *
00130 @verbatim   
00131  ===============================================================================
00132                       NRST Pin configuration function
00133  ===============================================================================  
00134 
00135 @endverbatim
00136   * @{
00137   */
00138   
00139 /**
00140   * @brief  Configures the reset pad as GP output.
00141   * @param  None
00142   * @retval None
00143   */
00144 void RST_GPOutputEnable(void)
00145 {
00146 
00147   RST->CR = RST_CR_MASK;
00148 }
00149 
00150 /**
00151   * @}
00152   */
00153 
00154 /**
00155   * @}
00156   */
00157   
00158 /**
00159   * @}
00160   */
00161 
00162 /**
00163   * @}
00164   */
00165 
00166 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com