added prescaler for 16 bit pwm in LPC1347 target

Fork of mbed-dev by mbed official

Committer:
bogdanm
Date:
Thu Oct 01 15:25:22 2015 +0300
Revision:
0:9b334a45a8ff
Child:
83:a036322b8637
Initial commit on mbed-dev

Replaces mbed-src (now inactive)

Who changed what in which revision?

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