Bei Chen Liu / 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.c
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 HAL module driver.
mbed_official 489:119543c9f674 8 * This is the common part of the HAL initialization
mbed_official 489:119543c9f674 9 *
mbed_official 489:119543c9f674 10 @verbatim
mbed_official 489:119543c9f674 11 ==============================================================================
mbed_official 489:119543c9f674 12 ##### How to use this driver #####
mbed_official 489:119543c9f674 13 ==============================================================================
mbed_official 489:119543c9f674 14 [..]
mbed_official 489:119543c9f674 15 The common HAL driver contains a set of generic and common APIs that can be
mbed_official 489:119543c9f674 16 used by the PPP peripheral drivers and the user to start using the HAL.
mbed_official 489:119543c9f674 17 [..]
mbed_official 489:119543c9f674 18 The HAL contains two APIs' categories:
mbed_official 489:119543c9f674 19 (+) Common HAL APIs
mbed_official 489:119543c9f674 20 (+) Services HAL APIs
mbed_official 489:119543c9f674 21
mbed_official 489:119543c9f674 22 @endverbatim
mbed_official 489:119543c9f674 23 ******************************************************************************
mbed_official 489:119543c9f674 24 * @attention
mbed_official 489:119543c9f674 25 *
mbed_official 489:119543c9f674 26 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 489:119543c9f674 27 *
mbed_official 489:119543c9f674 28 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 489:119543c9f674 29 * are permitted provided that the following conditions are met:
mbed_official 489:119543c9f674 30 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 489:119543c9f674 31 * this list of conditions and the following disclaimer.
mbed_official 489:119543c9f674 32 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 489:119543c9f674 33 * this list of conditions and the following disclaimer in the documentation
mbed_official 489:119543c9f674 34 * and/or other materials provided with the distribution.
mbed_official 489:119543c9f674 35 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 489:119543c9f674 36 * may be used to endorse or promote products derived from this software
mbed_official 489:119543c9f674 37 * without specific prior written permission.
mbed_official 489:119543c9f674 38 *
mbed_official 489:119543c9f674 39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 489:119543c9f674 40 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 489:119543c9f674 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 489:119543c9f674 42 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 489:119543c9f674 43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 489:119543c9f674 44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 489:119543c9f674 45 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 489:119543c9f674 46 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 489:119543c9f674 47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 489:119543c9f674 48 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 489:119543c9f674 49 *
mbed_official 489:119543c9f674 50 ******************************************************************************
mbed_official 489:119543c9f674 51 */
mbed_official 489:119543c9f674 52
mbed_official 489:119543c9f674 53 /* Includes ------------------------------------------------------------------*/
mbed_official 489:119543c9f674 54 #include "stm32f1xx_hal.h"
mbed_official 489:119543c9f674 55
mbed_official 489:119543c9f674 56 /** @addtogroup STM32F1xx_HAL_Driver
mbed_official 489:119543c9f674 57 * @{
mbed_official 489:119543c9f674 58 */
mbed_official 489:119543c9f674 59
mbed_official 489:119543c9f674 60 /** @defgroup HAL HAL
mbed_official 489:119543c9f674 61 * @brief HAL module driver.
mbed_official 489:119543c9f674 62 * @{
mbed_official 489:119543c9f674 63 */
mbed_official 489:119543c9f674 64
mbed_official 489:119543c9f674 65 #ifdef HAL_MODULE_ENABLED
mbed_official 489:119543c9f674 66
mbed_official 489:119543c9f674 67 /* Private typedef -----------------------------------------------------------*/
mbed_official 489:119543c9f674 68 /* Private define ------------------------------------------------------------*/
mbed_official 489:119543c9f674 69
mbed_official 489:119543c9f674 70 /** @defgroup HAL_Private_Constants HAL Private Constants
mbed_official 489:119543c9f674 71 * @{
mbed_official 489:119543c9f674 72 */
mbed_official 489:119543c9f674 73
mbed_official 489:119543c9f674 74 /**
mbed_official 489:119543c9f674 75 * @brief STM32F1xx HAL Driver version number V1.0.0
mbed_official 489:119543c9f674 76 */
mbed_official 489:119543c9f674 77 #define __STM32F1xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
mbed_official 489:119543c9f674 78 #define __STM32F1xx_HAL_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
mbed_official 489:119543c9f674 79 #define __STM32F1xx_HAL_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
mbed_official 489:119543c9f674 80 #define __STM32F1xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */
mbed_official 489:119543c9f674 81 #define __STM32F1xx_HAL_VERSION ((__STM32F1xx_HAL_VERSION_MAIN << 24)\
mbed_official 489:119543c9f674 82 |(__STM32F1xx_HAL_VERSION_SUB1 << 16)\
mbed_official 489:119543c9f674 83 |(__STM32F1xx_HAL_VERSION_SUB2 << 8 )\
mbed_official 489:119543c9f674 84 |(__STM32F1xx_HAL_VERSION_RC))
mbed_official 489:119543c9f674 85
mbed_official 489:119543c9f674 86 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
mbed_official 489:119543c9f674 87
mbed_official 489:119543c9f674 88 /**
mbed_official 489:119543c9f674 89 * @}
mbed_official 489:119543c9f674 90 */
mbed_official 489:119543c9f674 91
mbed_official 489:119543c9f674 92 /* Private macro -------------------------------------------------------------*/
mbed_official 489:119543c9f674 93 /* Private variables ---------------------------------------------------------*/
mbed_official 489:119543c9f674 94
mbed_official 489:119543c9f674 95 /** @defgroup HAL_Private_Variables HAL Private Variables
mbed_official 489:119543c9f674 96 * @{
mbed_official 489:119543c9f674 97 */
mbed_official 489:119543c9f674 98
mbed_official 489:119543c9f674 99 static __IO uint32_t uwTick;
mbed_official 489:119543c9f674 100
mbed_official 489:119543c9f674 101 /**
mbed_official 489:119543c9f674 102 * @}
mbed_official 489:119543c9f674 103 */
mbed_official 489:119543c9f674 104
mbed_official 489:119543c9f674 105 /* Private function prototypes -----------------------------------------------*/
mbed_official 489:119543c9f674 106 /* Private functions ---------------------------------------------------------*/
mbed_official 489:119543c9f674 107
mbed_official 489:119543c9f674 108 /** @defgroup HAL_Exported_Functions HAL Exported Functions
mbed_official 489:119543c9f674 109 * @{
mbed_official 489:119543c9f674 110 */
mbed_official 489:119543c9f674 111
mbed_official 489:119543c9f674 112 /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
mbed_official 489:119543c9f674 113 * @brief Initialization and de-initialization functions
mbed_official 489:119543c9f674 114 *
mbed_official 489:119543c9f674 115 @verbatim
mbed_official 489:119543c9f674 116 ===============================================================================
mbed_official 489:119543c9f674 117 ##### Initialization and de-initialization functions #####
mbed_official 489:119543c9f674 118 ===============================================================================
mbed_official 489:119543c9f674 119 [..] This section provides functions allowing to:
mbed_official 489:119543c9f674 120 (+) Initializes the Flash interface, the NVIC allocation and initial clock
mbed_official 489:119543c9f674 121 configuration. It initializes the source of time base also when timeout
mbed_official 489:119543c9f674 122 is needed and the backup domain when enabled.
mbed_official 489:119543c9f674 123 (+) de-Initializes common part of the HAL.
mbed_official 489:119543c9f674 124 (+) Configure The time base source to have 1ms time base with a dedicated
mbed_official 489:119543c9f674 125 Tick interrupt priority.
mbed_official 489:119543c9f674 126 (++) Systick timer is used by default as source of time base, but user
mbed_official 489:119543c9f674 127 can eventually implement his proper time base source (a general purpose
mbed_official 489:119543c9f674 128 timer for example or other time source), keeping in mind that Time base
mbed_official 489:119543c9f674 129 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
mbed_official 489:119543c9f674 130 handled in milliseconds basis.
mbed_official 489:119543c9f674 131 (++) Time base configuration function (HAL_InitTick ()) is called automatically
mbed_official 489:119543c9f674 132 at the beginning of the program after reset by HAL_Init() or at any time
mbed_official 489:119543c9f674 133 when clock is configured, by HAL_RCC_ClockConfig().
mbed_official 489:119543c9f674 134 (++) Source of time base is configured to generate interrupts at regular
mbed_official 489:119543c9f674 135 time intervals. Care must be taken if HAL_Delay() is called from a
mbed_official 489:119543c9f674 136 peripheral ISR process, the Tick interrupt line must have higher priority
mbed_official 489:119543c9f674 137 (numerically lower) than the peripheral interrupt. Otherwise the caller
mbed_official 489:119543c9f674 138 ISR process will be blocked.
mbed_official 489:119543c9f674 139 (++) functions affecting time base configurations are declared as __Weak
mbed_official 489:119543c9f674 140 to make override possible in case of other implementations in user file.
mbed_official 489:119543c9f674 141
mbed_official 489:119543c9f674 142 @endverbatim
mbed_official 489:119543c9f674 143 * @{
mbed_official 489:119543c9f674 144 */
mbed_official 489:119543c9f674 145
mbed_official 489:119543c9f674 146 /**
mbed_official 489:119543c9f674 147 * @brief This function configures the Flash prefetch,
mbed_official 489:119543c9f674 148 * Configures time base source, NVIC and Low level hardware
mbed_official 489:119543c9f674 149 * Note: This function is called at the beginning of program after reset and before
mbed_official 489:119543c9f674 150 * the clock configuration
mbed_official 489:119543c9f674 151 * Note: The time base configuration is based on MSI clock when exiting from Reset.
mbed_official 489:119543c9f674 152 * Once done, time base tick start incrementing.
mbed_official 489:119543c9f674 153 * In the default implementation,Systick is used as source of time base.
mbed_official 489:119543c9f674 154 * the tick variable is incremented each 1ms in its ISR.
mbed_official 489:119543c9f674 155 * @retval HAL status
mbed_official 489:119543c9f674 156 */
mbed_official 489:119543c9f674 157 HAL_StatusTypeDef HAL_Init(void)
mbed_official 489:119543c9f674 158 {
mbed_official 489:119543c9f674 159 /* Configure Flash prefetch */
mbed_official 489:119543c9f674 160 #if (PREFETCH_ENABLE != 0)
mbed_official 489:119543c9f674 161 #if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || \
mbed_official 489:119543c9f674 162 defined(STM32F102x6) || defined(STM32F102xB) || \
mbed_official 489:119543c9f674 163 defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || \
mbed_official 489:119543c9f674 164 defined(STM32F105xC) || defined(STM32F107xC)
mbed_official 489:119543c9f674 165
mbed_official 489:119543c9f674 166 /* Prefetch buffer is not available on value line devices */
mbed_official 489:119543c9f674 167 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
mbed_official 489:119543c9f674 168 #endif
mbed_official 489:119543c9f674 169 #endif /* PREFETCH_ENABLE */
mbed_official 489:119543c9f674 170
mbed_official 489:119543c9f674 171 /* Set Interrupt Group Priority */
mbed_official 489:119543c9f674 172 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
mbed_official 489:119543c9f674 173
mbed_official 489:119543c9f674 174 /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */
mbed_official 489:119543c9f674 175 HAL_InitTick(TICK_INT_PRIORITY);
mbed_official 489:119543c9f674 176
mbed_official 489:119543c9f674 177 /* Init the low level hardware */
mbed_official 489:119543c9f674 178 HAL_MspInit();
mbed_official 489:119543c9f674 179
mbed_official 489:119543c9f674 180 /* Return function status */
mbed_official 489:119543c9f674 181 return HAL_OK;
mbed_official 489:119543c9f674 182 }
mbed_official 489:119543c9f674 183
mbed_official 489:119543c9f674 184 /**
mbed_official 489:119543c9f674 185 * @brief This function de-Initializes common part of the HAL and stops the source
mbed_official 489:119543c9f674 186 * of time base.
mbed_official 489:119543c9f674 187 * Note: This function is optional.
mbed_official 489:119543c9f674 188 * @retval HAL status
mbed_official 489:119543c9f674 189 */
mbed_official 489:119543c9f674 190 HAL_StatusTypeDef HAL_DeInit(void)
mbed_official 489:119543c9f674 191 {
mbed_official 489:119543c9f674 192 /* Reset of all peripherals */
mbed_official 489:119543c9f674 193 __HAL_RCC_APB1_FORCE_RESET();
mbed_official 489:119543c9f674 194 __HAL_RCC_APB1_RELEASE_RESET();
mbed_official 489:119543c9f674 195
mbed_official 489:119543c9f674 196 __HAL_RCC_APB2_FORCE_RESET();
mbed_official 489:119543c9f674 197 __HAL_RCC_APB2_RELEASE_RESET();
mbed_official 489:119543c9f674 198
mbed_official 489:119543c9f674 199 #if defined(STM32F105xC) || defined(STM32F107xC)
mbed_official 489:119543c9f674 200 __HAL_RCC_AHB_FORCE_RESET();
mbed_official 489:119543c9f674 201 __HAL_RCC_AHB_RELEASE_RESET();
mbed_official 489:119543c9f674 202 #endif
mbed_official 489:119543c9f674 203
mbed_official 489:119543c9f674 204 /* De-Init the low level hardware */
mbed_official 489:119543c9f674 205 HAL_MspDeInit();
mbed_official 489:119543c9f674 206
mbed_official 489:119543c9f674 207 /* Return function status */
mbed_official 489:119543c9f674 208 return HAL_OK;
mbed_official 489:119543c9f674 209 }
mbed_official 489:119543c9f674 210
mbed_official 489:119543c9f674 211 /**
mbed_official 489:119543c9f674 212 * @brief Initializes the MSP.
mbed_official 489:119543c9f674 213 * @retval None
mbed_official 489:119543c9f674 214 */
mbed_official 489:119543c9f674 215 __weak void HAL_MspInit(void)
mbed_official 489:119543c9f674 216 {
mbed_official 489:119543c9f674 217 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 489:119543c9f674 218 the HAL_MspInit could be implemented in the user file
mbed_official 489:119543c9f674 219 */
mbed_official 489:119543c9f674 220 }
mbed_official 489:119543c9f674 221
mbed_official 489:119543c9f674 222 /**
mbed_official 489:119543c9f674 223 * @brief DeInitializes the MSP.
mbed_official 489:119543c9f674 224 * @retval None
mbed_official 489:119543c9f674 225 */
mbed_official 489:119543c9f674 226 __weak void HAL_MspDeInit(void)
mbed_official 489:119543c9f674 227 {
mbed_official 489:119543c9f674 228 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 489:119543c9f674 229 the HAL_MspDeInit could be implemented in the user file
mbed_official 489:119543c9f674 230 */
mbed_official 489:119543c9f674 231 }
mbed_official 489:119543c9f674 232
mbed_official 489:119543c9f674 233 /**
mbed_official 489:119543c9f674 234 * @brief This function configures the source of the time base.
mbed_official 489:119543c9f674 235 * The time source is configured to have 1ms time base with a dedicated
mbed_official 489:119543c9f674 236 * Tick interrupt priority.
mbed_official 489:119543c9f674 237 * Note: This function is called automatically at the beginning of program after
mbed_official 489:119543c9f674 238 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
mbed_official 489:119543c9f674 239 * Note: In the default implementation, SysTick timer is the source of time base.
mbed_official 489:119543c9f674 240 * It is used to generate interrupts at regular time intervals.
mbed_official 489:119543c9f674 241 * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
mbed_official 489:119543c9f674 242 * The the SysTick interrupt must have higher priority (numerically lower)
mbed_official 489:119543c9f674 243 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
mbed_official 489:119543c9f674 244 * The function is declared as __Weak to be overwritten in case of other
mbed_official 489:119543c9f674 245 * implementation in user file.
mbed_official 489:119543c9f674 246 * @param TickPriority: Tick interrupt priority.
mbed_official 489:119543c9f674 247 * @retval HAL status
mbed_official 489:119543c9f674 248 */
mbed_official 489:119543c9f674 249 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
mbed_official 489:119543c9f674 250 {
mbed_official 489:119543c9f674 251 /*Configure the SysTick to have interrupt in 1ms time basis*/
mbed_official 489:119543c9f674 252 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
mbed_official 489:119543c9f674 253
mbed_official 489:119543c9f674 254 /*Configure the SysTick IRQ priority */
mbed_official 489:119543c9f674 255 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
mbed_official 489:119543c9f674 256
mbed_official 489:119543c9f674 257 /* Return function status */
mbed_official 489:119543c9f674 258 return HAL_OK;
mbed_official 489:119543c9f674 259 }
mbed_official 489:119543c9f674 260
mbed_official 489:119543c9f674 261 /**
mbed_official 489:119543c9f674 262 * @}
mbed_official 489:119543c9f674 263 */
mbed_official 489:119543c9f674 264
mbed_official 489:119543c9f674 265 /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
mbed_official 489:119543c9f674 266 * @brief HAL Control functions
mbed_official 489:119543c9f674 267 *
mbed_official 489:119543c9f674 268 @verbatim
mbed_official 489:119543c9f674 269 ===============================================================================
mbed_official 489:119543c9f674 270 ##### HAL Control functions #####
mbed_official 489:119543c9f674 271 ===============================================================================
mbed_official 489:119543c9f674 272 [..] This section provides functions allowing to:
mbed_official 489:119543c9f674 273 (+) Provide a tick value in millisecond
mbed_official 489:119543c9f674 274 (+) Provide a blocking delay in millisecond
mbed_official 489:119543c9f674 275 (+) Suspend the time base source interrupt
mbed_official 489:119543c9f674 276 (+) Resume the time base source interrupt
mbed_official 489:119543c9f674 277 (+) Get the HAL API driver version
mbed_official 489:119543c9f674 278 (+) Get the device identifier
mbed_official 489:119543c9f674 279 (+) Get the device revision identifier
mbed_official 489:119543c9f674 280 (+) Enable/Disable Debug module during Sleep mode
mbed_official 489:119543c9f674 281 (+) Enable/Disable Debug module during STOP mode
mbed_official 489:119543c9f674 282 (+) Enable/Disable Debug module during STANDBY mode
mbed_official 489:119543c9f674 283
mbed_official 489:119543c9f674 284 @endverbatim
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 * @brief This function is called to increment a global variable "uwTick"
mbed_official 489:119543c9f674 290 * used as application time base.
mbed_official 489:119543c9f674 291 * Note: In the default implementation, this variable is incremented each 1ms
mbed_official 489:119543c9f674 292 * in Systick ISR.
mbed_official 489:119543c9f674 293 * Note: This function is declared as __weak to be overwritten in case of other
mbed_official 489:119543c9f674 294 * implementations in user file.
mbed_official 489:119543c9f674 295 * @retval None
mbed_official 489:119543c9f674 296 */
mbed_official 489:119543c9f674 297 __weak void HAL_IncTick(void)
mbed_official 489:119543c9f674 298 {
mbed_official 489:119543c9f674 299 uwTick++;
mbed_official 489:119543c9f674 300 }
mbed_official 489:119543c9f674 301
mbed_official 489:119543c9f674 302 /**
mbed_official 489:119543c9f674 303 * @brief Provides a tick value in millisecond.
mbed_official 489:119543c9f674 304 * Note: This function is declared as __weak to be overwritten in case of other
mbed_official 489:119543c9f674 305 * implementations in user file.
mbed_official 489:119543c9f674 306 * @retval tick value
mbed_official 489:119543c9f674 307 */
mbed_official 489:119543c9f674 308 __weak uint32_t HAL_GetTick(void)
mbed_official 489:119543c9f674 309 {
mbed_official 489:119543c9f674 310 return uwTick;
mbed_official 489:119543c9f674 311 }
mbed_official 489:119543c9f674 312
mbed_official 489:119543c9f674 313 /**
mbed_official 489:119543c9f674 314 * @brief This function provides accurate delay (in milliseconds) based
mbed_official 489:119543c9f674 315 * on variable incremented.
mbed_official 489:119543c9f674 316 * Note: In the default implementation , SysTick timer is the source of time base.
mbed_official 489:119543c9f674 317 * It is used to generate interrupts at regular time intervals where uwTick
mbed_official 489:119543c9f674 318 * is incremented.
mbed_official 489:119543c9f674 319 * Note: ThiS function is declared as __weak to be overwritten in case of other
mbed_official 489:119543c9f674 320 * implementations in user file.
mbed_official 489:119543c9f674 321 * @param Delay: specifies the delay time length, in milliseconds.
mbed_official 489:119543c9f674 322 * @retval None
mbed_official 489:119543c9f674 323 */
mbed_official 489:119543c9f674 324 __weak void HAL_Delay(__IO uint32_t Delay)
mbed_official 489:119543c9f674 325 {
mbed_official 489:119543c9f674 326 uint32_t tickstart = 0;
mbed_official 489:119543c9f674 327 tickstart = HAL_GetTick();
mbed_official 489:119543c9f674 328 while((HAL_GetTick() - tickstart) < Delay)
mbed_official 489:119543c9f674 329 {
mbed_official 489:119543c9f674 330 }
mbed_official 489:119543c9f674 331 }
mbed_official 489:119543c9f674 332
mbed_official 489:119543c9f674 333 /**
mbed_official 489:119543c9f674 334 * @brief Suspend Tick increment.
mbed_official 489:119543c9f674 335 * Note: In the default implementation , SysTick timer is the source of time base. It is
mbed_official 489:119543c9f674 336 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
mbed_official 489:119543c9f674 337 * is called, the the SysTick interrupt will be disabled and so Tick increment
mbed_official 489:119543c9f674 338 * is suspended.
mbed_official 489:119543c9f674 339 * Note: This function is declared as __weak to be overwritten in case of other
mbed_official 489:119543c9f674 340 * implementations in user file.
mbed_official 489:119543c9f674 341 * @retval None
mbed_official 489:119543c9f674 342 */
mbed_official 489:119543c9f674 343 __weak void HAL_SuspendTick(void)
mbed_official 489:119543c9f674 344 {
mbed_official 489:119543c9f674 345 /* Disable SysTick Interrupt */
mbed_official 489:119543c9f674 346 CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
mbed_official 489:119543c9f674 347 }
mbed_official 489:119543c9f674 348
mbed_official 489:119543c9f674 349 /**
mbed_official 489:119543c9f674 350 * @brief Resume Tick increment.
mbed_official 489:119543c9f674 351 * Note: In the default implementation , SysTick timer is the source of time base. It is
mbed_official 489:119543c9f674 352 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
mbed_official 489:119543c9f674 353 * is called, the the SysTick interrupt will be enabled and so Tick increment
mbed_official 489:119543c9f674 354 * is resumed.
mbed_official 489:119543c9f674 355 * Note: This function is declared as __weak to be overwritten in case of other
mbed_official 489:119543c9f674 356 * implementations in user file.
mbed_official 489:119543c9f674 357 * @retval None
mbed_official 489:119543c9f674 358 */
mbed_official 489:119543c9f674 359 __weak void HAL_ResumeTick(void)
mbed_official 489:119543c9f674 360 {
mbed_official 489:119543c9f674 361 /* Enable SysTick Interrupt */
mbed_official 489:119543c9f674 362 SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
mbed_official 489:119543c9f674 363 }
mbed_official 489:119543c9f674 364
mbed_official 489:119543c9f674 365 /**
mbed_official 489:119543c9f674 366 * @brief Returns the HAL revision
mbed_official 489:119543c9f674 367 * @retval version: 0xXYZR (8bits for each decimal, R for RC)
mbed_official 489:119543c9f674 368 */
mbed_official 489:119543c9f674 369 uint32_t HAL_GetHalVersion(void)
mbed_official 489:119543c9f674 370 {
mbed_official 489:119543c9f674 371 return __STM32F1xx_HAL_VERSION;
mbed_official 489:119543c9f674 372 }
mbed_official 489:119543c9f674 373
mbed_official 489:119543c9f674 374 /**
mbed_official 489:119543c9f674 375 * @brief Returns the device revision identifier.
mbed_official 489:119543c9f674 376 * Note: On devices STM32F10xx8 and STM32F10xxB,
mbed_official 489:119543c9f674 377 * STM32F101xC/D/E and STM32F103xC/D/E,
mbed_official 489:119543c9f674 378 * STM32F101xF/G and STM32F103xF/G
mbed_official 489:119543c9f674 379 * STM32F10xx4 and STM32F10xx6
mbed_official 489:119543c9f674 380 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
mbed_official 489:119543c9f674 381 * debug mode (not accessible by the user software in normal mode).
mbed_official 489:119543c9f674 382 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 383 * @retval Device revision identifier
mbed_official 489:119543c9f674 384 */
mbed_official 489:119543c9f674 385 uint32_t HAL_GetREVID(void)
mbed_official 489:119543c9f674 386 {
mbed_official 489:119543c9f674 387 return((DBGMCU->IDCODE) >> POSITION_VAL(DBGMCU_IDCODE_REV_ID));
mbed_official 489:119543c9f674 388 }
mbed_official 489:119543c9f674 389
mbed_official 489:119543c9f674 390 /**
mbed_official 489:119543c9f674 391 * @brief Returns the device identifier.
mbed_official 489:119543c9f674 392 * Note: On devices STM32F10xx8 and STM32F10xxB,
mbed_official 489:119543c9f674 393 * STM32F101xC/D/E and STM32F103xC/D/E,
mbed_official 489:119543c9f674 394 * STM32F101xF/G and STM32F103xF/G
mbed_official 489:119543c9f674 395 * STM32F10xx4 and STM32F10xx6
mbed_official 489:119543c9f674 396 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
mbed_official 489:119543c9f674 397 * debug mode (not accessible by the user software in normal mode).
mbed_official 489:119543c9f674 398 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 399 * @retval Device identifier
mbed_official 489:119543c9f674 400 */
mbed_official 489:119543c9f674 401 uint32_t HAL_GetDEVID(void)
mbed_official 489:119543c9f674 402 {
mbed_official 489:119543c9f674 403 return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
mbed_official 489:119543c9f674 404 }
mbed_official 489:119543c9f674 405
mbed_official 489:119543c9f674 406 /**
mbed_official 489:119543c9f674 407 * @brief Enable the Debug Module during SLEEP mode
mbed_official 489:119543c9f674 408 * @retval None
mbed_official 489:119543c9f674 409 */
mbed_official 489:119543c9f674 410 void HAL_DBGMCU_EnableDBGSleepMode(void)
mbed_official 489:119543c9f674 411 {
mbed_official 489:119543c9f674 412 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
mbed_official 489:119543c9f674 413 }
mbed_official 489:119543c9f674 414
mbed_official 489:119543c9f674 415 /**
mbed_official 489:119543c9f674 416 * @brief Disable the Debug Module during SLEEP mode
mbed_official 489:119543c9f674 417 * Note: On devices STM32F10xx8 and STM32F10xxB,
mbed_official 489:119543c9f674 418 * STM32F101xC/D/E and STM32F103xC/D/E,
mbed_official 489:119543c9f674 419 * STM32F101xF/G and STM32F103xF/G
mbed_official 489:119543c9f674 420 * STM32F10xx4 and STM32F10xx6
mbed_official 489:119543c9f674 421 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
mbed_official 489:119543c9f674 422 * debug mode (not accessible by the user software in normal mode).
mbed_official 489:119543c9f674 423 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 424 * @retval None
mbed_official 489:119543c9f674 425 */
mbed_official 489:119543c9f674 426 void HAL_DBGMCU_DisableDBGSleepMode(void)
mbed_official 489:119543c9f674 427 {
mbed_official 489:119543c9f674 428 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
mbed_official 489:119543c9f674 429 }
mbed_official 489:119543c9f674 430
mbed_official 489:119543c9f674 431 /**
mbed_official 489:119543c9f674 432 * @brief Enable the Debug Module during STOP mode
mbed_official 489:119543c9f674 433 * Note: On devices STM32F10xx8 and STM32F10xxB,
mbed_official 489:119543c9f674 434 * STM32F101xC/D/E and STM32F103xC/D/E,
mbed_official 489:119543c9f674 435 * STM32F101xF/G and STM32F103xF/G
mbed_official 489:119543c9f674 436 * STM32F10xx4 and STM32F10xx6
mbed_official 489:119543c9f674 437 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
mbed_official 489:119543c9f674 438 * debug mode (not accessible by the user software in normal mode).
mbed_official 489:119543c9f674 439 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 440 * Note: On all STM32F1 devices:
mbed_official 489:119543c9f674 441 * If the system tick timer interrupt is enabled during the Stop mode
mbed_official 489:119543c9f674 442 * debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
mbed_official 489:119543c9f674 443 * the system from Stop mode.
mbed_official 489:119543c9f674 444 * Workaround: To debug the Stop mode, disable the system tick timer
mbed_official 489:119543c9f674 445 * interrupt.
mbed_official 489:119543c9f674 446 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 447 * Note: On all STM32F1 devices:
mbed_official 489:119543c9f674 448 * If the system tick timer interrupt is enabled during the Stop mode
mbed_official 489:119543c9f674 449 * debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
mbed_official 489:119543c9f674 450 * the system from Stop mode.
mbed_official 489:119543c9f674 451 * Workaround: To debug the Stop mode, disable the system tick timer
mbed_official 489:119543c9f674 452 * interrupt.
mbed_official 489:119543c9f674 453 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 454 * @retval None
mbed_official 489:119543c9f674 455 */
mbed_official 489:119543c9f674 456 void HAL_DBGMCU_EnableDBGStopMode(void)
mbed_official 489:119543c9f674 457 {
mbed_official 489:119543c9f674 458 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 489:119543c9f674 459 }
mbed_official 489:119543c9f674 460
mbed_official 489:119543c9f674 461 /**
mbed_official 489:119543c9f674 462 * @brief Disable the Debug Module during STOP mode
mbed_official 489:119543c9f674 463 * Note: On devices STM32F10xx8 and STM32F10xxB,
mbed_official 489:119543c9f674 464 * STM32F101xC/D/E and STM32F103xC/D/E,
mbed_official 489:119543c9f674 465 * STM32F101xF/G and STM32F103xF/G
mbed_official 489:119543c9f674 466 * STM32F10xx4 and STM32F10xx6
mbed_official 489:119543c9f674 467 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
mbed_official 489:119543c9f674 468 * debug mode (not accessible by the user software in normal mode).
mbed_official 489:119543c9f674 469 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 470 * @retval None
mbed_official 489:119543c9f674 471 */
mbed_official 489:119543c9f674 472 void HAL_DBGMCU_DisableDBGStopMode(void)
mbed_official 489:119543c9f674 473 {
mbed_official 489:119543c9f674 474 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 489:119543c9f674 475 }
mbed_official 489:119543c9f674 476
mbed_official 489:119543c9f674 477 /**
mbed_official 489:119543c9f674 478 * @brief Enable the Debug Module during STANDBY mode
mbed_official 489:119543c9f674 479 * Note: On devices STM32F10xx8 and STM32F10xxB,
mbed_official 489:119543c9f674 480 * STM32F101xC/D/E and STM32F103xC/D/E,
mbed_official 489:119543c9f674 481 * STM32F101xF/G and STM32F103xF/G
mbed_official 489:119543c9f674 482 * STM32F10xx4 and STM32F10xx6
mbed_official 489:119543c9f674 483 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
mbed_official 489:119543c9f674 484 * debug mode (not accessible by the user software in normal mode).
mbed_official 489:119543c9f674 485 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 486 * @retval None
mbed_official 489:119543c9f674 487 */
mbed_official 489:119543c9f674 488 void HAL_DBGMCU_EnableDBGStandbyMode(void)
mbed_official 489:119543c9f674 489 {
mbed_official 489:119543c9f674 490 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 489:119543c9f674 491 }
mbed_official 489:119543c9f674 492
mbed_official 489:119543c9f674 493 /**
mbed_official 489:119543c9f674 494 * @brief Disable the Debug Module during STANDBY mode
mbed_official 489:119543c9f674 495 * Note: On devices STM32F10xx8 and STM32F10xxB,
mbed_official 489:119543c9f674 496 * STM32F101xC/D/E and STM32F103xC/D/E,
mbed_official 489:119543c9f674 497 * STM32F101xF/G and STM32F103xF/G
mbed_official 489:119543c9f674 498 * STM32F10xx4 and STM32F10xx6
mbed_official 489:119543c9f674 499 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
mbed_official 489:119543c9f674 500 * debug mode (not accessible by the user software in normal mode).
mbed_official 489:119543c9f674 501 * Refer to errata sheet of these devices for more details.
mbed_official 489:119543c9f674 502 * @retval None
mbed_official 489:119543c9f674 503 */
mbed_official 489:119543c9f674 504 void HAL_DBGMCU_DisableDBGStandbyMode(void)
mbed_official 489:119543c9f674 505 {
mbed_official 489:119543c9f674 506 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 489:119543c9f674 507 }
mbed_official 489:119543c9f674 508
mbed_official 489:119543c9f674 509 /**
mbed_official 489:119543c9f674 510 * @}
mbed_official 489:119543c9f674 511 */
mbed_official 489:119543c9f674 512
mbed_official 489:119543c9f674 513 /**
mbed_official 489:119543c9f674 514 * @}
mbed_official 489:119543c9f674 515 */
mbed_official 489:119543c9f674 516
mbed_official 489:119543c9f674 517 #endif /* HAL_MODULE_ENABLED */
mbed_official 489:119543c9f674 518 /**
mbed_official 489:119543c9f674 519 * @}
mbed_official 489:119543c9f674 520 */
mbed_official 489:119543c9f674 521
mbed_official 489:119543c9f674 522 /**
mbed_official 489:119543c9f674 523 * @}
mbed_official 489:119543c9f674 524 */
mbed_official 489:119543c9f674 525
mbed_official 489:119543c9f674 526 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/