version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon May 19 18:14:09 2014 +0100
Revision:
84:0b3ab51c8877
Release 84 of the mbed library

Main changes:

- added LPC11U68 to the official build
- Bug fixes and new features for ST Nucleo boards
- I2C fixes for Freescale targets
- Added nRF51822 exporters

Who changed what in which revision?

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