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