mbed library sources modified for open wear

Dependents:   openwear-lifelogger-example

Fork of mbed-src by mbed official

Committer:
janekm
Date:
Tue Sep 16 22:42:01 2014 +0000
Revision:
310:6188e0254baa
Parent:
237:f3da66175598
N/A

Who changed what in which revision?

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