STM32F439xx HAL User Manual
stm32f4xx_hal_flash_ramfunc.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_flash_ramfunc.c
00004   * @author  MCD Application Team
00005   * @brief   FLASH RAMFUNC module driver.
00006   *          This file provides a FLASH firmware functions which should be 
00007   *          executed from internal SRAM
00008   *            + Stop/Start the flash interface while System Run
00009   *            + Enable/Disable the flash sleep while System Run
00010   @verbatim
00011   ==============================================================================
00012                     ##### APIs executed from Internal RAM #####
00013   ==============================================================================
00014   [..]
00015     *** ARM Compiler ***
00016     --------------------
00017     [..] RAM functions are defined using the toolchain options. 
00018          Functions that are be executed in RAM should reside in a separate
00019          source module. Using the 'Options for File' dialog you can simply change
00020          the 'Code / Const' area of a module to a memory space in physical RAM.
00021          Available memory areas are declared in the 'Target' tab of the 
00022          Options for Target' dialog.
00023 
00024     *** ICCARM Compiler ***
00025     -----------------------
00026     [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
00027 
00028     *** GNU Compiler ***
00029     --------------------
00030     [..] RAM functions are defined using a specific toolchain attribute
00031          "__attribute__((section(".RamFunc")))".
00032   
00033   @endverbatim         
00034   ******************************************************************************
00035   * @attention
00036   *
00037   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00038   *
00039   * Redistribution and use in source and binary forms, with or without modification,
00040   * are permitted provided that the following conditions are met:
00041   *   1. Redistributions of source code must retain the above copyright notice,
00042   *      this list of conditions and the following disclaimer.
00043   *   2. Redistributions in binary form must reproduce the above copyright notice,
00044   *      this list of conditions and the following disclaimer in the documentation
00045   *      and/or other materials provided with the distribution.
00046   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00047   *      may be used to endorse or promote products derived from this software
00048   *      without specific prior written permission.
00049   *
00050   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00051   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00052   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00053   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00054   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00055   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00056   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00057   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00058   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00059   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00060   *
00061   ******************************************************************************
00062   */ 
00063 
00064 /* Includes ------------------------------------------------------------------*/
00065 #include "stm32f4xx_hal.h"
00066 
00067 /** @addtogroup STM32F4xx_HAL_Driver
00068   * @{
00069   */
00070 
00071 /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC
00072   * @brief FLASH functions executed from RAM
00073   * @{
00074   */
00075 #ifdef HAL_FLASH_MODULE_ENABLED
00076 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
00077     defined(STM32F412Rx) || defined(STM32F412Cx)
00078 
00079 /* Private typedef -----------------------------------------------------------*/
00080 /* Private define ------------------------------------------------------------*/
00081 /* Private macro -------------------------------------------------------------*/
00082 /* Private variables ---------------------------------------------------------*/
00083 /* Private function prototypes -----------------------------------------------*/
00084 /* Exported functions --------------------------------------------------------*/
00085 /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions
00086   * @{
00087   */
00088 
00089 /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM 
00090   *  @brief Peripheral Extended features functions 
00091   *
00092 @verbatim   
00093 
00094  ===============================================================================
00095                       ##### ramfunc functions #####
00096  ===============================================================================  
00097     [..]
00098     This subsection provides a set of functions that should be executed from RAM 
00099     transfers.
00100     
00101 @endverbatim
00102   * @{
00103   */
00104 
00105 /**
00106   * @brief Stop the flash interface while System Run
00107   * @note  This mode is only available for STM32F41xxx/STM32F446xx devices. 
00108   * @note  This mode couldn't be set while executing with the flash itself. 
00109   *        It should be done with specific routine executed from RAM.     
00110   * @retval None
00111   */
00112 __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void)
00113 {
00114   /* Enable Power ctrl clock */
00115   __HAL_RCC_PWR_CLK_ENABLE();
00116   /* Stop the flash interface while System Run */  
00117   SET_BIT(PWR->CR, PWR_CR_FISSR);
00118    
00119   return HAL_OK;
00120 }
00121 
00122 /**
00123   * @brief Start the flash interface while System Run
00124   * @note  This mode is only available for STM32F411xx/STM32F446xx devices. 
00125   * @note  This mode couldn't be set while executing with the flash itself. 
00126   *        It should be done with specific routine executed from RAM.     
00127   * @retval None
00128   */
00129 __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void)
00130 {
00131   /* Enable Power ctrl clock */
00132   __HAL_RCC_PWR_CLK_ENABLE();
00133   /* Start the flash interface while System Run */
00134   CLEAR_BIT(PWR->CR, PWR_CR_FISSR);
00135 
00136   return HAL_OK;
00137 }
00138 
00139 /**
00140   * @brief Enable the flash sleep while System Run
00141   * @note  This mode is only available for STM32F41xxx/STM32F446xx devices. 
00142   * @note  This mode could n't be set while executing with the flash itself. 
00143   *        It should be done with specific routine executed from RAM.     
00144   * @retval None
00145   */
00146 __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void)
00147 {
00148   /* Enable Power ctrl clock */
00149   __HAL_RCC_PWR_CLK_ENABLE();
00150   /* Enable the flash sleep while System Run */
00151   SET_BIT(PWR->CR, PWR_CR_FMSSR);
00152 
00153   return HAL_OK;
00154 }
00155 
00156 /**
00157   * @brief Disable the flash sleep while System Run
00158   * @note  This mode is only available for STM32F41xxx/STM32F446xx devices. 
00159   * @note  This mode couldn't be set while executing with the flash itself. 
00160   *        It should be done with specific routine executed from RAM.     
00161   * @retval None
00162   */
00163 __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void)
00164 {
00165   /* Enable Power ctrl clock */
00166   __HAL_RCC_PWR_CLK_ENABLE();
00167   /* Disable the flash sleep while System Run */
00168   CLEAR_BIT(PWR->CR, PWR_CR_FMSSR);
00169   
00170   return HAL_OK;
00171 }
00172 
00173 /**
00174   * @}
00175   */
00176 
00177 /**
00178   * @}
00179   */
00180 
00181 #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
00182 #endif /* HAL_FLASH_MODULE_ENABLED */
00183 /**
00184   * @}
00185   */
00186 
00187 /**
00188   * @}
00189   */
00190 
00191 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/