mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

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

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

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

Import librarymbed

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

Committer:
mbed_official
Date:
Wed Aug 06 08:15:07 2014 +0100
Revision:
274:6937b19af361
Parent:
226:b062af740e40
Child:
369:2e96f1b71984
Synchronized with git revision 5b145e4f6c509376173c3ea2aa35a6da879a2124

Full URL: https://github.com/mbedmicro/mbed/commit/5b145e4f6c509376173c3ea2aa35a6da879a2124/

[TARGET_LPC11UXX] PeripheralNames.h and PinMap definitions separation for LPC11UXX platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 87:085cde657901 1 /**
mbed_official 87:085cde657901 2 ******************************************************************************
mbed_official 87:085cde657901 3 * @file stm32f4xx_hal.c
mbed_official 87:085cde657901 4 * @author MCD Application Team
mbed_official 226:b062af740e40 5 * @version V1.1.0RC2
mbed_official 226:b062af740e40 6 * @date 14-May-2014
mbed_official 87:085cde657901 7 * @brief HAL module driver.
mbed_official 87:085cde657901 8 * This is the common part of the HAL initialization
mbed_official 226:b062af740e40 9 *
mbed_official 87:085cde657901 10 @verbatim
mbed_official 87:085cde657901 11 ==============================================================================
mbed_official 87:085cde657901 12 ##### How to use this driver #####
mbed_official 87:085cde657901 13 ==============================================================================
mbed_official 87:085cde657901 14 [..]
mbed_official 87:085cde657901 15 The common HAL driver contains a set of generic and common APIs that can be
mbed_official 87:085cde657901 16 used by the PPP peripheral drivers and the user to start using the HAL.
mbed_official 87:085cde657901 17 [..]
mbed_official 226:b062af740e40 18 The HAL contains two APIs' categories:
mbed_official 87:085cde657901 19 (+) Common HAL APIs
mbed_official 87:085cde657901 20 (+) Services HAL APIs
mbed_official 87:085cde657901 21
mbed_official 87:085cde657901 22 @endverbatim
mbed_official 87:085cde657901 23 ******************************************************************************
mbed_official 87:085cde657901 24 * @attention
mbed_official 87:085cde657901 25 *
mbed_official 87:085cde657901 26 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 87:085cde657901 27 *
mbed_official 87:085cde657901 28 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 87:085cde657901 29 * are permitted provided that the following conditions are met:
mbed_official 87:085cde657901 30 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 87:085cde657901 31 * this list of conditions and the following disclaimer.
mbed_official 87:085cde657901 32 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 87:085cde657901 33 * this list of conditions and the following disclaimer in the documentation
mbed_official 87:085cde657901 34 * and/or other materials provided with the distribution.
mbed_official 87:085cde657901 35 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 87:085cde657901 36 * may be used to endorse or promote products derived from this software
mbed_official 87:085cde657901 37 * without specific prior written permission.
mbed_official 87:085cde657901 38 *
mbed_official 87:085cde657901 39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 87:085cde657901 40 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 87:085cde657901 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 87:085cde657901 42 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 87:085cde657901 43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 87:085cde657901 44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 87:085cde657901 45 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 87:085cde657901 46 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 87:085cde657901 47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 87:085cde657901 48 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 87:085cde657901 49 *
mbed_official 87:085cde657901 50 ******************************************************************************
mbed_official 87:085cde657901 51 */
mbed_official 87:085cde657901 52
mbed_official 87:085cde657901 53 /* Includes ------------------------------------------------------------------*/
mbed_official 87:085cde657901 54 #include "stm32f4xx_hal.h"
mbed_official 87:085cde657901 55
mbed_official 87:085cde657901 56 /** @addtogroup STM32F4xx_HAL_Driver
mbed_official 87:085cde657901 57 * @{
mbed_official 87:085cde657901 58 */
mbed_official 87:085cde657901 59
mbed_official 87:085cde657901 60 /** @defgroup HAL
mbed_official 87:085cde657901 61 * @brief HAL module driver.
mbed_official 87:085cde657901 62 * @{
mbed_official 87:085cde657901 63 */
mbed_official 87:085cde657901 64
mbed_official 87:085cde657901 65 /* Private typedef -----------------------------------------------------------*/
mbed_official 87:085cde657901 66 /* Private define ------------------------------------------------------------*/
mbed_official 87:085cde657901 67 /**
mbed_official 226:b062af740e40 68 * @brief STM32F4xx HAL Driver version number V1.1.0RC2
mbed_official 87:085cde657901 69 */
mbed_official 87:085cde657901 70 #define __STM32F4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
mbed_official 226:b062af740e40 71 #define __STM32F4xx_HAL_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */
mbed_official 87:085cde657901 72 #define __STM32F4xx_HAL_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
mbed_official 226:b062af740e40 73 #define __STM32F4xx_HAL_VERSION_RC (0x02) /*!< [7:0] release candidate */
mbed_official 87:085cde657901 74 #define __STM32F4xx_HAL_VERSION ((__STM32F4xx_HAL_VERSION_MAIN << 24)\
mbed_official 87:085cde657901 75 |(__STM32F4xx_HAL_VERSION_SUB1 << 16)\
mbed_official 87:085cde657901 76 |(__STM32F4xx_HAL_VERSION_SUB2 << 8 )\
mbed_official 87:085cde657901 77 |(__STM32F4xx_HAL_VERSION_RC))
mbed_official 87:085cde657901 78
mbed_official 87:085cde657901 79 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
mbed_official 87:085cde657901 80
mbed_official 87:085cde657901 81 /* ------------ RCC registers bit address in the alias region ----------- */
mbed_official 87:085cde657901 82 #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE)
mbed_official 87:085cde657901 83 /* --- MEMRMP Register ---*/
mbed_official 87:085cde657901 84 /* Alias word address of UFB_MODE bit */
mbed_official 87:085cde657901 85 #define MEMRMP_OFFSET SYSCFG_OFFSET
mbed_official 87:085cde657901 86 #define UFB_MODE_BitNumber ((uint8_t)0x8)
mbed_official 87:085cde657901 87 #define UFB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (UFB_MODE_BitNumber * 4))
mbed_official 87:085cde657901 88
mbed_official 87:085cde657901 89 /* --- CMPCR Register ---*/
mbed_official 87:085cde657901 90 /* Alias word address of CMP_PD bit */
mbed_official 87:085cde657901 91 #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20)
mbed_official 87:085cde657901 92 #define CMP_PD_BitNumber ((uint8_t)0x00)
mbed_official 226:b062af740e40 93 #define CMPCR_CMP_PD_BB (PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BitNumber * 4))
mbed_official 87:085cde657901 94 /* Private macro -------------------------------------------------------------*/
mbed_official 87:085cde657901 95 /* Private variables ---------------------------------------------------------*/
mbed_official 87:085cde657901 96 static __IO uint32_t uwTick;
mbed_official 106:ced8cbb51063 97
mbed_official 87:085cde657901 98 /* Private function prototypes -----------------------------------------------*/
mbed_official 87:085cde657901 99 /* Private functions ---------------------------------------------------------*/
mbed_official 87:085cde657901 100
mbed_official 87:085cde657901 101 /** @defgroup HAL_Private_Functions
mbed_official 87:085cde657901 102 * @{
mbed_official 87:085cde657901 103 */
mbed_official 87:085cde657901 104
mbed_official 87:085cde657901 105 /** @defgroup HAL_Group1 Initialization and de-initialization Functions
mbed_official 87:085cde657901 106 * @brief Initialization and de-initialization functions
mbed_official 87:085cde657901 107 *
mbed_official 87:085cde657901 108 @verbatim
mbed_official 87:085cde657901 109 ===============================================================================
mbed_official 87:085cde657901 110 ##### Initialization and de-initialization functions #####
mbed_official 87:085cde657901 111 ===============================================================================
mbed_official 87:085cde657901 112 [..] This section provides functions allowing to:
mbed_official 87:085cde657901 113 (+) Initializes the Flash interface the NVIC allocation and initial clock
mbed_official 87:085cde657901 114 configuration. It initializes the systick also when timeout is needed
mbed_official 87:085cde657901 115 and the backup domain when enabled.
mbed_official 87:085cde657901 116 (+) de-Initializes common part of the HAL
mbed_official 226:b062af740e40 117 (+) Configure The time base source to have 1ms time base with a dedicated
mbed_official 226:b062af740e40 118 Tick interrupt priority.
mbed_official 226:b062af740e40 119 (++) Systick timer is used by default as source of time base, but user
mbed_official 226:b062af740e40 120 can eventually implement his proper time base source (a general purpose
mbed_official 226:b062af740e40 121 timer for example or other time source), keeping in mind that Time base
mbed_official 226:b062af740e40 122 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
mbed_official 226:b062af740e40 123 handled in milliseconds basis.
mbed_official 226:b062af740e40 124 (++) Time base configuration function (HAL_InitTick ()) is called automatically
mbed_official 226:b062af740e40 125 at the beginning of the program after reset by HAL_Init() or at any time
mbed_official 226:b062af740e40 126 when clock is configured, by HAL_RCC_ClockConfig().
mbed_official 226:b062af740e40 127 (++) Source of time base is configured to generate interrupts at regular
mbed_official 226:b062af740e40 128 time intervals. Care must be taken if HAL_Delay() is called from a
mbed_official 226:b062af740e40 129 peripheral ISR process, the Tick interrupt line must have higher priority
mbed_official 226:b062af740e40 130 (numerically lower) than the peripheral interrupt. Otherwise the caller
mbed_official 226:b062af740e40 131 ISR process will be blocked.
mbed_official 226:b062af740e40 132 (++) functions affecting time base configurations are declared as __weak
mbed_official 226:b062af740e40 133 to make override possible in case of other implementations in user file.
mbed_official 87:085cde657901 134 @endverbatim
mbed_official 87:085cde657901 135 * @{
mbed_official 87:085cde657901 136 */
mbed_official 87:085cde657901 137
mbed_official 87:085cde657901 138 /**
mbed_official 106:ced8cbb51063 139 * @brief This function is used to initialize the HAL Library; it must be the first
mbed_official 106:ced8cbb51063 140 * instruction to be executed in the main program (before to call any other
mbed_official 106:ced8cbb51063 141 * HAL function), it performs the following:
mbed_official 226:b062af740e40 142 * Configure the Flash prefetch, instruction and Data caches.
mbed_official 226:b062af740e40 143 * Configures the SysTick to generate an interrupt each 1 millisecond,
mbed_official 226:b062af740e40 144 * which is clocked by the HSI (at this stage, the clock is not yet
mbed_official 226:b062af740e40 145 * configured and thus the system is running from the internal HSI at 16 MHz).
mbed_official 226:b062af740e40 146 * Set NVIC Group Priority to 4.
mbed_official 226:b062af740e40 147 * Calls the HAL_MspInit() callback function defined in user file
mbed_official 226:b062af740e40 148 * "stm32f4xx_hal_msp.c" to do the global low level hardware initialization
mbed_official 87:085cde657901 149 *
mbed_official 106:ced8cbb51063 150 * @note SysTick is used as time base for the HAL_Delay() function, the application
mbed_official 106:ced8cbb51063 151 * need to ensure that the SysTick time base is always set to 1 millisecond
mbed_official 106:ced8cbb51063 152 * to have correct HAL operation.
mbed_official 87:085cde657901 153 * @param None
mbed_official 87:085cde657901 154 * @retval HAL status
mbed_official 87:085cde657901 155 */
mbed_official 87:085cde657901 156 HAL_StatusTypeDef HAL_Init(void)
mbed_official 87:085cde657901 157 {
mbed_official 87:085cde657901 158 /* Configure Flash prefetch, Instruction cache, Data cache */
mbed_official 87:085cde657901 159 #if (INSTRUCTION_CACHE_ENABLE != 0)
mbed_official 87:085cde657901 160 __HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
mbed_official 87:085cde657901 161 #endif /* INSTRUCTION_CACHE_ENABLE */
mbed_official 87:085cde657901 162
mbed_official 87:085cde657901 163 #if (DATA_CACHE_ENABLE != 0)
mbed_official 87:085cde657901 164 __HAL_FLASH_DATA_CACHE_ENABLE();
mbed_official 87:085cde657901 165 #endif /* DATA_CACHE_ENABLE */
mbed_official 87:085cde657901 166
mbed_official 87:085cde657901 167 #if (PREFETCH_ENABLE != 0)
mbed_official 87:085cde657901 168 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
mbed_official 87:085cde657901 169 #endif /* PREFETCH_ENABLE */
mbed_official 87:085cde657901 170
mbed_official 87:085cde657901 171 /* Set Interrupt Group Priority */
mbed_official 87:085cde657901 172 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
mbed_official 226:b062af740e40 173
mbed_official 226:b062af740e40 174 /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
mbed_official 226:b062af740e40 175 HAL_InitTick(TICK_INT_PRIORITY);
mbed_official 87:085cde657901 176
mbed_official 87:085cde657901 177 /* Init the low level hardware */
mbed_official 87:085cde657901 178 HAL_MspInit();
mbed_official 87:085cde657901 179
mbed_official 87:085cde657901 180 /* Return function status */
mbed_official 87:085cde657901 181 return HAL_OK;
mbed_official 87:085cde657901 182 }
mbed_official 87:085cde657901 183
mbed_official 87:085cde657901 184 /**
mbed_official 87:085cde657901 185 * @brief This function de-Initializes common part of the HAL and stops the systick.
mbed_official 87:085cde657901 186 * This function is optional.
mbed_official 87:085cde657901 187 * @param None
mbed_official 87:085cde657901 188 * @retval HAL status
mbed_official 87:085cde657901 189 */
mbed_official 87:085cde657901 190 HAL_StatusTypeDef HAL_DeInit(void)
mbed_official 87:085cde657901 191 {
mbed_official 87:085cde657901 192 /* Reset of all peripherals */
mbed_official 87:085cde657901 193 __APB1_FORCE_RESET();
mbed_official 87:085cde657901 194 __APB1_RELEASE_RESET();
mbed_official 87:085cde657901 195
mbed_official 87:085cde657901 196 __APB2_FORCE_RESET();
mbed_official 87:085cde657901 197 __APB2_RELEASE_RESET();
mbed_official 87:085cde657901 198
mbed_official 87:085cde657901 199 __AHB1_FORCE_RESET();
mbed_official 87:085cde657901 200 __AHB1_RELEASE_RESET();
mbed_official 87:085cde657901 201
mbed_official 87:085cde657901 202 __AHB2_FORCE_RESET();
mbed_official 87:085cde657901 203 __AHB2_RELEASE_RESET();
mbed_official 87:085cde657901 204
mbed_official 87:085cde657901 205 __AHB3_FORCE_RESET();
mbed_official 87:085cde657901 206 __AHB3_RELEASE_RESET();
mbed_official 87:085cde657901 207
mbed_official 87:085cde657901 208 /* De-Init the low level hardware */
mbed_official 87:085cde657901 209 HAL_MspDeInit();
mbed_official 87:085cde657901 210
mbed_official 87:085cde657901 211 /* Return function status */
mbed_official 87:085cde657901 212 return HAL_OK;
mbed_official 87:085cde657901 213 }
mbed_official 87:085cde657901 214
mbed_official 87:085cde657901 215 /**
mbed_official 87:085cde657901 216 * @brief Initializes the MSP.
mbed_official 87:085cde657901 217 * @param None
mbed_official 87:085cde657901 218 * @retval None
mbed_official 87:085cde657901 219 */
mbed_official 87:085cde657901 220 __weak void HAL_MspInit(void)
mbed_official 87:085cde657901 221 {
mbed_official 87:085cde657901 222 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 87:085cde657901 223 the HAL_MspInit could be implemented in the user file
mbed_official 226:b062af740e40 224 */
mbed_official 87:085cde657901 225 }
mbed_official 87:085cde657901 226
mbed_official 87:085cde657901 227 /**
mbed_official 87:085cde657901 228 * @brief DeInitializes the MSP.
mbed_official 87:085cde657901 229 * @param None
mbed_official 87:085cde657901 230 * @retval None
mbed_official 87:085cde657901 231 */
mbed_official 87:085cde657901 232 __weak void HAL_MspDeInit(void)
mbed_official 87:085cde657901 233 {
mbed_official 87:085cde657901 234 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 87:085cde657901 235 the HAL_MspDeInit could be implemented in the user file
mbed_official 87:085cde657901 236 */
mbed_official 87:085cde657901 237 }
mbed_official 87:085cde657901 238
mbed_official 87:085cde657901 239 /**
mbed_official 226:b062af740e40 240 * @brief This function configures the source of the time base.
mbed_official 226:b062af740e40 241 * The time source is configured to have 1ms time base with a dedicated
mbed_official 226:b062af740e40 242 * Tick interrupt priority.
mbed_official 226:b062af740e40 243 * @note This function is called automatically at the beginning of program after
mbed_official 226:b062af740e40 244 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
mbed_official 226:b062af740e40 245 * @note In the default implementation, SysTick timer is the source of time base.
mbed_official 226:b062af740e40 246 * It is used to generate interrupts at regular time intervals.
mbed_official 226:b062af740e40 247 * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
mbed_official 226:b062af740e40 248 * The the SysTick interrupt must have higher priority (numerically lower)
mbed_official 226:b062af740e40 249 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
mbed_official 226:b062af740e40 250 * The function is declared as __weak to be overwritten in case of other
mbed_official 226:b062af740e40 251 * implementation in user file.
mbed_official 226:b062af740e40 252 * @param TickPriority: Tick interrupt priority.
mbed_official 226:b062af740e40 253 * @retval HAL status
mbed_official 226:b062af740e40 254 */
mbed_official 226:b062af740e40 255 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
mbed_official 226:b062af740e40 256 {
mbed_official 226:b062af740e40 257 /*Configure the SysTick to have interrupt in 1ms time basis*/
mbed_official 226:b062af740e40 258 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
mbed_official 226:b062af740e40 259
mbed_official 226:b062af740e40 260 /*Configure the SysTick IRQ priority */
mbed_official 226:b062af740e40 261 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
mbed_official 226:b062af740e40 262
mbed_official 226:b062af740e40 263 /* Return function status */
mbed_official 226:b062af740e40 264 return HAL_OK;
mbed_official 226:b062af740e40 265 }
mbed_official 226:b062af740e40 266
mbed_official 226:b062af740e40 267 /**
mbed_official 87:085cde657901 268 * @}
mbed_official 87:085cde657901 269 */
mbed_official 87:085cde657901 270
mbed_official 87:085cde657901 271 /** @defgroup HAL_Group2 HAL Control functions
mbed_official 87:085cde657901 272 * @brief HAL Control functions
mbed_official 87:085cde657901 273 *
mbed_official 226:b062af740e40 274 @verbatim
mbed_official 87:085cde657901 275 ===============================================================================
mbed_official 87:085cde657901 276 ##### HAL Control functions #####
mbed_official 87:085cde657901 277 ===============================================================================
mbed_official 87:085cde657901 278 [..] This section provides functions allowing to:
mbed_official 226:b062af740e40 279 (+) Provide a tick value in millisecond
mbed_official 226:b062af740e40 280 (+) Provide a blocking delay in millisecond
mbed_official 226:b062af740e40 281 (+) Suspend the time base source interrupt
mbed_official 226:b062af740e40 282 (+) Resume the time base source interrupt
mbed_official 87:085cde657901 283 (+) Get the HAL API driver version
mbed_official 87:085cde657901 284 (+) Get the device identifier
mbed_official 87:085cde657901 285 (+) Get the device revision identifier
mbed_official 226:b062af740e40 286 (+) Enable/Disable Debug module during SLEEP mode
mbed_official 87:085cde657901 287 (+) Enable/Disable Debug module during STOP mode
mbed_official 87:085cde657901 288 (+) Enable/Disable Debug module during STANDBY mode
mbed_official 87:085cde657901 289
mbed_official 87:085cde657901 290 @endverbatim
mbed_official 87:085cde657901 291 * @{
mbed_official 87:085cde657901 292 */
mbed_official 87:085cde657901 293
mbed_official 87:085cde657901 294 /**
mbed_official 226:b062af740e40 295 * @brief This function is called to increment a global variable "uwTick"
mbed_official 226:b062af740e40 296 * used as application time base.
mbed_official 226:b062af740e40 297 * @note In the default implementation, this variable is incremented each 1ms
mbed_official 226:b062af740e40 298 * in Systick ISR.
mbed_official 226:b062af740e40 299 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 226:b062af740e40 300 * implementations in user file.
mbed_official 226:b062af740e40 301 * @param None
mbed_official 87:085cde657901 302 * @retval None
mbed_official 87:085cde657901 303 */
mbed_official 226:b062af740e40 304 __weak void HAL_IncTick(void)
mbed_official 87:085cde657901 305 {
mbed_official 87:085cde657901 306 uwTick++;
mbed_official 87:085cde657901 307 }
mbed_official 87:085cde657901 308
mbed_official 87:085cde657901 309 /**
mbed_official 226:b062af740e40 310 * @brief Provides a tick value in millisecond.
mbed_official 226:b062af740e40 311 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 226:b062af740e40 312 * implementations in user file.
mbed_official 226:b062af740e40 313 * @param None
mbed_official 87:085cde657901 314 * @retval tick value
mbed_official 87:085cde657901 315 */
mbed_official 226:b062af740e40 316 __weak uint32_t HAL_GetTick(void)
mbed_official 87:085cde657901 317 {
mbed_official 226:b062af740e40 318 return uwTick;
mbed_official 226:b062af740e40 319 }
mbed_official 226:b062af740e40 320
mbed_official 226:b062af740e40 321 /**
mbed_official 226:b062af740e40 322 * @brief This function provides accurate delay (in milliseconds) based
mbed_official 226:b062af740e40 323 * on variable incremented.
mbed_official 226:b062af740e40 324 * @note In the default implementation , SysTick timer is the source of time base.
mbed_official 226:b062af740e40 325 * It is used to generate interrupts at regular time intervals where uwTick
mbed_official 226:b062af740e40 326 * is incremented.
mbed_official 226:b062af740e40 327 * @note ThiS function is declared as __weak to be overwritten in case of other
mbed_official 226:b062af740e40 328 * implementations in user file.
mbed_official 226:b062af740e40 329 * @param Delay: specifies the delay time length, in milliseconds.
mbed_official 226:b062af740e40 330 * @retval None
mbed_official 226:b062af740e40 331 */
mbed_official 226:b062af740e40 332 __weak void HAL_Delay(__IO uint32_t Delay)
mbed_official 226:b062af740e40 333 {
mbed_official 226:b062af740e40 334 uint32_t tickstart = 0;
mbed_official 226:b062af740e40 335 tickstart = HAL_GetTick();
mbed_official 226:b062af740e40 336 while((HAL_GetTick() - tickstart) < Delay)
mbed_official 226:b062af740e40 337 {
mbed_official 226:b062af740e40 338 }
mbed_official 87:085cde657901 339 }
mbed_official 87:085cde657901 340
mbed_official 87:085cde657901 341 /**
mbed_official 226:b062af740e40 342 * @brief Suspend Tick increment.
mbed_official 226:b062af740e40 343 * @note In the default implementation , SysTick timer is the source of time base. It is
mbed_official 226:b062af740e40 344 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
mbed_official 226:b062af740e40 345 * is called, the the SysTick interrupt will be disabled and so Tick increment
mbed_official 226:b062af740e40 346 * is suspended.
mbed_official 226:b062af740e40 347 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 226:b062af740e40 348 * implementations in user file.
mbed_official 226:b062af740e40 349 * @param None
mbed_official 87:085cde657901 350 * @retval None
mbed_official 87:085cde657901 351 */
mbed_official 226:b062af740e40 352 __weak void HAL_SuspendTick(void)
mbed_official 87:085cde657901 353 {
mbed_official 226:b062af740e40 354 /* Disable SysTick Interrupt */
mbed_official 226:b062af740e40 355 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
mbed_official 226:b062af740e40 356 }
mbed_official 226:b062af740e40 357
mbed_official 226:b062af740e40 358 /**
mbed_official 226:b062af740e40 359 * @brief Resume Tick increment.
mbed_official 226:b062af740e40 360 * @note In the default implementation , SysTick timer is the source of time base. It is
mbed_official 226:b062af740e40 361 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
mbed_official 226:b062af740e40 362 * is called, the the SysTick interrupt will be enabled and so Tick increment
mbed_official 226:b062af740e40 363 * is resumed.
mbed_official 226:b062af740e40 364 * @note This function is declared as __weak to be overwritten in case of other
mbed_official 226:b062af740e40 365 * implementations in user file.
mbed_official 226:b062af740e40 366 * @param None
mbed_official 226:b062af740e40 367 * @retval None
mbed_official 226:b062af740e40 368 */
mbed_official 226:b062af740e40 369 __weak void HAL_ResumeTick(void)
mbed_official 226:b062af740e40 370 {
mbed_official 226:b062af740e40 371 /* Enable SysTick Interrupt */
mbed_official 226:b062af740e40 372 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
mbed_official 87:085cde657901 373 }
mbed_official 87:085cde657901 374
mbed_official 87:085cde657901 375 /**
mbed_official 106:ced8cbb51063 376 * @brief Returns the HAL revision
mbed_official 87:085cde657901 377 * @param None
mbed_official 87:085cde657901 378 * @retval version : 0xXYZR (8bits for each decimal, R for RC)
mbed_official 87:085cde657901 379 */
mbed_official 87:085cde657901 380 uint32_t HAL_GetHalVersion(void)
mbed_official 87:085cde657901 381 {
mbed_official 87:085cde657901 382 return __STM32F4xx_HAL_VERSION;
mbed_official 87:085cde657901 383 }
mbed_official 87:085cde657901 384
mbed_official 87:085cde657901 385 /**
mbed_official 87:085cde657901 386 * @brief Returns the device revision identifier.
mbed_official 87:085cde657901 387 * @param None
mbed_official 87:085cde657901 388 * @retval Device revision identifier
mbed_official 87:085cde657901 389 */
mbed_official 87:085cde657901 390 uint32_t HAL_GetREVID(void)
mbed_official 87:085cde657901 391 {
mbed_official 87:085cde657901 392 return((DBGMCU->IDCODE) >> 16);
mbed_official 87:085cde657901 393 }
mbed_official 87:085cde657901 394
mbed_official 87:085cde657901 395 /**
mbed_official 87:085cde657901 396 * @brief Returns the device identifier.
mbed_official 87:085cde657901 397 * @param None
mbed_official 87:085cde657901 398 * @retval Device identifier
mbed_official 87:085cde657901 399 */
mbed_official 87:085cde657901 400 uint32_t HAL_GetDEVID(void)
mbed_official 87:085cde657901 401 {
mbed_official 87:085cde657901 402 return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
mbed_official 87:085cde657901 403 }
mbed_official 87:085cde657901 404
mbed_official 87:085cde657901 405 /**
mbed_official 226:b062af740e40 406 * @brief Enable the Debug Module during SLEEP mode
mbed_official 87:085cde657901 407 * @param None
mbed_official 87:085cde657901 408 * @retval None
mbed_official 87:085cde657901 409 */
mbed_official 87:085cde657901 410 void HAL_EnableDBGSleepMode(void)
mbed_official 87:085cde657901 411 {
mbed_official 87:085cde657901 412 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
mbed_official 87:085cde657901 413 }
mbed_official 87:085cde657901 414
mbed_official 87:085cde657901 415 /**
mbed_official 226:b062af740e40 416 * @brief Disable the Debug Module during SLEEP mode
mbed_official 87:085cde657901 417 * @param None
mbed_official 87:085cde657901 418 * @retval None
mbed_official 87:085cde657901 419 */
mbed_official 87:085cde657901 420 void HAL_DisableDBGSleepMode(void)
mbed_official 87:085cde657901 421 {
mbed_official 87:085cde657901 422 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
mbed_official 87:085cde657901 423 }
mbed_official 87:085cde657901 424
mbed_official 87:085cde657901 425 /**
mbed_official 226:b062af740e40 426 * @brief Enable the Debug Module during STOP mode
mbed_official 87:085cde657901 427 * @param None
mbed_official 87:085cde657901 428 * @retval None
mbed_official 87:085cde657901 429 */
mbed_official 87:085cde657901 430 void HAL_EnableDBGStopMode(void)
mbed_official 87:085cde657901 431 {
mbed_official 87:085cde657901 432 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 87:085cde657901 433 }
mbed_official 87:085cde657901 434
mbed_official 87:085cde657901 435 /**
mbed_official 226:b062af740e40 436 * @brief Disable the Debug Module during STOP mode
mbed_official 87:085cde657901 437 * @param None
mbed_official 87:085cde657901 438 * @retval None
mbed_official 87:085cde657901 439 */
mbed_official 87:085cde657901 440 void HAL_DisableDBGStopMode(void)
mbed_official 87:085cde657901 441 {
mbed_official 87:085cde657901 442 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
mbed_official 87:085cde657901 443 }
mbed_official 87:085cde657901 444
mbed_official 87:085cde657901 445 /**
mbed_official 226:b062af740e40 446 * @brief Enable the Debug Module during STANDBY mode
mbed_official 87:085cde657901 447 * @param None
mbed_official 87:085cde657901 448 * @retval None
mbed_official 87:085cde657901 449 */
mbed_official 87:085cde657901 450 void HAL_EnableDBGStandbyMode(void)
mbed_official 87:085cde657901 451 {
mbed_official 87:085cde657901 452 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 87:085cde657901 453 }
mbed_official 87:085cde657901 454
mbed_official 87:085cde657901 455 /**
mbed_official 226:b062af740e40 456 * @brief Disable the Debug Module during STANDBY mode
mbed_official 87:085cde657901 457 * @param None
mbed_official 87:085cde657901 458 * @retval None
mbed_official 87:085cde657901 459 */
mbed_official 87:085cde657901 460 void HAL_DisableDBGStandbyMode(void)
mbed_official 87:085cde657901 461 {
mbed_official 87:085cde657901 462 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
mbed_official 87:085cde657901 463 }
mbed_official 87:085cde657901 464
mbed_official 87:085cde657901 465 /**
mbed_official 87:085cde657901 466 * @brief Enables the I/O Compensation Cell.
mbed_official 87:085cde657901 467 * @note The I/O compensation cell can be used only when the device supply
mbed_official 87:085cde657901 468 * voltage ranges from 2.4 to 3.6 V.
mbed_official 87:085cde657901 469 * @retval None
mbed_official 87:085cde657901 470 */
mbed_official 87:085cde657901 471 void HAL_EnableCompensationCell(void)
mbed_official 87:085cde657901 472 {
mbed_official 87:085cde657901 473 *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)ENABLE;
mbed_official 87:085cde657901 474 }
mbed_official 87:085cde657901 475
mbed_official 87:085cde657901 476 /**
mbed_official 87:085cde657901 477 * @brief Power-down the I/O Compensation Cell.
mbed_official 87:085cde657901 478 * @note The I/O compensation cell can be used only when the device supply
mbed_official 87:085cde657901 479 * voltage ranges from 2.4 to 3.6 V.
mbed_official 87:085cde657901 480 * @retval None
mbed_official 87:085cde657901 481 */
mbed_official 87:085cde657901 482 void HAL_DisableCompensationCell(void)
mbed_official 87:085cde657901 483 {
mbed_official 87:085cde657901 484 *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)DISABLE;
mbed_official 87:085cde657901 485 }
mbed_official 87:085cde657901 486
mbed_official 87:085cde657901 487 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
mbed_official 87:085cde657901 488 /**
mbed_official 87:085cde657901 489 * @brief Enables the Internal FLASH Bank Swapping.
mbed_official 87:085cde657901 490 *
mbed_official 87:085cde657901 491 * @note This function can be used only for STM32F42xxx/43xxx devices.
mbed_official 87:085cde657901 492 *
mbed_official 87:085cde657901 493 * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000)
mbed_official 87:085cde657901 494 * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000)
mbed_official 87:085cde657901 495 *
mbed_official 87:085cde657901 496 * @retval None
mbed_official 87:085cde657901 497 */
mbed_official 87:085cde657901 498 void HAL_EnableMemorySwappingBank(void)
mbed_official 87:085cde657901 499 {
mbed_official 87:085cde657901 500 *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)ENABLE;
mbed_official 87:085cde657901 501 }
mbed_official 87:085cde657901 502
mbed_official 87:085cde657901 503 /**
mbed_official 87:085cde657901 504 * @brief Disables the Internal FLASH Bank Swapping.
mbed_official 87:085cde657901 505 *
mbed_official 87:085cde657901 506 * @note This function can be used only for STM32F42xxx/43xxx devices.
mbed_official 87:085cde657901 507 *
mbed_official 87:085cde657901 508 * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000)
mbed_official 87:085cde657901 509 * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000)
mbed_official 87:085cde657901 510 *
mbed_official 87:085cde657901 511 * @retval None
mbed_official 87:085cde657901 512 */
mbed_official 87:085cde657901 513 void HAL_DisableMemorySwappingBank(void)
mbed_official 87:085cde657901 514 {
mbed_official 87:085cde657901 515
mbed_official 87:085cde657901 516 *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)DISABLE;
mbed_official 87:085cde657901 517 }
mbed_official 87:085cde657901 518 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
mbed_official 87:085cde657901 519
mbed_official 87:085cde657901 520 /**
mbed_official 87:085cde657901 521 * @}
mbed_official 87:085cde657901 522 */
mbed_official 87:085cde657901 523
mbed_official 87:085cde657901 524 /**
mbed_official 87:085cde657901 525 * @}
mbed_official 87:085cde657901 526 */
mbed_official 87:085cde657901 527
mbed_official 87:085cde657901 528 /**
mbed_official 87:085cde657901 529 * @}
mbed_official 87:085cde657901 530 */
mbed_official 87:085cde657901 531
mbed_official 87:085cde657901 532 /**
mbed_official 87:085cde657901 533 * @}
mbed_official 87:085cde657901 534 */
mbed_official 87:085cde657901 535
mbed_official 87:085cde657901 536 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/