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