inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_hal_flash_ramfunc.c
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief FLASH RAMFUNC module driver.
NYX 0:85b3fd62ea1a 8 * This file provides a FLASH firmware functions which should be
NYX 0:85b3fd62ea1a 9 * executed from internal SRAM
NYX 0:85b3fd62ea1a 10 * + Stop/Start the flash interface while System Run
NYX 0:85b3fd62ea1a 11 * + Enable/Disable the flash sleep while System Run
NYX 0:85b3fd62ea1a 12 @verbatim
NYX 0:85b3fd62ea1a 13 ==============================================================================
NYX 0:85b3fd62ea1a 14 ##### APIs executed from Internal RAM #####
NYX 0:85b3fd62ea1a 15 ==============================================================================
NYX 0:85b3fd62ea1a 16 [..]
NYX 0:85b3fd62ea1a 17 *** ARM Compiler ***
NYX 0:85b3fd62ea1a 18 --------------------
NYX 0:85b3fd62ea1a 19 [..] RAM functions are defined using the toolchain options.
NYX 0:85b3fd62ea1a 20 Functions that are be executed in RAM should reside in a separate
NYX 0:85b3fd62ea1a 21 source module. Using the 'Options for File' dialog you can simply change
NYX 0:85b3fd62ea1a 22 the 'Code / Const' area of a module to a memory space in physical RAM.
NYX 0:85b3fd62ea1a 23 Available memory areas are declared in the 'Target' tab of the
NYX 0:85b3fd62ea1a 24 Options for Target' dialog.
NYX 0:85b3fd62ea1a 25
NYX 0:85b3fd62ea1a 26 *** ICCARM Compiler ***
NYX 0:85b3fd62ea1a 27 -----------------------
NYX 0:85b3fd62ea1a 28 [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
NYX 0:85b3fd62ea1a 29
NYX 0:85b3fd62ea1a 30 *** GNU Compiler ***
NYX 0:85b3fd62ea1a 31 --------------------
NYX 0:85b3fd62ea1a 32 [..] RAM functions are defined using a specific toolchain attribute
NYX 0:85b3fd62ea1a 33 "__attribute__((section(".RamFunc")))".
NYX 0:85b3fd62ea1a 34
NYX 0:85b3fd62ea1a 35 @endverbatim
NYX 0:85b3fd62ea1a 36 ******************************************************************************
NYX 0:85b3fd62ea1a 37 * @attention
NYX 0:85b3fd62ea1a 38 *
NYX 0:85b3fd62ea1a 39 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 40 *
NYX 0:85b3fd62ea1a 41 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 42 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 43 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 44 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 45 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 46 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 47 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 48 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 49 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 50 * without specific prior written permission.
NYX 0:85b3fd62ea1a 51 *
NYX 0:85b3fd62ea1a 52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 53 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 55 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 58 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 59 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 60 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 61 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 62 *
NYX 0:85b3fd62ea1a 63 ******************************************************************************
NYX 0:85b3fd62ea1a 64 */
NYX 0:85b3fd62ea1a 65
NYX 0:85b3fd62ea1a 66 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 67 #include "stm32f4xx_hal.h"
NYX 0:85b3fd62ea1a 68
NYX 0:85b3fd62ea1a 69 /** @addtogroup STM32F4xx_HAL_Driver
NYX 0:85b3fd62ea1a 70 * @{
NYX 0:85b3fd62ea1a 71 */
NYX 0:85b3fd62ea1a 72
NYX 0:85b3fd62ea1a 73 /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC
NYX 0:85b3fd62ea1a 74 * @brief FLASH functions executed from RAM
NYX 0:85b3fd62ea1a 75 * @{
NYX 0:85b3fd62ea1a 76 */
NYX 0:85b3fd62ea1a 77 #ifdef HAL_FLASH_MODULE_ENABLED
NYX 0:85b3fd62ea1a 78 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
NYX 0:85b3fd62ea1a 79 defined(STM32F412Rx) || defined(STM32F412Cx)
NYX 0:85b3fd62ea1a 80
NYX 0:85b3fd62ea1a 81 /* Private typedef -----------------------------------------------------------*/
NYX 0:85b3fd62ea1a 82 /* Private define ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 83 /* Private macro -------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 84 /* Private variables ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 85 /* Private function prototypes -----------------------------------------------*/
NYX 0:85b3fd62ea1a 86 /* Exported functions --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 87 /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions
NYX 0:85b3fd62ea1a 88 * @{
NYX 0:85b3fd62ea1a 89 */
NYX 0:85b3fd62ea1a 90
NYX 0:85b3fd62ea1a 91 /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM
NYX 0:85b3fd62ea1a 92 * @brief Peripheral Extended features functions
NYX 0:85b3fd62ea1a 93 *
NYX 0:85b3fd62ea1a 94 @verbatim
NYX 0:85b3fd62ea1a 95
NYX 0:85b3fd62ea1a 96 ===============================================================================
NYX 0:85b3fd62ea1a 97 ##### ramfunc functions #####
NYX 0:85b3fd62ea1a 98 ===============================================================================
NYX 0:85b3fd62ea1a 99 [..]
NYX 0:85b3fd62ea1a 100 This subsection provides a set of functions that should be executed from RAM
NYX 0:85b3fd62ea1a 101 transfers.
NYX 0:85b3fd62ea1a 102
NYX 0:85b3fd62ea1a 103 @endverbatim
NYX 0:85b3fd62ea1a 104 * @{
NYX 0:85b3fd62ea1a 105 */
NYX 0:85b3fd62ea1a 106
NYX 0:85b3fd62ea1a 107 /**
NYX 0:85b3fd62ea1a 108 * @brief Stop the flash interface while System Run
NYX 0:85b3fd62ea1a 109 * @note This mode is only available for STM32F41xxx/STM32F446xx devices.
NYX 0:85b3fd62ea1a 110 * @note This mode couldn't be set while executing with the flash itself.
NYX 0:85b3fd62ea1a 111 * It should be done with specific routine executed from RAM.
NYX 0:85b3fd62ea1a 112 * @retval None
NYX 0:85b3fd62ea1a 113 */
NYX 0:85b3fd62ea1a 114 __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void)
NYX 0:85b3fd62ea1a 115 {
NYX 0:85b3fd62ea1a 116 /* Enable Power ctrl clock */
NYX 0:85b3fd62ea1a 117 __HAL_RCC_PWR_CLK_ENABLE();
NYX 0:85b3fd62ea1a 118 /* Stop the flash interface while System Run */
NYX 0:85b3fd62ea1a 119 SET_BIT(PWR->CR, PWR_CR_FISSR);
NYX 0:85b3fd62ea1a 120
NYX 0:85b3fd62ea1a 121 return HAL_OK;
NYX 0:85b3fd62ea1a 122 }
NYX 0:85b3fd62ea1a 123
NYX 0:85b3fd62ea1a 124 /**
NYX 0:85b3fd62ea1a 125 * @brief Start the flash interface while System Run
NYX 0:85b3fd62ea1a 126 * @note This mode is only available for STM32F411xx/STM32F446xx devices.
NYX 0:85b3fd62ea1a 127 * @note This mode couldn't be set while executing with the flash itself.
NYX 0:85b3fd62ea1a 128 * It should be done with specific routine executed from RAM.
NYX 0:85b3fd62ea1a 129 * @retval None
NYX 0:85b3fd62ea1a 130 */
NYX 0:85b3fd62ea1a 131 __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void)
NYX 0:85b3fd62ea1a 132 {
NYX 0:85b3fd62ea1a 133 /* Enable Power ctrl clock */
NYX 0:85b3fd62ea1a 134 __HAL_RCC_PWR_CLK_ENABLE();
NYX 0:85b3fd62ea1a 135 /* Start the flash interface while System Run */
NYX 0:85b3fd62ea1a 136 CLEAR_BIT(PWR->CR, PWR_CR_FISSR);
NYX 0:85b3fd62ea1a 137
NYX 0:85b3fd62ea1a 138 return HAL_OK;
NYX 0:85b3fd62ea1a 139 }
NYX 0:85b3fd62ea1a 140
NYX 0:85b3fd62ea1a 141 /**
NYX 0:85b3fd62ea1a 142 * @brief Enable the flash sleep while System Run
NYX 0:85b3fd62ea1a 143 * @note This mode is only available for STM32F41xxx/STM32F446xx devices.
NYX 0:85b3fd62ea1a 144 * @note This mode could n't be set while executing with the flash itself.
NYX 0:85b3fd62ea1a 145 * It should be done with specific routine executed from RAM.
NYX 0:85b3fd62ea1a 146 * @retval None
NYX 0:85b3fd62ea1a 147 */
NYX 0:85b3fd62ea1a 148 __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void)
NYX 0:85b3fd62ea1a 149 {
NYX 0:85b3fd62ea1a 150 /* Enable Power ctrl clock */
NYX 0:85b3fd62ea1a 151 __HAL_RCC_PWR_CLK_ENABLE();
NYX 0:85b3fd62ea1a 152 /* Enable the flash sleep while System Run */
NYX 0:85b3fd62ea1a 153 SET_BIT(PWR->CR, PWR_CR_FMSSR);
NYX 0:85b3fd62ea1a 154
NYX 0:85b3fd62ea1a 155 return HAL_OK;
NYX 0:85b3fd62ea1a 156 }
NYX 0:85b3fd62ea1a 157
NYX 0:85b3fd62ea1a 158 /**
NYX 0:85b3fd62ea1a 159 * @brief Disable the flash sleep while System Run
NYX 0:85b3fd62ea1a 160 * @note This mode is only available for STM32F41xxx/STM32F446xx devices.
NYX 0:85b3fd62ea1a 161 * @note This mode couldn't be set while executing with the flash itself.
NYX 0:85b3fd62ea1a 162 * It should be done with specific routine executed from RAM.
NYX 0:85b3fd62ea1a 163 * @retval None
NYX 0:85b3fd62ea1a 164 */
NYX 0:85b3fd62ea1a 165 __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void)
NYX 0:85b3fd62ea1a 166 {
NYX 0:85b3fd62ea1a 167 /* Enable Power ctrl clock */
NYX 0:85b3fd62ea1a 168 __HAL_RCC_PWR_CLK_ENABLE();
NYX 0:85b3fd62ea1a 169 /* Disable the flash sleep while System Run */
NYX 0:85b3fd62ea1a 170 CLEAR_BIT(PWR->CR, PWR_CR_FMSSR);
NYX 0:85b3fd62ea1a 171
NYX 0:85b3fd62ea1a 172 return HAL_OK;
NYX 0:85b3fd62ea1a 173 }
NYX 0:85b3fd62ea1a 174
NYX 0:85b3fd62ea1a 175 /**
NYX 0:85b3fd62ea1a 176 * @}
NYX 0:85b3fd62ea1a 177 */
NYX 0:85b3fd62ea1a 178
NYX 0:85b3fd62ea1a 179 /**
NYX 0:85b3fd62ea1a 180 * @}
NYX 0:85b3fd62ea1a 181 */
NYX 0:85b3fd62ea1a 182
NYX 0:85b3fd62ea1a 183 #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
NYX 0:85b3fd62ea1a 184 #endif /* HAL_FLASH_MODULE_ENABLED */
NYX 0:85b3fd62ea1a 185 /**
NYX 0:85b3fd62ea1a 186 * @}
NYX 0:85b3fd62ea1a 187 */
NYX 0:85b3fd62ea1a 188
NYX 0:85b3fd62ea1a 189 /**
NYX 0:85b3fd62ea1a 190 * @}
NYX 0:85b3fd62ea1a 191 */
NYX 0:85b3fd62ea1a 192
NYX 0:85b3fd62ea1a 193 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/