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:
124:6a4a5b7d7324
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 stm32f1xx_hal.c
bogdanm 0:9b334a45a8ff 4 * @author MCD Application Team
mbed_official 124:6a4a5b7d7324 5 * @version V1.0.4
mbed_official 124:6a4a5b7d7324 6 * @date 29-April-2016
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 *
mbed_official 124:6a4a5b7d7324 26 * <h2><center>&copy; COPYRIGHT(c) 2016 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 "stm32f1xx_hal.h"
bogdanm 0:9b334a45a8ff 55
bogdanm 0:9b334a45a8ff 56 /** @addtogroup STM32F1xx_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_Constants HAL Private Constants
bogdanm 0:9b334a45a8ff 71 * @{
bogdanm 0:9b334a45a8ff 72 */
bogdanm 0:9b334a45a8ff 73
bogdanm 0:9b334a45a8ff 74 /**
mbed_official 124:6a4a5b7d7324 75 * @brief STM32F1xx HAL Driver version number
bogdanm 0:9b334a45a8ff 76 */
bogdanm 0:9b334a45a8ff 77 #define __STM32F1xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
bogdanm 0:9b334a45a8ff 78 #define __STM32F1xx_HAL_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
mbed_official 124:6a4a5b7d7324 79 #define __STM32F1xx_HAL_VERSION_SUB2 (0x04) /*!< [15:8] sub2 version */
bogdanm 0:9b334a45a8ff 80 #define __STM32F1xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */
bogdanm 0:9b334a45a8ff 81 #define __STM32F1xx_HAL_VERSION ((__STM32F1xx_HAL_VERSION_MAIN << 24)\
bogdanm 0:9b334a45a8ff 82 |(__STM32F1xx_HAL_VERSION_SUB1 << 16)\
bogdanm 0:9b334a45a8ff 83 |(__STM32F1xx_HAL_VERSION_SUB2 << 8 )\
bogdanm 0:9b334a45a8ff 84 |(__STM32F1xx_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 -----------------------------------------------*/
mbed_official 124:6a4a5b7d7324 106 /* Exported 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
mbed_official 124:6a4a5b7d7324 149 * @note This function is called at the beginning of program after reset and before
bogdanm 0:9b334a45a8ff 150 * the clock configuration
mbed_official 124:6a4a5b7d7324 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.
mbed_official 124:6a4a5b7d7324 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 #if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || \
bogdanm 0:9b334a45a8ff 162 defined(STM32F102x6) || defined(STM32F102xB) || \
bogdanm 0:9b334a45a8ff 163 defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || \
bogdanm 0:9b334a45a8ff 164 defined(STM32F105xC) || defined(STM32F107xC)
bogdanm 0:9b334a45a8ff 165
bogdanm 0:9b334a45a8ff 166 /* Prefetch buffer is not available on value line devices */
bogdanm 0:9b334a45a8ff 167 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
bogdanm 0:9b334a45a8ff 168 #endif
bogdanm 0:9b334a45a8ff 169 #endif /* PREFETCH_ENABLE */
bogdanm 0:9b334a45a8ff 170
bogdanm 0:9b334a45a8ff 171 /* Set Interrupt Group Priority */
bogdanm 0:9b334a45a8ff 172 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
bogdanm 0:9b334a45a8ff 173
bogdanm 0:9b334a45a8ff 174 /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */
bogdanm 0:9b334a45a8ff 175 HAL_InitTick(TICK_INT_PRIORITY);
bogdanm 0:9b334a45a8ff 176
bogdanm 0:9b334a45a8ff 177 /* Init the low level hardware */
bogdanm 0:9b334a45a8ff 178 HAL_MspInit();
bogdanm 0:9b334a45a8ff 179
bogdanm 0:9b334a45a8ff 180 /* Return function status */
bogdanm 0:9b334a45a8ff 181 return HAL_OK;
bogdanm 0:9b334a45a8ff 182 }
bogdanm 0:9b334a45a8ff 183
bogdanm 0:9b334a45a8ff 184 /**
bogdanm 0:9b334a45a8ff 185 * @brief This function de-Initializes common part of the HAL and stops the source
bogdanm 0:9b334a45a8ff 186 * of time base.
mbed_official 124:6a4a5b7d7324 187 * @note This function is optional.
bogdanm 0:9b334a45a8ff 188 * @retval HAL status
bogdanm 0:9b334a45a8ff 189 */
bogdanm 0:9b334a45a8ff 190 HAL_StatusTypeDef HAL_DeInit(void)
bogdanm 0:9b334a45a8ff 191 {
bogdanm 0:9b334a45a8ff 192 /* Reset of all peripherals */
bogdanm 0:9b334a45a8ff 193 __HAL_RCC_APB1_FORCE_RESET();
bogdanm 0:9b334a45a8ff 194 __HAL_RCC_APB1_RELEASE_RESET();
bogdanm 0:9b334a45a8ff 195
bogdanm 0:9b334a45a8ff 196 __HAL_RCC_APB2_FORCE_RESET();
bogdanm 0:9b334a45a8ff 197 __HAL_RCC_APB2_RELEASE_RESET();
bogdanm 0:9b334a45a8ff 198
bogdanm 0:9b334a45a8ff 199 #if defined(STM32F105xC) || defined(STM32F107xC)
bogdanm 0:9b334a45a8ff 200 __HAL_RCC_AHB_FORCE_RESET();
bogdanm 0:9b334a45a8ff 201 __HAL_RCC_AHB_RELEASE_RESET();
bogdanm 0:9b334a45a8ff 202 #endif
bogdanm 0:9b334a45a8ff 203
bogdanm 0:9b334a45a8ff 204 /* De-Init the low level hardware */
bogdanm 0:9b334a45a8ff 205 HAL_MspDeInit();
bogdanm 0:9b334a45a8ff 206
bogdanm 0:9b334a45a8ff 207 /* Return function status */
bogdanm 0:9b334a45a8ff 208 return HAL_OK;
bogdanm 0:9b334a45a8ff 209 }
bogdanm 0:9b334a45a8ff 210
bogdanm 0:9b334a45a8ff 211 /**
bogdanm 0:9b334a45a8ff 212 * @brief Initializes the MSP.
bogdanm 0:9b334a45a8ff 213 * @retval None
bogdanm 0:9b334a45a8ff 214 */
bogdanm 0:9b334a45a8ff 215 __weak void HAL_MspInit(void)
bogdanm 0:9b334a45a8ff 216 {
bogdanm 0:9b334a45a8ff 217 /* NOTE : This function Should not be modified, when the callback is needed,
bogdanm 0:9b334a45a8ff 218 the HAL_MspInit could be implemented in the user file
bogdanm 0:9b334a45a8ff 219 */
bogdanm 0:9b334a45a8ff 220 }
bogdanm 0:9b334a45a8ff 221
bogdanm 0:9b334a45a8ff 222 /**
bogdanm 0:9b334a45a8ff 223 * @brief DeInitializes the MSP.
bogdanm 0:9b334a45a8ff 224 * @retval None
bogdanm 0:9b334a45a8ff 225 */
bogdanm 0:9b334a45a8ff 226 __weak void HAL_MspDeInit(void)
bogdanm 0:9b334a45a8ff 227 {
bogdanm 0:9b334a45a8ff 228 /* NOTE : This function Should not be modified, when the callback is needed,
bogdanm 0:9b334a45a8ff 229 the HAL_MspDeInit could be implemented in the user file
bogdanm 0:9b334a45a8ff 230 */
bogdanm 0:9b334a45a8ff 231 }
bogdanm 0:9b334a45a8ff 232
bogdanm 0:9b334a45a8ff 233 /**
bogdanm 0:9b334a45a8ff 234 * @brief This function configures the source of the time base.
bogdanm 0:9b334a45a8ff 235 * The time source is configured to have 1ms time base with a dedicated
bogdanm 0:9b334a45a8ff 236 * Tick interrupt priority.
mbed_official 124:6a4a5b7d7324 237 * @note This function is called automatically at the beginning of program after
bogdanm 0:9b334a45a8ff 238 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
mbed_official 124:6a4a5b7d7324 239 * @note In the default implementation, SysTick timer is the source of time base.
bogdanm 0:9b334a45a8ff 240 * It is used to generate interrupts at regular time intervals.
bogdanm 0:9b334a45a8ff 241 * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
bogdanm 0:9b334a45a8ff 242 * The the SysTick interrupt must have higher priority (numerically lower)
bogdanm 0:9b334a45a8ff 243 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
bogdanm 0:9b334a45a8ff 244 * The function is declared as __Weak to be overwritten in case of other
bogdanm 0:9b334a45a8ff 245 * implementation in user file.
bogdanm 0:9b334a45a8ff 246 * @param TickPriority: Tick interrupt priority.
bogdanm 0:9b334a45a8ff 247 * @retval HAL status
bogdanm 0:9b334a45a8ff 248 */
bogdanm 0:9b334a45a8ff 249 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
bogdanm 0:9b334a45a8ff 250 {
bogdanm 0:9b334a45a8ff 251 /*Configure the SysTick to have interrupt in 1ms time basis*/
bogdanm 0:9b334a45a8ff 252 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
bogdanm 0:9b334a45a8ff 253
bogdanm 0:9b334a45a8ff 254 /*Configure the SysTick IRQ priority */
bogdanm 0:9b334a45a8ff 255 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
bogdanm 0:9b334a45a8ff 256
bogdanm 0:9b334a45a8ff 257 /* Return function status */
bogdanm 0:9b334a45a8ff 258 return HAL_OK;
bogdanm 0:9b334a45a8ff 259 }
bogdanm 0:9b334a45a8ff 260
bogdanm 0:9b334a45a8ff 261 /**
bogdanm 0:9b334a45a8ff 262 * @}
bogdanm 0:9b334a45a8ff 263 */
bogdanm 0:9b334a45a8ff 264
bogdanm 0:9b334a45a8ff 265 /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
bogdanm 0:9b334a45a8ff 266 * @brief HAL Control functions
bogdanm 0:9b334a45a8ff 267 *
bogdanm 0:9b334a45a8ff 268 @verbatim
bogdanm 0:9b334a45a8ff 269 ===============================================================================
bogdanm 0:9b334a45a8ff 270 ##### HAL Control functions #####
bogdanm 0:9b334a45a8ff 271 ===============================================================================
bogdanm 0:9b334a45a8ff 272 [..] This section provides functions allowing to:
bogdanm 0:9b334a45a8ff 273 (+) Provide a tick value in millisecond
bogdanm 0:9b334a45a8ff 274 (+) Provide a blocking delay in millisecond
bogdanm 0:9b334a45a8ff 275 (+) Suspend the time base source interrupt
bogdanm 0:9b334a45a8ff 276 (+) Resume the time base source interrupt
bogdanm 0:9b334a45a8ff 277 (+) Get the HAL API driver version
bogdanm 0:9b334a45a8ff 278 (+) Get the device identifier
bogdanm 0:9b334a45a8ff 279 (+) Get the device revision identifier
bogdanm 0:9b334a45a8ff 280 (+) Enable/Disable Debug module during Sleep mode
bogdanm 0:9b334a45a8ff 281 (+) Enable/Disable Debug module during STOP mode
bogdanm 0:9b334a45a8ff 282 (+) Enable/Disable Debug module during STANDBY mode
bogdanm 0:9b334a45a8ff 283
bogdanm 0:9b334a45a8ff 284 @endverbatim
bogdanm 0:9b334a45a8ff 285 * @{
bogdanm 0:9b334a45a8ff 286 */
bogdanm 0:9b334a45a8ff 287
bogdanm 0:9b334a45a8ff 288 /**
bogdanm 0:9b334a45a8ff 289 * @brief This function is called to increment a global variable "uwTick"
bogdanm 0:9b334a45a8ff 290 * used as application time base.
mbed_official 124:6a4a5b7d7324 291 * @note In the default implementation, this variable is incremented each 1ms
bogdanm 0:9b334a45a8ff 292 * in Systick ISR.
mbed_official 124:6a4a5b7d7324 293 * @note This function is declared as __weak to be overwritten in case of other
bogdanm 0:9b334a45a8ff 294 * implementations in user file.
bogdanm 0:9b334a45a8ff 295 * @retval None
bogdanm 0:9b334a45a8ff 296 */
bogdanm 0:9b334a45a8ff 297 __weak void HAL_IncTick(void)
bogdanm 0:9b334a45a8ff 298 {
bogdanm 0:9b334a45a8ff 299 uwTick++;
bogdanm 0:9b334a45a8ff 300 }
bogdanm 0:9b334a45a8ff 301
bogdanm 0:9b334a45a8ff 302 /**
bogdanm 0:9b334a45a8ff 303 * @brief Provides a tick value in millisecond.
mbed_official 124:6a4a5b7d7324 304 * @note This function is declared as __weak to be overwritten in case of other
bogdanm 0:9b334a45a8ff 305 * implementations in user file.
bogdanm 0:9b334a45a8ff 306 * @retval tick value
bogdanm 0:9b334a45a8ff 307 */
bogdanm 0:9b334a45a8ff 308 __weak uint32_t HAL_GetTick(void)
bogdanm 0:9b334a45a8ff 309 {
bogdanm 0:9b334a45a8ff 310 return uwTick;
bogdanm 0:9b334a45a8ff 311 }
bogdanm 0:9b334a45a8ff 312
bogdanm 0:9b334a45a8ff 313 /**
bogdanm 0:9b334a45a8ff 314 * @brief This function provides accurate delay (in milliseconds) based
bogdanm 0:9b334a45a8ff 315 * on variable incremented.
mbed_official 124:6a4a5b7d7324 316 * @note In the default implementation , SysTick timer is the source of time base.
bogdanm 0:9b334a45a8ff 317 * It is used to generate interrupts at regular time intervals where uwTick
bogdanm 0:9b334a45a8ff 318 * is incremented.
mbed_official 124:6a4a5b7d7324 319 * @note ThiS function is declared as __weak to be overwritten in case of other
bogdanm 0:9b334a45a8ff 320 * implementations in user file.
bogdanm 0:9b334a45a8ff 321 * @param Delay: specifies the delay time length, in milliseconds.
bogdanm 0:9b334a45a8ff 322 * @retval None
bogdanm 0:9b334a45a8ff 323 */
bogdanm 0:9b334a45a8ff 324 __weak void HAL_Delay(__IO uint32_t Delay)
bogdanm 0:9b334a45a8ff 325 {
bogdanm 0:9b334a45a8ff 326 uint32_t tickstart = 0;
bogdanm 0:9b334a45a8ff 327 tickstart = HAL_GetTick();
bogdanm 0:9b334a45a8ff 328 while((HAL_GetTick() - tickstart) < Delay)
bogdanm 0:9b334a45a8ff 329 {
bogdanm 0:9b334a45a8ff 330 }
bogdanm 0:9b334a45a8ff 331 }
bogdanm 0:9b334a45a8ff 332
bogdanm 0:9b334a45a8ff 333 /**
bogdanm 0:9b334a45a8ff 334 * @brief Suspend Tick increment.
mbed_official 124:6a4a5b7d7324 335 * @note In the default implementation , SysTick timer is the source of time base. It is
bogdanm 0:9b334a45a8ff 336 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
bogdanm 0:9b334a45a8ff 337 * is called, the the SysTick interrupt will be disabled and so Tick increment
bogdanm 0:9b334a45a8ff 338 * is suspended.
mbed_official 124:6a4a5b7d7324 339 * @note This function is declared as __weak to be overwritten in case of other
bogdanm 0:9b334a45a8ff 340 * implementations in user file.
bogdanm 0:9b334a45a8ff 341 * @retval None
bogdanm 0:9b334a45a8ff 342 */
bogdanm 0:9b334a45a8ff 343 __weak void HAL_SuspendTick(void)
bogdanm 0:9b334a45a8ff 344 {
bogdanm 0:9b334a45a8ff 345 /* Disable SysTick Interrupt */
bogdanm 0:9b334a45a8ff 346 CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
bogdanm 0:9b334a45a8ff 347 }
bogdanm 0:9b334a45a8ff 348
bogdanm 0:9b334a45a8ff 349 /**
bogdanm 0:9b334a45a8ff 350 * @brief Resume Tick increment.
mbed_official 124:6a4a5b7d7324 351 * @note In the default implementation , SysTick timer is the source of time base. It is
bogdanm 0:9b334a45a8ff 352 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
bogdanm 0:9b334a45a8ff 353 * is called, the the SysTick interrupt will be enabled and so Tick increment
bogdanm 0:9b334a45a8ff 354 * is resumed.
mbed_official 124:6a4a5b7d7324 355 * @note This function is declared as __weak to be overwritten in case of other
bogdanm 0:9b334a45a8ff 356 * implementations in user file.
bogdanm 0:9b334a45a8ff 357 * @retval None
bogdanm 0:9b334a45a8ff 358 */
bogdanm 0:9b334a45a8ff 359 __weak void HAL_ResumeTick(void)
bogdanm 0:9b334a45a8ff 360 {
bogdanm 0:9b334a45a8ff 361 /* Enable SysTick Interrupt */
bogdanm 0:9b334a45a8ff 362 SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
bogdanm 0:9b334a45a8ff 363 }
bogdanm 0:9b334a45a8ff 364
bogdanm 0:9b334a45a8ff 365 /**
mbed_official 124:6a4a5b7d7324 366 * @brief This method returns the HAL revision
bogdanm 0:9b334a45a8ff 367 * @retval version: 0xXYZR (8bits for each decimal, R for RC)
bogdanm 0:9b334a45a8ff 368 */
bogdanm 0:9b334a45a8ff 369 uint32_t HAL_GetHalVersion(void)
bogdanm 0:9b334a45a8ff 370 {
bogdanm 0:9b334a45a8ff 371 return __STM32F1xx_HAL_VERSION;
bogdanm 0:9b334a45a8ff 372 }
bogdanm 0:9b334a45a8ff 373
bogdanm 0:9b334a45a8ff 374 /**
bogdanm 0:9b334a45a8ff 375 * @brief Returns the device revision identifier.
bogdanm 0:9b334a45a8ff 376 * Note: On devices STM32F10xx8 and STM32F10xxB,
bogdanm 0:9b334a45a8ff 377 * STM32F101xC/D/E and STM32F103xC/D/E,
bogdanm 0:9b334a45a8ff 378 * STM32F101xF/G and STM32F103xF/G
bogdanm 0:9b334a45a8ff 379 * STM32F10xx4 and STM32F10xx6
bogdanm 0:9b334a45a8ff 380 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
bogdanm 0:9b334a45a8ff 381 * debug mode (not accessible by the user software in normal mode).
bogdanm 0:9b334a45a8ff 382 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 383 * @retval Device revision identifier
bogdanm 0:9b334a45a8ff 384 */
bogdanm 0:9b334a45a8ff 385 uint32_t HAL_GetREVID(void)
bogdanm 0:9b334a45a8ff 386 {
bogdanm 0:9b334a45a8ff 387 return((DBGMCU->IDCODE) >> POSITION_VAL(DBGMCU_IDCODE_REV_ID));
bogdanm 0:9b334a45a8ff 388 }
bogdanm 0:9b334a45a8ff 389
bogdanm 0:9b334a45a8ff 390 /**
bogdanm 0:9b334a45a8ff 391 * @brief Returns the device identifier.
bogdanm 0:9b334a45a8ff 392 * Note: On devices STM32F10xx8 and STM32F10xxB,
bogdanm 0:9b334a45a8ff 393 * STM32F101xC/D/E and STM32F103xC/D/E,
bogdanm 0:9b334a45a8ff 394 * STM32F101xF/G and STM32F103xF/G
bogdanm 0:9b334a45a8ff 395 * STM32F10xx4 and STM32F10xx6
bogdanm 0:9b334a45a8ff 396 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
bogdanm 0:9b334a45a8ff 397 * debug mode (not accessible by the user software in normal mode).
bogdanm 0:9b334a45a8ff 398 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 399 * @retval Device identifier
bogdanm 0:9b334a45a8ff 400 */
bogdanm 0:9b334a45a8ff 401 uint32_t HAL_GetDEVID(void)
bogdanm 0:9b334a45a8ff 402 {
bogdanm 0:9b334a45a8ff 403 return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
bogdanm 0:9b334a45a8ff 404 }
bogdanm 0:9b334a45a8ff 405
bogdanm 0:9b334a45a8ff 406 /**
bogdanm 0:9b334a45a8ff 407 * @brief Enable the Debug Module during SLEEP mode
bogdanm 0:9b334a45a8ff 408 * @retval None
bogdanm 0:9b334a45a8ff 409 */
bogdanm 0:9b334a45a8ff 410 void HAL_DBGMCU_EnableDBGSleepMode(void)
bogdanm 0:9b334a45a8ff 411 {
bogdanm 0:9b334a45a8ff 412 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
bogdanm 0:9b334a45a8ff 413 }
bogdanm 0:9b334a45a8ff 414
bogdanm 0:9b334a45a8ff 415 /**
bogdanm 0:9b334a45a8ff 416 * @brief Disable the Debug Module during SLEEP mode
bogdanm 0:9b334a45a8ff 417 * Note: On devices STM32F10xx8 and STM32F10xxB,
bogdanm 0:9b334a45a8ff 418 * STM32F101xC/D/E and STM32F103xC/D/E,
bogdanm 0:9b334a45a8ff 419 * STM32F101xF/G and STM32F103xF/G
bogdanm 0:9b334a45a8ff 420 * STM32F10xx4 and STM32F10xx6
bogdanm 0:9b334a45a8ff 421 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
bogdanm 0:9b334a45a8ff 422 * debug mode (not accessible by the user software in normal mode).
bogdanm 0:9b334a45a8ff 423 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 424 * @retval None
bogdanm 0:9b334a45a8ff 425 */
bogdanm 0:9b334a45a8ff 426 void HAL_DBGMCU_DisableDBGSleepMode(void)
bogdanm 0:9b334a45a8ff 427 {
bogdanm 0:9b334a45a8ff 428 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
bogdanm 0:9b334a45a8ff 429 }
bogdanm 0:9b334a45a8ff 430
bogdanm 0:9b334a45a8ff 431 /**
bogdanm 0:9b334a45a8ff 432 * @brief Enable the Debug Module during STOP mode
bogdanm 0:9b334a45a8ff 433 * Note: On devices STM32F10xx8 and STM32F10xxB,
bogdanm 0:9b334a45a8ff 434 * STM32F101xC/D/E and STM32F103xC/D/E,
bogdanm 0:9b334a45a8ff 435 * STM32F101xF/G and STM32F103xF/G
bogdanm 0:9b334a45a8ff 436 * STM32F10xx4 and STM32F10xx6
bogdanm 0:9b334a45a8ff 437 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
bogdanm 0:9b334a45a8ff 438 * debug mode (not accessible by the user software in normal mode).
bogdanm 0:9b334a45a8ff 439 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 440 * Note: On all STM32F1 devices:
bogdanm 0:9b334a45a8ff 441 * If the system tick timer interrupt is enabled during the Stop mode
bogdanm 0:9b334a45a8ff 442 * debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
bogdanm 0:9b334a45a8ff 443 * the system from Stop mode.
bogdanm 0:9b334a45a8ff 444 * Workaround: To debug the Stop mode, disable the system tick timer
bogdanm 0:9b334a45a8ff 445 * interrupt.
bogdanm 0:9b334a45a8ff 446 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 447 * Note: On all STM32F1 devices:
bogdanm 0:9b334a45a8ff 448 * If the system tick timer interrupt is enabled during the Stop mode
bogdanm 0:9b334a45a8ff 449 * debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
bogdanm 0:9b334a45a8ff 450 * the system from Stop mode.
bogdanm 0:9b334a45a8ff 451 * Workaround: To debug the Stop mode, disable the system tick timer
bogdanm 0:9b334a45a8ff 452 * interrupt.
bogdanm 0:9b334a45a8ff 453 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 454 * @retval None
bogdanm 0:9b334a45a8ff 455 */
bogdanm 0:9b334a45a8ff 456 void HAL_DBGMCU_EnableDBGStopMode(void)
bogdanm 0:9b334a45a8ff 457 {
bogdanm 0:9b334a45a8ff 458 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
bogdanm 0:9b334a45a8ff 459 }
bogdanm 0:9b334a45a8ff 460
bogdanm 0:9b334a45a8ff 461 /**
bogdanm 0:9b334a45a8ff 462 * @brief Disable the Debug Module during STOP mode
bogdanm 0:9b334a45a8ff 463 * Note: On devices STM32F10xx8 and STM32F10xxB,
bogdanm 0:9b334a45a8ff 464 * STM32F101xC/D/E and STM32F103xC/D/E,
bogdanm 0:9b334a45a8ff 465 * STM32F101xF/G and STM32F103xF/G
bogdanm 0:9b334a45a8ff 466 * STM32F10xx4 and STM32F10xx6
bogdanm 0:9b334a45a8ff 467 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
bogdanm 0:9b334a45a8ff 468 * debug mode (not accessible by the user software in normal mode).
bogdanm 0:9b334a45a8ff 469 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 470 * @retval None
bogdanm 0:9b334a45a8ff 471 */
bogdanm 0:9b334a45a8ff 472 void HAL_DBGMCU_DisableDBGStopMode(void)
bogdanm 0:9b334a45a8ff 473 {
bogdanm 0:9b334a45a8ff 474 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
bogdanm 0:9b334a45a8ff 475 }
bogdanm 0:9b334a45a8ff 476
bogdanm 0:9b334a45a8ff 477 /**
bogdanm 0:9b334a45a8ff 478 * @brief Enable the Debug Module during STANDBY mode
bogdanm 0:9b334a45a8ff 479 * Note: On devices STM32F10xx8 and STM32F10xxB,
bogdanm 0:9b334a45a8ff 480 * STM32F101xC/D/E and STM32F103xC/D/E,
bogdanm 0:9b334a45a8ff 481 * STM32F101xF/G and STM32F103xF/G
bogdanm 0:9b334a45a8ff 482 * STM32F10xx4 and STM32F10xx6
bogdanm 0:9b334a45a8ff 483 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
bogdanm 0:9b334a45a8ff 484 * debug mode (not accessible by the user software in normal mode).
bogdanm 0:9b334a45a8ff 485 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 486 * @retval None
bogdanm 0:9b334a45a8ff 487 */
bogdanm 0:9b334a45a8ff 488 void HAL_DBGMCU_EnableDBGStandbyMode(void)
bogdanm 0:9b334a45a8ff 489 {
bogdanm 0:9b334a45a8ff 490 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
bogdanm 0:9b334a45a8ff 491 }
bogdanm 0:9b334a45a8ff 492
bogdanm 0:9b334a45a8ff 493 /**
bogdanm 0:9b334a45a8ff 494 * @brief Disable the Debug Module during STANDBY mode
bogdanm 0:9b334a45a8ff 495 * Note: On devices STM32F10xx8 and STM32F10xxB,
bogdanm 0:9b334a45a8ff 496 * STM32F101xC/D/E and STM32F103xC/D/E,
bogdanm 0:9b334a45a8ff 497 * STM32F101xF/G and STM32F103xF/G
bogdanm 0:9b334a45a8ff 498 * STM32F10xx4 and STM32F10xx6
bogdanm 0:9b334a45a8ff 499 * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
bogdanm 0:9b334a45a8ff 500 * debug mode (not accessible by the user software in normal mode).
bogdanm 0:9b334a45a8ff 501 * Refer to errata sheet of these devices for more details.
bogdanm 0:9b334a45a8ff 502 * @retval None
bogdanm 0:9b334a45a8ff 503 */
bogdanm 0:9b334a45a8ff 504 void HAL_DBGMCU_DisableDBGStandbyMode(void)
bogdanm 0:9b334a45a8ff 505 {
bogdanm 0:9b334a45a8ff 506 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
bogdanm 0:9b334a45a8ff 507 }
bogdanm 0:9b334a45a8ff 508
bogdanm 0:9b334a45a8ff 509 /**
bogdanm 0:9b334a45a8ff 510 * @}
bogdanm 0:9b334a45a8ff 511 */
bogdanm 0:9b334a45a8ff 512
bogdanm 0:9b334a45a8ff 513 /**
bogdanm 0:9b334a45a8ff 514 * @}
bogdanm 0:9b334a45a8ff 515 */
bogdanm 0:9b334a45a8ff 516
bogdanm 0:9b334a45a8ff 517 #endif /* HAL_MODULE_ENABLED */
bogdanm 0:9b334a45a8ff 518 /**
bogdanm 0:9b334a45a8ff 519 * @}
bogdanm 0:9b334a45a8ff 520 */
bogdanm 0:9b334a45a8ff 521
bogdanm 0:9b334a45a8ff 522 /**
bogdanm 0:9b334a45a8ff 523 * @}
bogdanm 0:9b334a45a8ff 524 */
bogdanm 0:9b334a45a8ff 525
bogdanm 0:9b334a45a8ff 526 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/