2 ******************************************************************************
3 * @file stm32f4xx_hal_flash_ramfunc.c
4 * @author MCD Application Team
7 * @brief FLASH RAMFUNC module driver.
8 * This file provides a FLASH firmware functions which should be
9 * executed from internal SRAM
10 * + Stop/Start the flash interface while System Run
11 * + Enable/Disable the flash sleep while System Run
13 ==============================================================================
14 ##### APIs executed from Internal RAM #####
15 ==============================================================================
19 [..] RAM functions are defined using the toolchain options.
20 Functions that are be executed in RAM should reside in a separate
21 source module. Using the 'Options for File' dialog you can simply change
22 the 'Code / Const' area of a module to a memory space in physical RAM.
23 Available memory areas are declared in the 'Target' tab of the
24 Options for Target' dialog.
26 *** ICCARM Compiler ***
27 -----------------------
28 [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
32 [..] RAM functions are defined using a specific toolchain attribute
33 "__attribute__((section(".RamFunc")))".
36 ******************************************************************************
39 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
41 * Redistribution and use in source and binary forms, with or without modification,
42 * are permitted provided that the following conditions are met:
43 * 1. Redistributions of source code must retain the above copyright notice,
44 * this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright notice,
46 * this list of conditions and the following disclaimer in the documentation
47 * and/or other materials provided with the distribution.
48 * 3. Neither the name of STMicroelectronics nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
53 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
55 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
58 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
59 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
60 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 ******************************************************************************
66 /* Includes ------------------------------------------------------------------*/
67 #include "stm32f4xx_hal.h"
69 /** @addtogroup STM32F4xx_HAL_Driver
73 /** @defgroup FLASH_RAMFUNC
74 * @brief FLASH functions executed from RAM
78 #ifdef HAL_FLASH_MODULE_ENABLED
80 #if defined(STM32F411xE)
82 /* Private typedef -----------------------------------------------------------*/
83 /* Private define ------------------------------------------------------------*/
84 /* Private macro -------------------------------------------------------------*/
85 /* Private variables ---------------------------------------------------------*/
86 /* Private function prototypes -----------------------------------------------*/
87 /* Private functions ---------------------------------------------------------*/
89 /** @defgroup FLASH_RAMFUNC_Private_Functions
93 /** @defgroup FLASH_RAMFUNC_Group1 Peripheral features functions executed from internal RAM
94 * @brief Peripheral Extended features functions
98 ===============================================================================
99 ##### ramfunc functions #####
100 ===============================================================================
102 This subsection provides a set of functions that should be executed from RAM
110 * @brief Stop the flash interface while System Run
111 * @note This mode is only available for STM32F411xx devices.
112 * @note This mode could n't be set while executing with the flash itself.
113 * It should be done with specific routine executed from RAM.
117 __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void)
119 /* Enable Power ctrl clock */
121 /* Stop the flash interface while System Run */
122 SET_BIT(PWR->CR, PWR_CR_FISSR);
128 * @brief Start the flash interface while System Run
129 * @note This mode is only available for STM32F411xx devices.
130 * @note This mode could n't be set while executing with the flash itself.
131 * It should be done with specific routine executed from RAM.
135 __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void)
137 /* Enable Power ctrl clock */
139 /* Start the flash interface while System Run */
140 CLEAR_BIT(PWR->CR, PWR_CR_FISSR);
146 * @brief Enable the flash sleep while System Run
147 * @note This mode is only available for STM32F411xx devices.
148 * @note This mode could n't be set while executing with the flash itself.
149 * It should be done with specific routine executed from RAM.
153 __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void)
155 /* Enable Power ctrl clock */
157 /* Enable the flash sleep while System Run */
158 SET_BIT(PWR->CR, PWR_CR_FMSSR);
164 * @brief Disable the flash sleep while System Run
165 * @note This mode is only available for STM32F411xx devices.
166 * @note This mode could n't be set while executing with the flash itself.
167 * It should be done with specific routine executed from RAM.
171 __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void)
173 /* Enable Power ctrl clock */
175 /* Disable the flash sleep while System Run */
176 CLEAR_BIT(PWR->CR, PWR_CR_FMSSR);
189 #endif /* STM32F411xE */
190 #endif /* HAL_FLASH_MODULE_ENABLED */
199 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/