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