marcus chiou / mbed-src

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu Mar 12 14:30:49 2015 +0000
Revision:
489:119543c9f674
Synchronized with git revision 051854181516992fb498d51f9ee6e70cbad9e083

Full URL: https://github.com/mbedmicro/mbed/commit/051854181516992fb498d51f9ee6e70cbad9e083/

Fix ksdk mcu HAL - stopbit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 489:119543c9f674 1 /**
mbed_official 489:119543c9f674 2 ******************************************************************************
mbed_official 489:119543c9f674 3 * @file stm32f1xx_hal_iwdg.h
mbed_official 489:119543c9f674 4 * @author MCD Application Team
mbed_official 489:119543c9f674 5 * @version V1.0.0
mbed_official 489:119543c9f674 6 * @date 15-December-2014
mbed_official 489:119543c9f674 7 * @brief Header file of IWDG HAL module.
mbed_official 489:119543c9f674 8 ******************************************************************************
mbed_official 489:119543c9f674 9 * @attention
mbed_official 489:119543c9f674 10 *
mbed_official 489:119543c9f674 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 489:119543c9f674 12 *
mbed_official 489:119543c9f674 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 489:119543c9f674 14 * are permitted provided that the following conditions are met:
mbed_official 489:119543c9f674 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 489:119543c9f674 16 * this list of conditions and the following disclaimer.
mbed_official 489:119543c9f674 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 489:119543c9f674 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 489:119543c9f674 19 * and/or other materials provided with the distribution.
mbed_official 489:119543c9f674 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 489:119543c9f674 21 * may be used to endorse or promote products derived from this software
mbed_official 489:119543c9f674 22 * without specific prior written permission.
mbed_official 489:119543c9f674 23 *
mbed_official 489:119543c9f674 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 489:119543c9f674 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 489:119543c9f674 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 489:119543c9f674 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 489:119543c9f674 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 489:119543c9f674 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 489:119543c9f674 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 489:119543c9f674 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 489:119543c9f674 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 489:119543c9f674 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 489:119543c9f674 34 *
mbed_official 489:119543c9f674 35 ******************************************************************************
mbed_official 489:119543c9f674 36 */
mbed_official 489:119543c9f674 37
mbed_official 489:119543c9f674 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 489:119543c9f674 39 #ifndef __STM32F1xx_HAL_IWDG_H
mbed_official 489:119543c9f674 40 #define __STM32F1xx_HAL_IWDG_H
mbed_official 489:119543c9f674 41
mbed_official 489:119543c9f674 42 #ifdef __cplusplus
mbed_official 489:119543c9f674 43 extern "C" {
mbed_official 489:119543c9f674 44 #endif
mbed_official 489:119543c9f674 45
mbed_official 489:119543c9f674 46 /* Includes ------------------------------------------------------------------*/
mbed_official 489:119543c9f674 47 #include "stm32f1xx_hal_def.h"
mbed_official 489:119543c9f674 48
mbed_official 489:119543c9f674 49 /** @addtogroup STM32F1xx_HAL_Driver
mbed_official 489:119543c9f674 50 * @{
mbed_official 489:119543c9f674 51 */
mbed_official 489:119543c9f674 52
mbed_official 489:119543c9f674 53 /** @addtogroup IWDG
mbed_official 489:119543c9f674 54 * @{
mbed_official 489:119543c9f674 55 */
mbed_official 489:119543c9f674 56
mbed_official 489:119543c9f674 57 /* Exported types ------------------------------------------------------------*/
mbed_official 489:119543c9f674 58
mbed_official 489:119543c9f674 59 /** @defgroup IWDG_Exported_Types IWDG Exported Types
mbed_official 489:119543c9f674 60 * @{
mbed_official 489:119543c9f674 61 */
mbed_official 489:119543c9f674 62
mbed_official 489:119543c9f674 63 /**
mbed_official 489:119543c9f674 64 * @brief IWDG HAL State Structure definition
mbed_official 489:119543c9f674 65 */
mbed_official 489:119543c9f674 66 typedef enum
mbed_official 489:119543c9f674 67 {
mbed_official 489:119543c9f674 68 HAL_IWDG_STATE_RESET = 0x00, /*!< IWDG not yet initialized or disabled */
mbed_official 489:119543c9f674 69 HAL_IWDG_STATE_READY = 0x01, /*!< IWDG initialized and ready for use */
mbed_official 489:119543c9f674 70 HAL_IWDG_STATE_BUSY = 0x02, /*!< IWDG internal process is ongoing */
mbed_official 489:119543c9f674 71 HAL_IWDG_STATE_TIMEOUT = 0x03, /*!< IWDG timeout state */
mbed_official 489:119543c9f674 72 HAL_IWDG_STATE_ERROR = 0x04 /*!< IWDG error state */
mbed_official 489:119543c9f674 73
mbed_official 489:119543c9f674 74 }HAL_IWDG_StateTypeDef;
mbed_official 489:119543c9f674 75
mbed_official 489:119543c9f674 76 /**
mbed_official 489:119543c9f674 77 * @brief IWDG Init structure definition
mbed_official 489:119543c9f674 78 */
mbed_official 489:119543c9f674 79 typedef struct
mbed_official 489:119543c9f674 80 {
mbed_official 489:119543c9f674 81 uint32_t Prescaler; /*!< Select the prescaler of the IWDG.
mbed_official 489:119543c9f674 82 This parameter can be a value of @ref IWDG_Prescaler */
mbed_official 489:119543c9f674 83
mbed_official 489:119543c9f674 84 uint32_t Reload; /*!< Specifies the IWDG down-counter reload value.
mbed_official 489:119543c9f674 85 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
mbed_official 489:119543c9f674 86
mbed_official 489:119543c9f674 87 }IWDG_InitTypeDef;
mbed_official 489:119543c9f674 88
mbed_official 489:119543c9f674 89 /**
mbed_official 489:119543c9f674 90 * @brief IWDG Handle Structure definition
mbed_official 489:119543c9f674 91 */
mbed_official 489:119543c9f674 92 typedef struct
mbed_official 489:119543c9f674 93 {
mbed_official 489:119543c9f674 94 IWDG_TypeDef *Instance; /*!< Register base address */
mbed_official 489:119543c9f674 95
mbed_official 489:119543c9f674 96 IWDG_InitTypeDef Init; /*!< IWDG required parameters */
mbed_official 489:119543c9f674 97
mbed_official 489:119543c9f674 98 HAL_LockTypeDef Lock; /*!< IWDG Locking object */
mbed_official 489:119543c9f674 99
mbed_official 489:119543c9f674 100 __IO HAL_IWDG_StateTypeDef State; /*!< IWDG communication state */
mbed_official 489:119543c9f674 101
mbed_official 489:119543c9f674 102 }IWDG_HandleTypeDef;
mbed_official 489:119543c9f674 103
mbed_official 489:119543c9f674 104 /**
mbed_official 489:119543c9f674 105 * @}
mbed_official 489:119543c9f674 106 */
mbed_official 489:119543c9f674 107
mbed_official 489:119543c9f674 108 /* Exported constants --------------------------------------------------------*/
mbed_official 489:119543c9f674 109
mbed_official 489:119543c9f674 110 /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
mbed_official 489:119543c9f674 111 * @{
mbed_official 489:119543c9f674 112 */
mbed_official 489:119543c9f674 113
mbed_official 489:119543c9f674 114 /** @defgroup IWDG_Registers_BitMask IWDG Registers BitMask
mbed_official 489:119543c9f674 115 * @brief IWDG registers bit mask
mbed_official 489:119543c9f674 116 * @{
mbed_official 489:119543c9f674 117 */
mbed_official 489:119543c9f674 118 /* --- KR Register ---*/
mbed_official 489:119543c9f674 119 /* KR register bit mask */
mbed_official 489:119543c9f674 120 #define IWDG_KEY_RELOAD ((uint32_t)0xAAAA) /*!< IWDG Reload Counter Enable */
mbed_official 489:119543c9f674 121 #define IWDG_KEY_ENABLE ((uint32_t)0xCCCC) /*!< IWDG Peripheral Enable */
mbed_official 489:119543c9f674 122 #define IWDG_KEY_WRITE_ACCESS_ENABLE ((uint32_t)0x5555) /*!< IWDG KR Write Access Enable */
mbed_official 489:119543c9f674 123 #define IWDG_KEY_WRITE_ACCESS_DISABLE ((uint32_t)0x0000) /*!< IWDG KR Write Access Disable */
mbed_official 489:119543c9f674 124
mbed_official 489:119543c9f674 125 /**
mbed_official 489:119543c9f674 126 * @}
mbed_official 489:119543c9f674 127 */
mbed_official 489:119543c9f674 128
mbed_official 489:119543c9f674 129 /** @defgroup IWDG_Flag_definition IWDG Flag definition
mbed_official 489:119543c9f674 130 * @{
mbed_official 489:119543c9f674 131 */
mbed_official 489:119543c9f674 132 #define IWDG_FLAG_PVU ((uint32_t)IWDG_SR_PVU) /*!< Watchdog counter prescaler value update Flag */
mbed_official 489:119543c9f674 133 #define IWDG_FLAG_RVU ((uint32_t)IWDG_SR_RVU) /*!< Watchdog counter reload value update Flag */
mbed_official 489:119543c9f674 134
mbed_official 489:119543c9f674 135 /**
mbed_official 489:119543c9f674 136 * @}
mbed_official 489:119543c9f674 137 */
mbed_official 489:119543c9f674 138
mbed_official 489:119543c9f674 139 /** @defgroup IWDG_Prescaler IWDG Prescaler
mbed_official 489:119543c9f674 140 * @{
mbed_official 489:119543c9f674 141 */
mbed_official 489:119543c9f674 142 #define IWDG_PRESCALER_4 ((uint8_t)0x00) /*!< IWDG prescaler set to 4 */
mbed_official 489:119543c9f674 143 #define IWDG_PRESCALER_8 ((uint8_t)(IWDG_PR_PR_0)) /*!< IWDG prescaler set to 8 */
mbed_official 489:119543c9f674 144 #define IWDG_PRESCALER_16 ((uint8_t)(IWDG_PR_PR_1)) /*!< IWDG prescaler set to 16 */
mbed_official 489:119543c9f674 145 #define IWDG_PRESCALER_32 ((uint8_t)(IWDG_PR_PR_1 | IWDG_PR_PR_0)) /*!< IWDG prescaler set to 32 */
mbed_official 489:119543c9f674 146 #define IWDG_PRESCALER_64 ((uint8_t)(IWDG_PR_PR_2)) /*!< IWDG prescaler set to 64 */
mbed_official 489:119543c9f674 147 #define IWDG_PRESCALER_128 ((uint8_t)(IWDG_PR_PR_2 | IWDG_PR_PR_0)) /*!< IWDG prescaler set to 128 */
mbed_official 489:119543c9f674 148 #define IWDG_PRESCALER_256 ((uint8_t)(IWDG_PR_PR_2 | IWDG_PR_PR_1)) /*!< IWDG prescaler set to 256 */
mbed_official 489:119543c9f674 149
mbed_official 489:119543c9f674 150 /**
mbed_official 489:119543c9f674 151 * @}
mbed_official 489:119543c9f674 152 */
mbed_official 489:119543c9f674 153
mbed_official 489:119543c9f674 154
mbed_official 489:119543c9f674 155 /**
mbed_official 489:119543c9f674 156 * @}
mbed_official 489:119543c9f674 157 */
mbed_official 489:119543c9f674 158
mbed_official 489:119543c9f674 159 /* Exported macros -----------------------------------------------------------*/
mbed_official 489:119543c9f674 160
mbed_official 489:119543c9f674 161 /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
mbed_official 489:119543c9f674 162 * @{
mbed_official 489:119543c9f674 163 */
mbed_official 489:119543c9f674 164
mbed_official 489:119543c9f674 165 /** @brief Reset IWDG handle state
mbed_official 489:119543c9f674 166 * @param __HANDLE__: IWDG handle.
mbed_official 489:119543c9f674 167 * @retval None
mbed_official 489:119543c9f674 168 */
mbed_official 489:119543c9f674 169 #define __HAL_IWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IWDG_STATE_RESET)
mbed_official 489:119543c9f674 170
mbed_official 489:119543c9f674 171 /**
mbed_official 489:119543c9f674 172 * @brief Enables the IWDG peripheral.
mbed_official 489:119543c9f674 173 * @param __HANDLE__: IWDG handle
mbed_official 489:119543c9f674 174 * @retval None
mbed_official 489:119543c9f674 175 */
mbed_official 489:119543c9f674 176 #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
mbed_official 489:119543c9f674 177
mbed_official 489:119543c9f674 178 /**
mbed_official 489:119543c9f674 179 * @brief Reloads IWDG counter with value defined in the reload register
mbed_official 489:119543c9f674 180 * (write access to IWDG_PR and IWDG_RLR registers disabled).
mbed_official 489:119543c9f674 181 * @param __HANDLE__: IWDG handle
mbed_official 489:119543c9f674 182 * @retval None
mbed_official 489:119543c9f674 183 */
mbed_official 489:119543c9f674 184 #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
mbed_official 489:119543c9f674 185
mbed_official 489:119543c9f674 186
mbed_official 489:119543c9f674 187
mbed_official 489:119543c9f674 188 /**
mbed_official 489:119543c9f674 189 * @brief Gets the selected IWDG's flag status.
mbed_official 489:119543c9f674 190 * @param __HANDLE__: IWDG handle
mbed_official 489:119543c9f674 191 * @param __FLAG__: specifies the flag to check.
mbed_official 489:119543c9f674 192 * This parameter can be one of the following values:
mbed_official 489:119543c9f674 193 * @arg IWDG_FLAG_PVU: Watchdog counter reload value update flag
mbed_official 489:119543c9f674 194 * @arg IWDG_FLAG_RVU: Watchdog counter prescaler value flag
mbed_official 489:119543c9f674 195 * @retval The new state of __FLAG__ (TRUE or FALSE).
mbed_official 489:119543c9f674 196 */
mbed_official 489:119543c9f674 197 #define __HAL_IWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
mbed_official 489:119543c9f674 198
mbed_official 489:119543c9f674 199 /**
mbed_official 489:119543c9f674 200 * @}
mbed_official 489:119543c9f674 201 */
mbed_official 489:119543c9f674 202
mbed_official 489:119543c9f674 203 /* Private macro -------------------------------------------------------------*/
mbed_official 489:119543c9f674 204
mbed_official 489:119543c9f674 205 /** @defgroup IWDG_Private_Macros IWDG Private Macros
mbed_official 489:119543c9f674 206 * @{
mbed_official 489:119543c9f674 207 */
mbed_official 489:119543c9f674 208
mbed_official 489:119543c9f674 209
mbed_official 489:119543c9f674 210 /**
mbed_official 489:119543c9f674 211 * @brief Enables write access to IWDG_PR and IWDG_RLR registers.
mbed_official 489:119543c9f674 212 * @param __HANDLE__: IWDG handle
mbed_official 489:119543c9f674 213 * @retval None
mbed_official 489:119543c9f674 214 */
mbed_official 489:119543c9f674 215 #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
mbed_official 489:119543c9f674 216
mbed_official 489:119543c9f674 217 /**
mbed_official 489:119543c9f674 218 * @brief Disables write access to IWDG_PR and IWDG_RLR registers.
mbed_official 489:119543c9f674 219 * @param __HANDLE__: IWDG handle
mbed_official 489:119543c9f674 220 * @retval None
mbed_official 489:119543c9f674 221 */
mbed_official 489:119543c9f674 222 #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
mbed_official 489:119543c9f674 223
mbed_official 489:119543c9f674 224
mbed_official 489:119543c9f674 225 #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \
mbed_official 489:119543c9f674 226 ((__PRESCALER__) == IWDG_PRESCALER_8) || \
mbed_official 489:119543c9f674 227 ((__PRESCALER__) == IWDG_PRESCALER_16) || \
mbed_official 489:119543c9f674 228 ((__PRESCALER__) == IWDG_PRESCALER_32) || \
mbed_official 489:119543c9f674 229 ((__PRESCALER__) == IWDG_PRESCALER_64) || \
mbed_official 489:119543c9f674 230 ((__PRESCALER__) == IWDG_PRESCALER_128)|| \
mbed_official 489:119543c9f674 231 ((__PRESCALER__) == IWDG_PRESCALER_256))
mbed_official 489:119543c9f674 232
mbed_official 489:119543c9f674 233
mbed_official 489:119543c9f674 234 #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= 0xFFF)
mbed_official 489:119543c9f674 235
mbed_official 489:119543c9f674 236
mbed_official 489:119543c9f674 237 /**
mbed_official 489:119543c9f674 238 * @}
mbed_official 489:119543c9f674 239 */
mbed_official 489:119543c9f674 240
mbed_official 489:119543c9f674 241
mbed_official 489:119543c9f674 242
mbed_official 489:119543c9f674 243 /* Exported functions --------------------------------------------------------*/
mbed_official 489:119543c9f674 244
mbed_official 489:119543c9f674 245 /** @addtogroup IWDG_Exported_Functions
mbed_official 489:119543c9f674 246 * @{
mbed_official 489:119543c9f674 247 */
mbed_official 489:119543c9f674 248
mbed_official 489:119543c9f674 249 /** @addtogroup IWDG_Exported_Functions_Group1
mbed_official 489:119543c9f674 250 * @{
mbed_official 489:119543c9f674 251 */
mbed_official 489:119543c9f674 252 /* Initialization/de-initialization functions ********************************/
mbed_official 489:119543c9f674 253 HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
mbed_official 489:119543c9f674 254 void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg);
mbed_official 489:119543c9f674 255
mbed_official 489:119543c9f674 256 /**
mbed_official 489:119543c9f674 257 * @}
mbed_official 489:119543c9f674 258 */
mbed_official 489:119543c9f674 259
mbed_official 489:119543c9f674 260 /** @addtogroup IWDG_Exported_Functions_Group2
mbed_official 489:119543c9f674 261 * @{
mbed_official 489:119543c9f674 262 */
mbed_official 489:119543c9f674 263 /* I/O operation functions ****************************************************/
mbed_official 489:119543c9f674 264 HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg);
mbed_official 489:119543c9f674 265 HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
mbed_official 489:119543c9f674 266
mbed_official 489:119543c9f674 267 /**
mbed_official 489:119543c9f674 268 * @}
mbed_official 489:119543c9f674 269 */
mbed_official 489:119543c9f674 270
mbed_official 489:119543c9f674 271 /** @addtogroup IWDG_Exported_Functions_Group3
mbed_official 489:119543c9f674 272 * @{
mbed_official 489:119543c9f674 273 */
mbed_official 489:119543c9f674 274 /* Peripheral State functions ************************************************/
mbed_official 489:119543c9f674 275 HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg);
mbed_official 489:119543c9f674 276
mbed_official 489:119543c9f674 277 /**
mbed_official 489:119543c9f674 278 * @}
mbed_official 489:119543c9f674 279 */
mbed_official 489:119543c9f674 280
mbed_official 489:119543c9f674 281 /**
mbed_official 489:119543c9f674 282 * @}
mbed_official 489:119543c9f674 283 */
mbed_official 489:119543c9f674 284
mbed_official 489:119543c9f674 285 /**
mbed_official 489:119543c9f674 286 * @}
mbed_official 489:119543c9f674 287 */
mbed_official 489:119543c9f674 288
mbed_official 489:119543c9f674 289 /**
mbed_official 489:119543c9f674 290 * @}
mbed_official 489:119543c9f674 291 */
mbed_official 489:119543c9f674 292
mbed_official 489:119543c9f674 293 #ifdef __cplusplus
mbed_official 489:119543c9f674 294 }
mbed_official 489:119543c9f674 295 #endif
mbed_official 489:119543c9f674 296
mbed_official 489:119543c9f674 297 #endif /* __STM32F1xx_HAL_IWDG_H */
mbed_official 489:119543c9f674 298
mbed_official 489:119543c9f674 299 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/