Files
@ de42eee9f86f
Branch filter:
Location: therm/libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_iwdg.c - annotation
de42eee9f86f
10.8 KiB
text/plain
Add cube generated init and usb files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 be6c0feb9b98 | /**
******************************************************************************
* @file stm32f0xx_iwdg.c
* @author MCD Application Team
* @version V1.4.0
* @date 24-July-2014
* @brief This file provides firmware functions to manage the following
* functionalities of the Independent watchdog (IWDG) peripheral:
* + Prescaler and Counter configuration
* + IWDG activation
* + Flag management
*
* @verbatim
*
==============================================================================
##### IWDG features #####
==============================================================================
[..] The IWDG can be started by either software or hardware (configurable
through option byte).
[..] The IWDG is clocked by its own dedicated low-speed clock (LSI) and
thus stays active even if the main clock fails.
Once the IWDG is started, the LSI is forced ON and cannot be disabled
(LSI cannot be disabled too), and the counter starts counting down from
the reset value of 0xFFF. When it reaches the end of count value (0x000)
a system reset is generated.
The IWDG counter should be reloaded at regular intervals to prevent
an MCU reset.
[..] The IWDG is implemented in the VDD voltage domain that is still functional
in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY).
[..] IWDGRST flag in RCC_CSR register can be used to inform when a IWDG
reset occurs.
[..] Min-max timeout value @40KHz (LSI): ~0.1ms / ~28.3s
The IWDG timeout may vary due to LSI frequency dispersion. STM32F0xx
devices provide the capability to measure the LSI frequency (LSI clock
should be seleted as RTC clock which is internally connected to TIM10 CH1
input capture). The measured value can be used to have an IWDG timeout with
an acceptable accuracy.
For more information, please refer to the STM32F0xx Reference manual.
##### How to use this driver #####
==============================================================================
[..] This driver allows to use IWDG peripheral with either window option enabled
or disabled. To do so follow one of the two procedures below.
(#) Window option is enabled:
(++) Start the IWDG using IWDG_Enable() function, when the IWDG is used
in software mode (no need to enable the LSI, it will be enabled
by hardware).
(++) Enable write access to IWDG_PR and IWDG_RLR registers using
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) function.
(++) Configure the IWDG prescaler using IWDG_SetPrescaler() function.
(++) Configure the IWDG counter value using IWDG_SetReload() function.
This value will be loaded in the IWDG counter each time the counter
is reloaded, then the IWDG will start counting down from this value.
(++) Wait for the IWDG registers to be updated using IWDG_GetFlagStatus() function.
(++) Configure the IWDG refresh window using IWDG_SetWindowValue() function.
(#) Window option is disabled:
(++) Enable write access to IWDG_PR and IWDG_RLR registers using
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) function.
(++) Configure the IWDG prescaler using IWDG_SetPrescaler() function.
(++) Configure the IWDG counter value using IWDG_SetReload() function.
This value will be loaded in the IWDG counter each time the counter
is reloaded, then the IWDG will start counting down from this value.
(++) Wait for the IWDG registers to be updated using IWDG_GetFlagStatus() function.
(++) reload the IWDG counter at regular intervals during normal operation
to prevent an MCU reset, using IWDG_ReloadCounter() function.
(++) Start the IWDG using IWDG_Enable() function, when the IWDG is used
in software mode (no need to enable the LSI, it will be enabled
by hardware).
@endverbatim
*
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_iwdg.h"
/** @addtogroup STM32F0xx_StdPeriph_Driver
* @{
*/
/** @defgroup IWDG
* @brief IWDG driver modules
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* ---------------------- IWDG registers bit mask ----------------------------*/
/* KR register bit mask */
#define KR_KEY_RELOAD ((uint16_t)0xAAAA)
#define KR_KEY_ENABLE ((uint16_t)0xCCCC)
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/** @defgroup IWDG_Private_Functions
* @{
*/
/** @defgroup IWDG_Group1 Prescaler and Counter configuration functions
* @brief Prescaler and Counter configuration functions
*
@verbatim
==============================================================================
##### Prescaler and Counter configuration functions #####
==============================================================================
@endverbatim
* @{
*/
/**
* @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers.
* @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers.
* This parameter can be one of the following values:
* @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers
* @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers
* @retval None
*/
void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
{
/* Check the parameters */
assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess));
IWDG->KR = IWDG_WriteAccess;
}
/**
* @brief Sets IWDG Prescaler value.
* @param IWDG_Prescaler: specifies the IWDG Prescaler value.
* This parameter can be one of the following values:
* @arg IWDG_Prescaler_4: IWDG prescaler set to 4
* @arg IWDG_Prescaler_8: IWDG prescaler set to 8
* @arg IWDG_Prescaler_16: IWDG prescaler set to 16
* @arg IWDG_Prescaler_32: IWDG prescaler set to 32
* @arg IWDG_Prescaler_64: IWDG prescaler set to 64
* @arg IWDG_Prescaler_128: IWDG prescaler set to 128
* @arg IWDG_Prescaler_256: IWDG prescaler set to 256
* @retval None
*/
void IWDG_SetPrescaler(uint8_t IWDG_Prescaler)
{
/* Check the parameters */
assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler));
IWDG->PR = IWDG_Prescaler;
}
/**
* @brief Sets IWDG Reload value.
* @param Reload: specifies the IWDG Reload value.
* This parameter must be a number between 0 and 0x0FFF.
* @retval None
*/
void IWDG_SetReload(uint16_t Reload)
{
/* Check the parameters */
assert_param(IS_IWDG_RELOAD(Reload));
IWDG->RLR = Reload;
}
/**
* @brief Reloads IWDG counter with value defined in the reload register
* (write access to IWDG_PR and IWDG_RLR registers disabled).
* @param None
* @retval None
*/
void IWDG_ReloadCounter(void)
{
IWDG->KR = KR_KEY_RELOAD;
}
/**
* @brief Sets the IWDG window value.
* @param WindowValue: specifies the window value to be compared to the downcounter.
* @retval None
*/
void IWDG_SetWindowValue(uint16_t WindowValue)
{
/* Check the parameters */
assert_param(IS_IWDG_WINDOW_VALUE(WindowValue));
IWDG->WINR = WindowValue;
}
/**
* @}
*/
/** @defgroup IWDG_Group2 IWDG activation function
* @brief IWDG activation function
*
@verbatim
==============================================================================
##### IWDG activation function #####
==============================================================================
@endverbatim
* @{
*/
/**
* @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled).
* @param None
* @retval None
*/
void IWDG_Enable(void)
{
IWDG->KR = KR_KEY_ENABLE;
}
/**
* @}
*/
/** @defgroup IWDG_Group3 Flag management function
* @brief Flag management function
*
@verbatim
===============================================================================
##### Flag management function #####
===============================================================================
@endverbatim
* @{
*/
/**
* @brief Checks whether the specified IWDG flag is set or not.
* @param IWDG_FLAG: specifies the flag to check.
* This parameter can be one of the following values:
* @arg IWDG_FLAG_PVU: Prescaler Value Update on going
* @arg IWDG_FLAG_RVU: Reload Value Update on going
* @arg IWDG_FLAG_WVU: Counter Window Value Update on going
* @retval The new state of IWDG_FLAG (SET or RESET).
*/
FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
{
FlagStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_IWDG_FLAG(IWDG_FLAG));
if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
/* Return the flag status */
return bitstatus;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|