mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri May 30 15:30:09 2014 +0100
Revision:
218:44081b78fdc2
Parent:
205:c41fc65bcfb4
Synchronized with git revision d854859072d318241476ccc5f335965444d4c1d8

Full URL: https://github.com/mbedmicro/mbed/commit/d854859072d318241476ccc5f335965444d4c1d8/

[NUCLEO_F072RB] Update CubeF0 HAL driver

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 205:c41fc65bcfb4 1 /**
mbed_official 205:c41fc65bcfb4 2 ******************************************************************************
mbed_official 205:c41fc65bcfb4 3 * @file stm32f0xx_hal.c
mbed_official 205:c41fc65bcfb4 4 * @author MCD Application Team
mbed_official 205:c41fc65bcfb4 5 * @version V1.0.0
mbed_official 218:44081b78fdc2 6 * @date 28-May-2014
mbed_official 205:c41fc65bcfb4 7 * @brief HAL module driver.
mbed_official 205:c41fc65bcfb4 8 * This is the common part of the HAL initialization
mbed_official 205:c41fc65bcfb4 9 *
mbed_official 205:c41fc65bcfb4 10 @verbatim
mbed_official 205:c41fc65bcfb4 11 ==============================================================================
mbed_official 205:c41fc65bcfb4 12 ##### How to use this driver #####
mbed_official 205:c41fc65bcfb4 13 ==============================================================================
mbed_official 205:c41fc65bcfb4 14 [..]
mbed_official 205:c41fc65bcfb4 15 The common HAL driver contains a set of generic and common APIs that can be
mbed_official 205:c41fc65bcfb4 16 used by the PPP peripheral drivers and the user to start using the HAL.
mbed_official 205:c41fc65bcfb4 17 [..]
mbed_official 205:c41fc65bcfb4 18 The HAL contains two APIs categories:
mbed_official 205:c41fc65bcfb4 19 (+) Common HAL APIs
mbed_official 205:c41fc65bcfb4 20 (+) Services HAL APIs
mbed_official 205:c41fc65bcfb4 21
mbed_official 205:c41fc65bcfb4 22 @endverbatim
mbed_official 205:c41fc65bcfb4 23 ******************************************************************************
mbed_official 205:c41fc65bcfb4 24 * @attention
mbed_official 205:c41fc65bcfb4 25 *
mbed_official 205:c41fc65bcfb4 26 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 205:c41fc65bcfb4 27 *
mbed_official 205:c41fc65bcfb4 28 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 205:c41fc65bcfb4 29 * are permitted provided that the following conditions are met:
mbed_official 205:c41fc65bcfb4 30 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 205:c41fc65bcfb4 31 * this list of conditions and the following disclaimer.
mbed_official 205:c41fc65bcfb4 32 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 205:c41fc65bcfb4 33 * this list of conditions and the following disclaimer in the documentation
mbed_official 205:c41fc65bcfb4 34 * and/or other materials provided with the distribution.
mbed_official 205:c41fc65bcfb4 35 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 205:c41fc65bcfb4 36 * may be used to endorse or promote products derived from this software
mbed_official 205:c41fc65bcfb4 37 * without specific prior written permission.
mbed_official 205:c41fc65bcfb4 38 *
mbed_official 205:c41fc65bcfb4 39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 205:c41fc65bcfb4 40 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 205:c41fc65bcfb4 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 205:c41fc65bcfb4 42 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 205:c41fc65bcfb4 43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 205:c41fc65bcfb4 44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 205:c41fc65bcfb4 45 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 205:c41fc65bcfb4 46 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 205:c41fc65bcfb4 47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 205:c41fc65bcfb4 48 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 205:c41fc65bcfb4 49 *
mbed_official 205:c41fc65bcfb4 50 ******************************************************************************
mbed_official 205:c41fc65bcfb4 51 */
mbed_official 205:c41fc65bcfb4 52
mbed_official 205:c41fc65bcfb4 53 /* Includes ------------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 54 #include "stm32f0xx_hal.h"
mbed_official 205:c41fc65bcfb4 55
mbed_official 205:c41fc65bcfb4 56 /** @addtogroup STM32F0xx_HAL_Driver
mbed_official 205:c41fc65bcfb4 57 * @{
mbed_official 205:c41fc65bcfb4 58 */
mbed_official 205:c41fc65bcfb4 59
mbed_official 205:c41fc65bcfb4 60 /** @defgroup HAL
mbed_official 205:c41fc65bcfb4 61 * @brief HAL module driver.
mbed_official 205:c41fc65bcfb4 62 * @{
mbed_official 205:c41fc65bcfb4 63 */
mbed_official 205:c41fc65bcfb4 64
mbed_official 205:c41fc65bcfb4 65 #ifdef HAL_MODULE_ENABLED
mbed_official 205:c41fc65bcfb4 66
mbed_official 205:c41fc65bcfb4 67 /* Private typedef -----------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 68 /* Private define ------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 69 /**
mbed_official 205:c41fc65bcfb4 70 * @brief STM32F0xx HAL Driver version number V1.0.0
mbed_official 205:c41fc65bcfb4 71 */
mbed_official 205:c41fc65bcfb4 72 #define __STM32F0xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
mbed_official 205:c41fc65bcfb4 73 #define __STM32F0xx_HAL_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
mbed_official 205:c41fc65bcfb4 74 #define __STM32F0xx_HAL_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
mbed_official 205:c41fc65bcfb4 75 #define __STM32F0xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */
mbed_official 205:c41fc65bcfb4 76 #define __STM32F0xx_HAL_VERSION ((__STM32F0xx_HAL_VERSION_MAIN << 24)\
mbed_official 205:c41fc65bcfb4 77 |(__STM32F0xx_HAL_VERSION_SUB1 << 16)\
mbed_official 205:c41fc65bcfb4 78 |(__STM32F0xx_HAL_VERSION_SUB2 << 8 )\
mbed_official 205:c41fc65bcfb4 79 |(__STM32F0xx_HAL_VERSION_RC))
mbed_official 205:c41fc65bcfb4 80
mbed_official 205:c41fc65bcfb4 81 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
mbed_official 205:c41fc65bcfb4 82
mbed_official 205:c41fc65bcfb4 83 /* Private macro -------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 84 /* Private variables ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 85 static __IO uint32_t uwTick;
mbed_official 205:c41fc65bcfb4 86 /* Private function prototypes -----------------------------------------------*/
mbed_official 205:c41fc65bcfb4 87 /* Private functions ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 88
mbed_official 205:c41fc65bcfb4 89 /** @defgroup HAL_Private_Functions
mbed_official 205:c41fc65bcfb4 90 * @{
mbed_official 205:c41fc65bcfb4 91 */
mbed_official 205:c41fc65bcfb4 92
mbed_official 205:c41fc65bcfb4 93 /** @defgroup HAL_Group1 Initialization and de-initialization Functions
mbed_official 205:c41fc65bcfb4 94 * @brief Initialization and de-initialization functions
mbed_official 205:c41fc65bcfb4 95 *
mbed_official 205:c41fc65bcfb4 96 @verbatim
mbed_official 205:c41fc65bcfb4 97 ===============================================================================
mbed_official 205:c41fc65bcfb4 98 ##### Initialization and de-initialization functions #####
mbed_official 205:c41fc65bcfb4 99 ===============================================================================
mbed_official 205:c41fc65bcfb4 100 [..] This section provides functions allowing to:
mbed_official 205:c41fc65bcfb4 101 (+) Initializes the Flash interface, the NVIC allocation and initial clock
mbed_official 205:c41fc65bcfb4 102 configuration. It initializes the source of time base also when timeout
mbed_official 205:c41fc65bcfb4 103 is needed and the backup domain when enabled.
mbed_official 205:c41fc65bcfb4 104 (+) de-Initializes common part of the HAL.
mbed_official 205:c41fc65bcfb4 105 (+) Configure The time base source to have 1ms time base with a dedicated
mbed_official 205:c41fc65bcfb4 106 Tick interrupt priority.
mbed_official 205:c41fc65bcfb4 107 (++) Systick timer is used by default as source of time base, but user
mbed_official 205:c41fc65bcfb4 108 can eventually implement his proper time base source (a general purpose
mbed_official 205:c41fc65bcfb4 109 timer for example or other time source), keeping in mind that Time base
mbed_official 205:c41fc65bcfb4 110 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
mbed_official 205:c41fc65bcfb4 111 handled in milliseconds basis.
mbed_official 205:c41fc65bcfb4 112 (++) Time base configuration function (HAL_InitTick ()) is called automatically
mbed_official 205:c41fc65bcfb4 113 at the beginning of the program after reset by HAL_Init() or at any time
mbed_official 205:c41fc65bcfb4 114 when clock is configured, by HAL_RCC_ClockConfig().
mbed_official 205:c41fc65bcfb4 115 (++) Source of time base is configured to generate interrupts at regular
mbed_official 205:c41fc65bcfb4 116 time intervals. Care must be taken if HAL_Delay() is called from a
mbed_official 205:c41fc65bcfb4 117 peripheral ISR process, the Tick interrupt line must have higher priority
mbed_official 205:c41fc65bcfb4 118 (numerically lower) than the peripheral interrupt. Otherwise the caller
mbed_official 205:c41fc65bcfb4 119 ISR process will be blocked.
mbed_official 205:c41fc65bcfb4 120 (++) functions affecting time base configurations are declared as __Weak
mbed_official 205:c41fc65bcfb4 121 to make override possible in case of other implementations in user file.
mbed_official 205:c41fc65bcfb4 122
mbed_official 205:c41fc65bcfb4 123 @endverbatim
mbed_official 205:c41fc65bcfb4 124 * @{
mbed_official 205:c41fc65bcfb4 125 */
mbed_official 205:c41fc65bcfb4 126
mbed_official 205:c41fc65bcfb4 127 /**
mbed_official 205:c41fc65bcfb4 128 * @brief This function configures the Flash prefetch,
mbed_official 205:c41fc65bcfb4 129 * Configures time base source, NVIC and Low level hardware
mbed_official 205:c41fc65bcfb4 130 * @note This function is called at the beginning of program after reset and before
mbed_official 205:c41fc65bcfb4 131 * the clock configuration
mbed_official 205:c41fc65bcfb4 132 * @note The time base configuration is based on HSI clock when exiting from Reset.
mbed_official 205:c41fc65bcfb4 133 * Once done, time base tick start incrementing.
mbed_official 205:c41fc65bcfb4 134 * In the default implementation,Systick is used as source of time base.
mbed_official 205:c41fc65bcfb4 135 * The tick variable is incremented each 1ms in its ISR.
mbed_official 205:c41fc65bcfb4 136 * @param None
mbed_official 205:c41fc65bcfb4 137 * @retval HAL status
mbed_official 205:c41fc65bcfb4 138 */
mbed_official 205:c41fc65bcfb4 139 HAL_StatusTypeDef HAL_Init(void)
mbed_official 205:c41fc65bcfb4 140 {
mbed_official 205:c41fc65bcfb4 141 /* Configure Flash prefetch */
mbed_official 205:c41fc65bcfb4 142 #if (PREFETCH_ENABLE != 0)
mbed_official 205:c41fc65bcfb4 143 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
mbed_official 205:c41fc65bcfb4 144 #endif /* PREFETCH_ENABLE */
mbed_official 205:c41fc65bcfb4 145
mbed_official 205:c41fc65bcfb4 146 /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
mbed_official 205:c41fc65bcfb4 147
mbed_official 205:c41fc65bcfb4 148 HAL_InitTick(TICK_INT_PRIORITY);
mbed_official 205:c41fc65bcfb4 149
mbed_official 205:c41fc65bcfb4 150 /* Init the low level hardware */
mbed_official 205:c41fc65bcfb4 151 HAL_MspInit();
mbed_official 205:c41fc65bcfb4 152
mbed_official 205:c41fc65bcfb4 153 /* Return function status */
mbed_official 205:c41fc65bcfb4 154 return HAL_OK;
mbed_official 205:c41fc65bcfb4 155 }
mbed_official 205:c41fc65bcfb4 156
mbed_official 205:c41fc65bcfb4 157 /**
mbed_official 205:c41fc65bcfb4 158 * @brief This function de-Initializes common part of the HAL and stops the source
mbed_official 205:c41fc65bcfb4 159 * of time base.
mbed_official 205:c41fc65bcfb4 160 * @note This function is optional.
mbed_official 205:c41fc65bcfb4 161 * @param None
mbed_official 205:c41fc65bcfb4 162 * @retval HAL status
mbed_official 205:c41fc65bcfb4 163 */
mbed_official 205:c41fc65bcfb4 164 HAL_StatusTypeDef HAL_DeInit(void)
mbed_official 205:c41fc65bcfb4 165 {
mbed_official 205:c41fc65bcfb4 166 /* Reset of all peripherals */
mbed_official 205:c41fc65bcfb4 167 __APB1_FORCE_RESET();
mbed_official 205:c41fc65bcfb4 168 __APB1_RELEASE_RESET();
mbed_official 205:c41fc65bcfb4 169
mbed_official 205:c41fc65bcfb4 170 __APB2_FORCE_RESET();
mbed_official 205:c41fc65bcfb4 171 __APB2_RELEASE_RESET();
mbed_official 205:c41fc65bcfb4 172
mbed_official 205:c41fc65bcfb4 173 __AHB_FORCE_RESET();
mbed_official 205:c41fc65bcfb4 174 __AHB_RELEASE_RESET();
mbed_official 205:c41fc65bcfb4 175
mbed_official 205:c41fc65bcfb4 176 /* De-Init the low level hardware */
mbed_official 205:c41fc65bcfb4 177 HAL_MspDeInit();
mbed_official 205:c41fc65bcfb4 178
mbed_official 205:c41fc65bcfb4 179 /* Return function status */
mbed_official 205:c41fc65bcfb4 180 return HAL_OK;
mbed_official 205:c41fc65bcfb4 181 }
mbed_official 205:c41fc65bcfb4 182
mbed_official 205:c41fc65bcfb4 183 /**
mbed_official 205:c41fc65bcfb4 184 * @brief Initializes the MSP.
mbed_official 205:c41fc65bcfb4 185 * @param None
mbed_official 205:c41fc65bcfb4 186 * @retval None
mbed_official 205:c41fc65bcfb4 187 */
mbed_official 205:c41fc65bcfb4 188 __weak void HAL_MspInit(void)
mbed_official 205:c41fc65bcfb4 189 {
mbed_official 205:c41fc65bcfb4 190 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 191 the HAL_MspInit could be implemented in the user file
mbed_official 205:c41fc65bcfb4 192 */
mbed_official 205:c41fc65bcfb4 193 }
mbed_official 205:c41fc65bcfb4 194
mbed_official 205:c41fc65bcfb4 195 /**
mbed_official 205:c41fc65bcfb4 196 * @brief DeInitializes the MSP.
mbed_official 205:c41fc65bcfb4 197 * @param None
mbed_official 205:c41fc65bcfb4 198 * @retval None
mbed_official 205:c41fc65bcfb4 199 */
mbed_official 205:c41fc65bcfb4 200 __weak void HAL_MspDeInit(void)
mbed_official 205:c41fc65bcfb4 201 {
mbed_official 205:c41fc65bcfb4 202 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 203 the HAL_MspDeInit could be implemented in the user file
mbed_official 205:c41fc65bcfb4 204 */
mbed_official 205:c41fc65bcfb4 205 }
mbed_official 205:c41fc65bcfb4 206
mbed_official 205:c41fc65bcfb4 207 /**
mbed_official 205:c41fc65bcfb4 208 * @brief This function configures the source of the time base.
mbed_official 205:c41fc65bcfb4 209 * The time source is configured to have 1ms time base with a dedicated
mbed_official 205:c41fc65bcfb4 210 * Tick interrupt priority.
mbed_official 205:c41fc65bcfb4 211 * @note This function is called automatically at the beginning of program after
mbed_official 205:c41fc65bcfb4 212 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
mbed_official 205:c41fc65bcfb4 213 * @note In the default implementation, SysTick timer is the source of time base.
mbed_official 205:c41fc65bcfb4 214 * It is used to generate interrupts at regular time intervals.
mbed_official 205:c41fc65bcfb4 215 * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
mbed_official 205:c41fc65bcfb4 216 * The the SysTick interrupt must have higher priority (numerically lower)
mbed_official 205:c41fc65bcfb4 217 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
mbed_official 205:c41fc65bcfb4 218 * The function is declared as __Weak to be overwritten in case of other
mbed_official 205:c41fc65bcfb4 219 * implementation in user file.
mbed_official 205:c41fc65bcfb4 220 * @param TickPriority: Tick interrupt priority.
mbed_official 205:c41fc65bcfb4 221 * @retval HAL status
mbed_official 205:c41fc65bcfb4 222 */
mbed_official 205:c41fc65bcfb4 223 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
mbed_official 205:c41fc65bcfb4 224 {
mbed_official 205:c41fc65bcfb4 225 /*Configure the SysTick to have interrupt in 1ms time basis*/
mbed_official 205:c41fc65bcfb4 226 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
mbed_official 205:c41fc65bcfb4 227
mbed_official 205:c41fc65bcfb4 228 /*Configure the SysTick IRQ priority */
mbed_official 205:c41fc65bcfb4 229 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
mbed_official 205:c41fc65bcfb4 230
mbed_official 205:c41fc65bcfb4 231 /* Return function status */
mbed_official 205:c41fc65bcfb4 232 return HAL_OK;
mbed_official 205:c41fc65bcfb4 233 }
mbed_official 205:c41fc65bcfb4 234
mbed_official 205:c41fc65bcfb4 235 /**
mbed_official 205:c41fc65bcfb4 236 * @}
mbed_official 205:c41fc65bcfb4 237 */
mbed_official 205:c41fc65bcfb4 238
mbed_official 205:c41fc65bcfb4 239 /** @defgroup HAL_Group2 HAL Control function
mbed_official 205:c41fc65bcfb4 240 * @brief HAL Control functions
mbed_official 205:c41fc65bcfb4 241 *
mbed_official 205:c41fc65bcfb4 242 @verbatim
mbed_official 205:c41fc65bcfb4 243 ===============================================================================
mbed_official 205:c41fc65bcfb4 244 ##### HAL Control functions #####
mbed_official 205:c41fc65bcfb4 245 ===============================================================================
mbed_official 205:c41fc65bcfb4 246 [..] This section provides functions allowing to:
mbed_official 205:c41fc65bcfb4 247 (+) Provide a tick value in millisecond
mbed_official 205:c41fc65bcfb4 248 (+) Provide a blocking delay in millisecond
mbed_official 205:c41fc65bcfb4 249 (+) Suspend the time base source interrupt
mbed_official 205:c41fc65bcfb4 250 (+) Resume the time base source interrupt
mbed_official 205:c41fc65bcfb4 251 (+) Get the HAL API driver version
mbed_official 205:c41fc65bcfb4 252 (+) Get the device identifier
mbed_official 205:c41fc65bcfb4 253 (+) Get the device revision identifier
mbed_official 205:c41fc65bcfb4 254 (+) Enable/Disable Debug module during Sleep mode
mbed_official 205:c41fc65bcfb4 255 (+) Enable/Disable Debug module during STOP mode
mbed_official 205:c41fc65bcfb4 256 (+) Enable/Disable Debug module during STANDBY mode
mbed_official 205:c41fc65bcfb4 257
mbed_official 205:c41fc65bcfb4 258 @endverbatim
mbed_official 205:c41fc65bcfb4 259 * @{
mbed_official 205:c41fc65bcfb4 260 */
mbed_official 205:c41fc65bcfb4 261
mbed_official 205:c41fc65bcfb4 262 /**
mbed_official 205:c41fc65bcfb4 263 * @brief This function is called to increment a global variable "uwTick"
mbed_official 205:c41fc65bcfb4 264 * used as application time base.
mbed_official 205:c41fc65bcfb4 265 * @note In the default implementation, this variable is incremented each 1ms
mbed_official 205:c41fc65bcfb4 266 * in Systick ISR.
mbed_official 205:c41fc65bcfb4 267 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 205:c41fc65bcfb4 268 * implementations in user file.
mbed_official 205:c41fc65bcfb4 269 * @param None
mbed_official 205:c41fc65bcfb4 270 * @retval None
mbed_official 205:c41fc65bcfb4 271 */
mbed_official 205:c41fc65bcfb4 272 __weak void HAL_IncTick(void)
mbed_official 205:c41fc65bcfb4 273 {
mbed_official 205:c41fc65bcfb4 274 uwTick++;
mbed_official 205:c41fc65bcfb4 275 }
mbed_official 205:c41fc65bcfb4 276
mbed_official 205:c41fc65bcfb4 277 /**
mbed_official 205:c41fc65bcfb4 278 * @brief Provides a tick value in millisecond.
mbed_official 205:c41fc65bcfb4 279 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 205:c41fc65bcfb4 280 * implementations in user file.
mbed_official 205:c41fc65bcfb4 281 * @param None
mbed_official 205:c41fc65bcfb4 282 * @retval tick value
mbed_official 205:c41fc65bcfb4 283 */
mbed_official 205:c41fc65bcfb4 284 __weak uint32_t HAL_GetTick(void)
mbed_official 205:c41fc65bcfb4 285 {
mbed_official 205:c41fc65bcfb4 286 return uwTick;
mbed_official 205:c41fc65bcfb4 287 }
mbed_official 205:c41fc65bcfb4 288
mbed_official 205:c41fc65bcfb4 289 /**
mbed_official 205:c41fc65bcfb4 290 * @brief Suspend Tick increment.
mbed_official 205:c41fc65bcfb4 291 * @note In the default implementation , SysTick timer is the source of time base. It is
mbed_official 205:c41fc65bcfb4 292 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
mbed_official 205:c41fc65bcfb4 293 * is called, the the SysTick interrupt will be disabled and so Tick increment
mbed_official 205:c41fc65bcfb4 294 * is suspended.
mbed_official 205:c41fc65bcfb4 295 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 205:c41fc65bcfb4 296 * implementations in user file.
mbed_official 205:c41fc65bcfb4 297 * @param None
mbed_official 205:c41fc65bcfb4 298 * @retval None
mbed_official 205:c41fc65bcfb4 299 */
mbed_official 205:c41fc65bcfb4 300 __weak void HAL_SuspendTick(void)
mbed_official 205:c41fc65bcfb4 301 {
mbed_official 205:c41fc65bcfb4 302 /* Disable SysTick Interrupt */
mbed_official 205:c41fc65bcfb4 303 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
mbed_official 205:c41fc65bcfb4 304 }
mbed_official 205:c41fc65bcfb4 305
mbed_official 205:c41fc65bcfb4 306 /**
mbed_official 205:c41fc65bcfb4 307 * @brief Resume Tick increment.
mbed_official 205:c41fc65bcfb4 308 * @note In the default implementation , SysTick timer is the source of time base. It is
mbed_official 205:c41fc65bcfb4 309 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
mbed_official 205:c41fc65bcfb4 310 * is called, the the SysTick interrupt will be enabled and so Tick increment
mbed_official 205:c41fc65bcfb4 311 * is resumed.
mbed_official 205:c41fc65bcfb4 312 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 205:c41fc65bcfb4 313 * implementations in user file.
mbed_official 205:c41fc65bcfb4 314 * @param None
mbed_official 205:c41fc65bcfb4 315 * @retval None
mbed_official 205:c41fc65bcfb4 316 */
mbed_official 205:c41fc65bcfb4 317 __weak void HAL_ResumeTick(void)
mbed_official 205:c41fc65bcfb4 318 {
mbed_official 205:c41fc65bcfb4 319 /* Enable SysTick Interrupt */
mbed_official 205:c41fc65bcfb4 320 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
mbed_official 205:c41fc65bcfb4 321 }
mbed_official 205:c41fc65bcfb4 322
mbed_official 205:c41fc65bcfb4 323 /**
mbed_official 205:c41fc65bcfb4 324 * @brief This function provides accurate delay (in milliseconds) based
mbed_official 205:c41fc65bcfb4 325 * on variable incremented.
mbed_official 205:c41fc65bcfb4 326 * @note In the default implementation , SysTick timer is the source of time base.
mbed_official 205:c41fc65bcfb4 327 * It is used to generate interrupts at regular time intervals where uwTick
mbed_official 205:c41fc65bcfb4 328 * is incremented.
mbed_official 205:c41fc65bcfb4 329 * @note ThiS function is declared as __weak to be overwritten in case of other
mbed_official 205:c41fc65bcfb4 330 * implementations in user file.
mbed_official 205:c41fc65bcfb4 331 * @param Delay: specifies the delay time length, in milliseconds.
mbed_official 205:c41fc65bcfb4 332 * @retval None
mbed_official 205:c41fc65bcfb4 333 */
mbed_official 205:c41fc65bcfb4 334 __weak void HAL_Delay(__IO uint32_t Delay)
mbed_official 205:c41fc65bcfb4 335 {
mbed_official 205:c41fc65bcfb4 336 uint32_t tickstart = 0;
mbed_official 205:c41fc65bcfb4 337 tickstart = HAL_GetTick();
mbed_official 205:c41fc65bcfb4 338 while((HAL_GetTick() - tickstart) < Delay)
mbed_official 205:c41fc65bcfb4 339 {
mbed_official 205:c41fc65bcfb4 340 }
mbed_official 205:c41fc65bcfb4 341 }
mbed_official 205:c41fc65bcfb4 342
mbed_official 205:c41fc65bcfb4 343 /**
mbed_official 205:c41fc65bcfb4 344 * @brief This method returns the HAL revision
mbed_official 205:c41fc65bcfb4 345 * @param None
mbed_official 205:c41fc65bcfb4 346 * @retval version : 0xXYZR (8bits for each decimal, R for RC)
mbed_official 205:c41fc65bcfb4 347 */
mbed_official 205:c41fc65bcfb4 348 uint32_t HAL_GetHalVersion(void)
mbed_official 205:c41fc65bcfb4 349 {
mbed_official 205:c41fc65bcfb4 350 return __STM32F0xx_HAL_VERSION;
mbed_official 205:c41fc65bcfb4 351 }
mbed_official 205:c41fc65bcfb4 352
mbed_official 205:c41fc65bcfb4 353 /**
mbed_official 205:c41fc65bcfb4 354 * @brief Returns the device revision identifier.
mbed_official 205:c41fc65bcfb4 355 * @param None
mbed_official 205:c41fc65bcfb4 356 * @retval Device revision identifier
mbed_official 205:c41fc65bcfb4 357 */
mbed_official 205:c41fc65bcfb4 358 uint32_t HAL_GetREVID(void)
mbed_official 205:c41fc65bcfb4 359 {
mbed_official 205:c41fc65bcfb4 360 return(DBGMCU->IDCODE >> 16);
mbed_official 205:c41fc65bcfb4 361 }
mbed_official 205:c41fc65bcfb4 362
mbed_official 205:c41fc65bcfb4 363 /**
mbed_official 205:c41fc65bcfb4 364 * @brief Returns the device identifier.
mbed_official 205:c41fc65bcfb4 365 * @param None
mbed_official 205:c41fc65bcfb4 366 * @retval Device identifier
mbed_official 205:c41fc65bcfb4 367 */
mbed_official 205:c41fc65bcfb4 368 uint32_t HAL_GetDEVID(void)
mbed_official 205:c41fc65bcfb4 369 {
mbed_official 205:c41fc65bcfb4 370 return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
mbed_official 205:c41fc65bcfb4 371 }
mbed_official 205:c41fc65bcfb4 372
mbed_official 205:c41fc65bcfb4 373 /**
mbed_official 205:c41fc65bcfb4 374 * @brief Enable the Debug Module during STOP mode
mbed_official 205:c41fc65bcfb4 375 * @param None
mbed_official 205:c41fc65bcfb4 376 * @retval None
mbed_official 205:c41fc65bcfb4 377 */
mbed_official 205:c41fc65bcfb4 378 void HAL_EnableDBGStopMode(void)
mbed_official 205:c41fc65bcfb4 379 {
mbed_official 205:c41fc65bcfb4 380 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 205:c41fc65bcfb4 381 }
mbed_official 205:c41fc65bcfb4 382
mbed_official 205:c41fc65bcfb4 383 /**
mbed_official 205:c41fc65bcfb4 384 * @brief Disable the Debug Module during STOP mode
mbed_official 205:c41fc65bcfb4 385 * @param None
mbed_official 205:c41fc65bcfb4 386 * @retval None
mbed_official 205:c41fc65bcfb4 387 */
mbed_official 205:c41fc65bcfb4 388 void HAL_DisableDBGStopMode(void)
mbed_official 205:c41fc65bcfb4 389 {
mbed_official 205:c41fc65bcfb4 390 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 205:c41fc65bcfb4 391 }
mbed_official 205:c41fc65bcfb4 392
mbed_official 205:c41fc65bcfb4 393 /**
mbed_official 205:c41fc65bcfb4 394 * @brief Enable the Debug Module during STANDBY mode
mbed_official 205:c41fc65bcfb4 395 * @param None
mbed_official 205:c41fc65bcfb4 396 * @retval None
mbed_official 205:c41fc65bcfb4 397 */
mbed_official 205:c41fc65bcfb4 398 void HAL_EnableDBGStandbyMode(void)
mbed_official 205:c41fc65bcfb4 399 {
mbed_official 205:c41fc65bcfb4 400 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 205:c41fc65bcfb4 401 }
mbed_official 205:c41fc65bcfb4 402
mbed_official 205:c41fc65bcfb4 403 /**
mbed_official 205:c41fc65bcfb4 404 * @brief Disable the Debug Module during STANDBY mode
mbed_official 205:c41fc65bcfb4 405 * @param None
mbed_official 205:c41fc65bcfb4 406 * @retval None
mbed_official 205:c41fc65bcfb4 407 */
mbed_official 205:c41fc65bcfb4 408 void HAL_DisableDBGStandbyMode(void)
mbed_official 205:c41fc65bcfb4 409 {
mbed_official 205:c41fc65bcfb4 410 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 205:c41fc65bcfb4 411 }
mbed_official 205:c41fc65bcfb4 412
mbed_official 205:c41fc65bcfb4 413 /**
mbed_official 205:c41fc65bcfb4 414 * @}
mbed_official 205:c41fc65bcfb4 415 */
mbed_official 205:c41fc65bcfb4 416
mbed_official 205:c41fc65bcfb4 417 /**
mbed_official 205:c41fc65bcfb4 418 * @}
mbed_official 205:c41fc65bcfb4 419 */
mbed_official 205:c41fc65bcfb4 420
mbed_official 205:c41fc65bcfb4 421 #endif /* HAL_MODULE_ENABLED */
mbed_official 205:c41fc65bcfb4 422 /**
mbed_official 205:c41fc65bcfb4 423 * @}
mbed_official 205:c41fc65bcfb4 424 */
mbed_official 205:c41fc65bcfb4 425
mbed_official 205:c41fc65bcfb4 426 /**
mbed_official 205:c41fc65bcfb4 427 * @}
mbed_official 205:c41fc65bcfb4 428 */
mbed_official 205:c41fc65bcfb4 429
mbed_official 205:c41fc65bcfb4 430 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/