Iftikhar Aziz / mbed-dev

Dependents:   LSS_Rev_1

Fork of mbed-dev by Umar Naeem

Committer:
<>
Date:
Fri Sep 02 15:07:44 2016 +0100
Revision:
144:ef7eb2e8f9f7
Parent:
19:112740acecfa
This updates the lib to the mbed lib v125

Who changed what in which revision?

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