mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Nov 07 08:15:08 2014 +0000
Revision:
392:2b59412bb664
Parent:
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_hal.c@340:28d1f895c6fe
Child:
441:d2c15dda23c1
Synchronized with git revision eec0be05cd92349bee83c65f9e1302b25b5badf4

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

Targets: STM32F0 - Factorisation of NUCLEO_F030R8/F072RB/F091RC cmsis folders

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 340:28d1f895c6fe 5 * @version V1.1.0
mbed_official 340:28d1f895c6fe 6 * @date 03-Oct-2014
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 340:28d1f895c6fe 26 * <h2><center>&copy; COPYRIGHT(c) 2014 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 340:28d1f895c6fe 60 /** @defgroup HAL HAL module driver
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 340:28d1f895c6fe 69 /** @defgroup HAL_Private Constants
mbed_official 340:28d1f895c6fe 70 * @{
mbed_official 340:28d1f895c6fe 71 */
mbed_official 340:28d1f895c6fe 72 /**
mbed_official 340:28d1f895c6fe 73 * @brief STM32F0xx HAL Driver version number V1.1.0
mbed_official 340:28d1f895c6fe 74 */
mbed_official 340:28d1f895c6fe 75 #define __STM32F0xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
mbed_official 340:28d1f895c6fe 76 #define __STM32F0xx_HAL_VERSION_SUB1 (0x01) /*!< [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 340:28d1f895c6fe 90 /* Private variables ---------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 91 /** @defgroup HAL_Private_Variables HAL Private Variables
mbed_official 340:28d1f895c6fe 92 * @{
mbed_official 340:28d1f895c6fe 93 */
mbed_official 340:28d1f895c6fe 94 static __IO uint32_t uwTick;
mbed_official 340:28d1f895c6fe 95 /**
mbed_official 340:28d1f895c6fe 96 * @}
mbed_official 340:28d1f895c6fe 97 */
mbed_official 340:28d1f895c6fe 98 /* Private function prototypes -----------------------------------------------*/
mbed_official 340:28d1f895c6fe 99 /* Exported functions ---------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 100
mbed_official 340:28d1f895c6fe 101 /** @defgroup HAL_Exported_Functions HAL Exported Functions
mbed_official 340:28d1f895c6fe 102 * @{
mbed_official 340:28d1f895c6fe 103 */
mbed_official 340:28d1f895c6fe 104
mbed_official 340:28d1f895c6fe 105 /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
mbed_official 340:28d1f895c6fe 106 * @brief Initialization and de-initialization functions
mbed_official 340:28d1f895c6fe 107 *
mbed_official 340:28d1f895c6fe 108 @verbatim
mbed_official 340:28d1f895c6fe 109 ===============================================================================
mbed_official 340:28d1f895c6fe 110 ##### Initialization and de-initialization functions #####
mbed_official 340:28d1f895c6fe 111 ===============================================================================
mbed_official 340:28d1f895c6fe 112 [..] This section provides functions allowing to:
mbed_official 340:28d1f895c6fe 113 (+) Initializes the Flash interface, the NVIC allocation and initial clock
mbed_official 340:28d1f895c6fe 114 configuration. It initializes the source of time base also when timeout
mbed_official 340:28d1f895c6fe 115 is needed and the backup domain when enabled.
mbed_official 340:28d1f895c6fe 116 (+) de-Initializes common part of the HAL.
mbed_official 340:28d1f895c6fe 117 (+) Configure The time base source to have 1ms time base with a dedicated
mbed_official 340:28d1f895c6fe 118 Tick interrupt priority.
mbed_official 340:28d1f895c6fe 119 (++) Systick timer is used by default as source of time base, but user
mbed_official 340:28d1f895c6fe 120 can eventually implement his proper time base source (a general purpose
mbed_official 340:28d1f895c6fe 121 timer for example or other time source), keeping in mind that Time base
mbed_official 340:28d1f895c6fe 122 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
mbed_official 340:28d1f895c6fe 123 handled in milliseconds basis.
mbed_official 340:28d1f895c6fe 124 (++) Time base configuration function (HAL_InitTick ()) is called automatically
mbed_official 340:28d1f895c6fe 125 at the beginning of the program after reset by HAL_Init() or at any time
mbed_official 340:28d1f895c6fe 126 when clock is configured, by HAL_RCC_ClockConfig().
mbed_official 340:28d1f895c6fe 127 (++) Source of time base is configured to generate interrupts at regular
mbed_official 340:28d1f895c6fe 128 time intervals. Care must be taken if HAL_Delay() is called from a
mbed_official 340:28d1f895c6fe 129 peripheral ISR process, the Tick interrupt line must have higher priority
mbed_official 340:28d1f895c6fe 130 (numerically lower) than the peripheral interrupt. Otherwise the caller
mbed_official 340:28d1f895c6fe 131 ISR process will be blocked.
mbed_official 340:28d1f895c6fe 132 (++) functions affecting time base configurations are declared as __Weak
mbed_official 340:28d1f895c6fe 133 to make override possible in case of other implementations in user file.
mbed_official 340:28d1f895c6fe 134
mbed_official 340:28d1f895c6fe 135 @endverbatim
mbed_official 340:28d1f895c6fe 136 * @{
mbed_official 340:28d1f895c6fe 137 */
mbed_official 340:28d1f895c6fe 138
mbed_official 340:28d1f895c6fe 139 /**
mbed_official 340:28d1f895c6fe 140 * @brief This function configures the Flash prefetch,
mbed_official 340:28d1f895c6fe 141 * Configures time base source, NVIC and Low level hardware
mbed_official 340:28d1f895c6fe 142 * @note This function is called at the beginning of program after reset and before
mbed_official 340:28d1f895c6fe 143 * the clock configuration
mbed_official 340:28d1f895c6fe 144 * @note The time base configuration is based on HSI clock when exiting from Reset.
mbed_official 340:28d1f895c6fe 145 * Once done, time base tick start incrementing.
mbed_official 340:28d1f895c6fe 146 * In the default implementation,Systick is used as source of time base.
mbed_official 340:28d1f895c6fe 147 * The tick variable is incremented each 1ms in its ISR.
mbed_official 340:28d1f895c6fe 148 * @retval HAL status
mbed_official 340:28d1f895c6fe 149 */
mbed_official 340:28d1f895c6fe 150 HAL_StatusTypeDef HAL_Init(void)
mbed_official 340:28d1f895c6fe 151 {
mbed_official 340:28d1f895c6fe 152 /* Configure Flash prefetch */
mbed_official 340:28d1f895c6fe 153 #if (PREFETCH_ENABLE != 0)
mbed_official 340:28d1f895c6fe 154 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
mbed_official 340:28d1f895c6fe 155 #endif /* PREFETCH_ENABLE */
mbed_official 340:28d1f895c6fe 156
mbed_official 340:28d1f895c6fe 157 /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
mbed_official 340:28d1f895c6fe 158
mbed_official 340:28d1f895c6fe 159 HAL_InitTick(TICK_INT_PRIORITY);
mbed_official 340:28d1f895c6fe 160
mbed_official 340:28d1f895c6fe 161 /* Init the low level hardware */
mbed_official 340:28d1f895c6fe 162 HAL_MspInit();
mbed_official 340:28d1f895c6fe 163
mbed_official 340:28d1f895c6fe 164 /* Return function status */
mbed_official 340:28d1f895c6fe 165 return HAL_OK;
mbed_official 340:28d1f895c6fe 166 }
mbed_official 340:28d1f895c6fe 167
mbed_official 340:28d1f895c6fe 168 /**
mbed_official 340:28d1f895c6fe 169 * @brief This function de-Initializes common part of the HAL and stops the source
mbed_official 340:28d1f895c6fe 170 * of time base.
mbed_official 340:28d1f895c6fe 171 * @note This function is optional.
mbed_official 340:28d1f895c6fe 172 * @retval HAL status
mbed_official 340:28d1f895c6fe 173 */
mbed_official 340:28d1f895c6fe 174 HAL_StatusTypeDef HAL_DeInit(void)
mbed_official 340:28d1f895c6fe 175 {
mbed_official 340:28d1f895c6fe 176 /* Reset of all peripherals */
mbed_official 340:28d1f895c6fe 177 __APB1_FORCE_RESET();
mbed_official 340:28d1f895c6fe 178 __APB1_RELEASE_RESET();
mbed_official 340:28d1f895c6fe 179
mbed_official 340:28d1f895c6fe 180 __APB2_FORCE_RESET();
mbed_official 340:28d1f895c6fe 181 __APB2_RELEASE_RESET();
mbed_official 340:28d1f895c6fe 182
mbed_official 340:28d1f895c6fe 183 __AHB_FORCE_RESET();
mbed_official 340:28d1f895c6fe 184 __AHB_RELEASE_RESET();
mbed_official 340:28d1f895c6fe 185
mbed_official 340:28d1f895c6fe 186 /* De-Init the low level hardware */
mbed_official 340:28d1f895c6fe 187 HAL_MspDeInit();
mbed_official 340:28d1f895c6fe 188
mbed_official 340:28d1f895c6fe 189 /* Return function status */
mbed_official 340:28d1f895c6fe 190 return HAL_OK;
mbed_official 340:28d1f895c6fe 191 }
mbed_official 340:28d1f895c6fe 192
mbed_official 340:28d1f895c6fe 193 /**
mbed_official 340:28d1f895c6fe 194 * @brief Initializes the MSP.
mbed_official 340:28d1f895c6fe 195 * @retval None
mbed_official 340:28d1f895c6fe 196 */
mbed_official 340:28d1f895c6fe 197 __weak void HAL_MspInit(void)
mbed_official 340:28d1f895c6fe 198 {
mbed_official 340:28d1f895c6fe 199 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 340:28d1f895c6fe 200 the HAL_MspInit could be implemented in the user file
mbed_official 340:28d1f895c6fe 201 */
mbed_official 340:28d1f895c6fe 202 }
mbed_official 340:28d1f895c6fe 203
mbed_official 340:28d1f895c6fe 204 /**
mbed_official 340:28d1f895c6fe 205 * @brief DeInitializes the MSP.
mbed_official 340:28d1f895c6fe 206 * @retval None
mbed_official 340:28d1f895c6fe 207 */
mbed_official 340:28d1f895c6fe 208 __weak void HAL_MspDeInit(void)
mbed_official 340:28d1f895c6fe 209 {
mbed_official 340:28d1f895c6fe 210 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 340:28d1f895c6fe 211 the HAL_MspDeInit could be implemented in the user file
mbed_official 340:28d1f895c6fe 212 */
mbed_official 340:28d1f895c6fe 213 }
mbed_official 340:28d1f895c6fe 214
mbed_official 340:28d1f895c6fe 215 /**
mbed_official 340:28d1f895c6fe 216 * @brief This function configures the source of the time base.
mbed_official 340:28d1f895c6fe 217 * The time source is configured to have 1ms time base with a dedicated
mbed_official 340:28d1f895c6fe 218 * Tick interrupt priority.
mbed_official 340:28d1f895c6fe 219 * @note This function is called automatically at the beginning of program after
mbed_official 340:28d1f895c6fe 220 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
mbed_official 340:28d1f895c6fe 221 * @note In the default implementation, SysTick timer is the source of time base.
mbed_official 340:28d1f895c6fe 222 * It is used to generate interrupts at regular time intervals.
mbed_official 340:28d1f895c6fe 223 * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
mbed_official 340:28d1f895c6fe 224 * The the SysTick interrupt must have higher priority (numerically lower)
mbed_official 340:28d1f895c6fe 225 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
mbed_official 340:28d1f895c6fe 226 * The function is declared as __Weak to be overwritten in case of other
mbed_official 340:28d1f895c6fe 227 * implementation in user file.
mbed_official 340:28d1f895c6fe 228 * @param TickPriority: Tick interrupt priority.
mbed_official 340:28d1f895c6fe 229 * @retval HAL status
mbed_official 340:28d1f895c6fe 230 */
mbed_official 340:28d1f895c6fe 231 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
mbed_official 340:28d1f895c6fe 232 {
mbed_official 340:28d1f895c6fe 233 /*Configure the SysTick to have interrupt in 1ms time basis*/
mbed_official 340:28d1f895c6fe 234 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
mbed_official 340:28d1f895c6fe 235
mbed_official 340:28d1f895c6fe 236 /*Configure the SysTick IRQ priority */
mbed_official 340:28d1f895c6fe 237 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
mbed_official 340:28d1f895c6fe 238
mbed_official 340:28d1f895c6fe 239 /* Return function status */
mbed_official 340:28d1f895c6fe 240 return HAL_OK;
mbed_official 340:28d1f895c6fe 241 }
mbed_official 340:28d1f895c6fe 242
mbed_official 340:28d1f895c6fe 243 /**
mbed_official 340:28d1f895c6fe 244 * @}
mbed_official 340:28d1f895c6fe 245 */
mbed_official 340:28d1f895c6fe 246
mbed_official 340:28d1f895c6fe 247 /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
mbed_official 340:28d1f895c6fe 248 * @brief HAL Control functions
mbed_official 340:28d1f895c6fe 249 *
mbed_official 340:28d1f895c6fe 250 @verbatim
mbed_official 340:28d1f895c6fe 251 ===============================================================================
mbed_official 340:28d1f895c6fe 252 ##### HAL Control functions #####
mbed_official 340:28d1f895c6fe 253 ===============================================================================
mbed_official 340:28d1f895c6fe 254 [..] This section provides functions allowing to:
mbed_official 340:28d1f895c6fe 255 (+) Provide a tick value in millisecond
mbed_official 340:28d1f895c6fe 256 (+) Provide a blocking delay in millisecond
mbed_official 340:28d1f895c6fe 257 (+) Suspend the time base source interrupt
mbed_official 340:28d1f895c6fe 258 (+) Resume the time base source interrupt
mbed_official 340:28d1f895c6fe 259 (+) Get the HAL API driver version
mbed_official 340:28d1f895c6fe 260 (+) Get the device identifier
mbed_official 340:28d1f895c6fe 261 (+) Get the device revision identifier
mbed_official 340:28d1f895c6fe 262 (+) Enable/Disable Debug module during Sleep mode
mbed_official 340:28d1f895c6fe 263 (+) Enable/Disable Debug module during STOP mode
mbed_official 340:28d1f895c6fe 264 (+) Enable/Disable Debug module during STANDBY mode
mbed_official 340:28d1f895c6fe 265
mbed_official 340:28d1f895c6fe 266 @endverbatim
mbed_official 340:28d1f895c6fe 267 * @{
mbed_official 340:28d1f895c6fe 268 */
mbed_official 340:28d1f895c6fe 269
mbed_official 340:28d1f895c6fe 270 /**
mbed_official 340:28d1f895c6fe 271 * @brief This function is called to increment a global variable "uwTick"
mbed_official 340:28d1f895c6fe 272 * used as application time base.
mbed_official 340:28d1f895c6fe 273 * @note In the default implementation, this variable is incremented each 1ms
mbed_official 340:28d1f895c6fe 274 * in Systick ISR.
mbed_official 340:28d1f895c6fe 275 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 340:28d1f895c6fe 276 * implementations in user file.
mbed_official 340:28d1f895c6fe 277 * @retval None
mbed_official 340:28d1f895c6fe 278 */
mbed_official 340:28d1f895c6fe 279 __weak void HAL_IncTick(void)
mbed_official 340:28d1f895c6fe 280 {
mbed_official 340:28d1f895c6fe 281 uwTick++;
mbed_official 340:28d1f895c6fe 282 }
mbed_official 340:28d1f895c6fe 283
mbed_official 340:28d1f895c6fe 284 /**
mbed_official 340:28d1f895c6fe 285 * @brief Povides a tick value in millisecond.
mbed_official 340:28d1f895c6fe 286 * @note The function is declared as __Weak to be overwritten in case of other
mbed_official 340:28d1f895c6fe 287 * implementations in user file.
mbed_official 340:28d1f895c6fe 288 * @retval tick value
mbed_official 340:28d1f895c6fe 289 */
mbed_official 340:28d1f895c6fe 290 __weak uint32_t HAL_GetTick(void)
mbed_official 340:28d1f895c6fe 291 {
mbed_official 340:28d1f895c6fe 292 return uwTick;
mbed_official 340:28d1f895c6fe 293 }
mbed_official 340:28d1f895c6fe 294
mbed_official 340:28d1f895c6fe 295 /**
mbed_official 340:28d1f895c6fe 296 * @brief Suspend Tick increment.
mbed_official 340:28d1f895c6fe 297 * @note In the default implementation , SysTick timer is the source of time base. It is
mbed_official 340:28d1f895c6fe 298 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
mbed_official 340:28d1f895c6fe 299 * is called, the the SysTick interrupt will be disabled and so Tick increment
mbed_official 340:28d1f895c6fe 300 * is suspended.
mbed_official 340:28d1f895c6fe 301 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 340:28d1f895c6fe 302 * implementations in user file.
mbed_official 340:28d1f895c6fe 303 * @retval None
mbed_official 340:28d1f895c6fe 304 */
mbed_official 340:28d1f895c6fe 305 __weak void HAL_SuspendTick(void)
mbed_official 340:28d1f895c6fe 306
mbed_official 340:28d1f895c6fe 307 {
mbed_official 340:28d1f895c6fe 308 /* Disable SysTick Interrupt */
mbed_official 340:28d1f895c6fe 309 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
mbed_official 340:28d1f895c6fe 310
mbed_official 340:28d1f895c6fe 311 }
mbed_official 340:28d1f895c6fe 312
mbed_official 340:28d1f895c6fe 313 /**
mbed_official 340:28d1f895c6fe 314 * @brief Resume Tick increment.
mbed_official 340:28d1f895c6fe 315 * @note In the default implementation , SysTick timer is the source of time base. It is
mbed_official 340:28d1f895c6fe 316 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
mbed_official 340:28d1f895c6fe 317 * is called, the the SysTick interrupt will be enabled and so Tick increment
mbed_official 340:28d1f895c6fe 318 * is resumed.
mbed_official 340:28d1f895c6fe 319 * The function is declared as __Weak to be overwritten in case of other
mbed_official 340:28d1f895c6fe 320 * implementations in user file.
mbed_official 340:28d1f895c6fe 321 * @retval None
mbed_official 340:28d1f895c6fe 322 */
mbed_official 340:28d1f895c6fe 323 __weak void HAL_ResumeTick(void)
mbed_official 340:28d1f895c6fe 324 {
mbed_official 340:28d1f895c6fe 325 /* Enable SysTick Interrupt */
mbed_official 340:28d1f895c6fe 326 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
mbed_official 340:28d1f895c6fe 327
mbed_official 340:28d1f895c6fe 328 }
mbed_official 340:28d1f895c6fe 329
mbed_official 340:28d1f895c6fe 330 /**
mbed_official 340:28d1f895c6fe 331 * @brief This function provides accurate delay (in milliseconds) based
mbed_official 340:28d1f895c6fe 332 * on variable incremented.
mbed_official 340:28d1f895c6fe 333 * @note In the default implementation , SysTick timer is the source of time base.
mbed_official 340:28d1f895c6fe 334 * It is used to generate interrupts at regular time intervals where uwTick
mbed_official 340:28d1f895c6fe 335 * is incremented.
mbed_official 340:28d1f895c6fe 336 * @note ThiS function is declared as __weak to be overwritten in case of other
mbed_official 340:28d1f895c6fe 337 * implementations in user file.
mbed_official 340:28d1f895c6fe 338 * @param Delay: specifies the delay time length, in milliseconds.
mbed_official 340:28d1f895c6fe 339 * @retval None
mbed_official 340:28d1f895c6fe 340 */
mbed_official 340:28d1f895c6fe 341 __weak void HAL_Delay(__IO uint32_t Delay)
mbed_official 340:28d1f895c6fe 342 {
mbed_official 340:28d1f895c6fe 343 uint32_t tickstart = 0;
mbed_official 340:28d1f895c6fe 344 tickstart = HAL_GetTick();
mbed_official 340:28d1f895c6fe 345 while((HAL_GetTick() - tickstart) < Delay)
mbed_official 340:28d1f895c6fe 346 {
mbed_official 340:28d1f895c6fe 347 }
mbed_official 340:28d1f895c6fe 348 }
mbed_official 340:28d1f895c6fe 349
mbed_official 340:28d1f895c6fe 350 /**
mbed_official 340:28d1f895c6fe 351 * @brief This method returns the HAL revision
mbed_official 340:28d1f895c6fe 352 * @retval version : 0xXYZR (8bits for each decimal, R for RC)
mbed_official 340:28d1f895c6fe 353 */
mbed_official 340:28d1f895c6fe 354 uint32_t HAL_GetHalVersion(void)
mbed_official 340:28d1f895c6fe 355 {
mbed_official 340:28d1f895c6fe 356 return __STM32F0xx_HAL_VERSION;
mbed_official 340:28d1f895c6fe 357 }
mbed_official 340:28d1f895c6fe 358
mbed_official 340:28d1f895c6fe 359 /**
mbed_official 340:28d1f895c6fe 360 * @brief Returns the device revision identifier.
mbed_official 340:28d1f895c6fe 361 * @retval Device revision identifier
mbed_official 340:28d1f895c6fe 362 */
mbed_official 340:28d1f895c6fe 363 uint32_t HAL_GetREVID(void)
mbed_official 340:28d1f895c6fe 364 {
mbed_official 340:28d1f895c6fe 365 return((DBGMCU->IDCODE) >> 16);
mbed_official 340:28d1f895c6fe 366 }
mbed_official 340:28d1f895c6fe 367
mbed_official 340:28d1f895c6fe 368 /**
mbed_official 340:28d1f895c6fe 369 * @brief Returns the device identifier.
mbed_official 340:28d1f895c6fe 370 * @retval Device identifier
mbed_official 340:28d1f895c6fe 371 */
mbed_official 340:28d1f895c6fe 372 uint32_t HAL_GetDEVID(void)
mbed_official 340:28d1f895c6fe 373 {
mbed_official 340:28d1f895c6fe 374 return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
mbed_official 340:28d1f895c6fe 375 }
mbed_official 340:28d1f895c6fe 376
mbed_official 340:28d1f895c6fe 377 /**
mbed_official 340:28d1f895c6fe 378 * @brief Enable the Debug Module during STOP mode
mbed_official 340:28d1f895c6fe 379 * @retval None
mbed_official 340:28d1f895c6fe 380 */
mbed_official 340:28d1f895c6fe 381 void HAL_EnableDBGStopMode(void)
mbed_official 340:28d1f895c6fe 382 {
mbed_official 340:28d1f895c6fe 383 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 340:28d1f895c6fe 384 }
mbed_official 340:28d1f895c6fe 385
mbed_official 340:28d1f895c6fe 386 /**
mbed_official 340:28d1f895c6fe 387 * @brief Disable the Debug Module during STOP mode
mbed_official 340:28d1f895c6fe 388 * @retval None
mbed_official 340:28d1f895c6fe 389 */
mbed_official 340:28d1f895c6fe 390 void HAL_DisableDBGStopMode(void)
mbed_official 340:28d1f895c6fe 391 {
mbed_official 340:28d1f895c6fe 392 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 340:28d1f895c6fe 393 }
mbed_official 340:28d1f895c6fe 394
mbed_official 340:28d1f895c6fe 395 /**
mbed_official 340:28d1f895c6fe 396 * @brief Enable the Debug Module during STANDBY mode
mbed_official 340:28d1f895c6fe 397 * @retval None
mbed_official 340:28d1f895c6fe 398 */
mbed_official 340:28d1f895c6fe 399 void HAL_EnableDBGStandbyMode(void)
mbed_official 340:28d1f895c6fe 400 {
mbed_official 340:28d1f895c6fe 401 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 340:28d1f895c6fe 402 }
mbed_official 340:28d1f895c6fe 403
mbed_official 340:28d1f895c6fe 404 /**
mbed_official 340:28d1f895c6fe 405 * @brief Disable the Debug Module during STANDBY mode
mbed_official 340:28d1f895c6fe 406 * @retval None
mbed_official 340:28d1f895c6fe 407 */
mbed_official 340:28d1f895c6fe 408 void HAL_DisableDBGStandbyMode(void)
mbed_official 340:28d1f895c6fe 409 {
mbed_official 340:28d1f895c6fe 410 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 340:28d1f895c6fe 411 }
mbed_official 340:28d1f895c6fe 412
mbed_official 340:28d1f895c6fe 413 /**
mbed_official 340:28d1f895c6fe 414 * @}
mbed_official 340:28d1f895c6fe 415 */
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 #endif /* HAL_MODULE_ENABLED */
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 /**
mbed_official 340:28d1f895c6fe 427 * @}
mbed_official 340:28d1f895c6fe 428 */
mbed_official 340:28d1f895c6fe 429
mbed_official 340:28d1f895c6fe 430 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/