mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
yusuke_kyo
Date:
Wed Apr 08 08:04:18 2015 +0000
Revision:
98:01a414ca7d6d
Parent:
96:487b796308b0
remove SerialHalfDuplex.h

Who changed what in which revision?

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