mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Sep 30 17:00:09 2015 +0100
Revision:
636:a11c0372f0ba
Parent:
631:825f75ca301e
Synchronized with git revision d29c98dae61be0946ddf3a3c641c7726056f9452

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

Added support for SAMW25

Who changed what in which revision?

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