SHIO

Fork of mbed-stm32l0/l1-src by lzbp li

Committer:
mbed_official
Date:
Fri Nov 07 15:45:07 2014 +0000
Revision:
394:83f921546702
Parent:
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_hal.c@354:e67efb2aab0e
Synchronized with git revision aab52cb7ec5a665869e507dd988bbfd55b7e087e

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

Tests: Fix cpputest testrunner

Who changed what in which revision?

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