fix LPC812 PWM

Dependents:   IR_LED_Send

Fork of mbed-dev by mbed official

Committer:
nameless129
Date:
Mon May 16 16:50:30 2016 +0000
Revision:
129:2e517c56bcfb
Parent:
0:9b334a45a8ff
PWM Fix:Duty 0%??H???????????????

Who changed what in which revision?

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