]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_flash_ramfunc.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F4 / stm32f4xx_hal_flash_ramfunc.c
1 /**
2   ******************************************************************************
3   * @file    stm32f4xx_hal_flash_ramfunc.c
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    19-June-2014
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
12   @verbatim
13   ==============================================================================
14                     ##### APIs executed from Internal RAM #####
15   ==============================================================================
16   [..]
17     *** ARM Compiler ***
18     --------------------
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.
25
26     *** ICCARM Compiler ***
27     -----------------------
28     [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
29
30     *** GNU Compiler ***
31     --------------------
32     [..] RAM functions are defined using a specific toolchain attribute
33          "__attribute__((section(".RamFunc")))".
34   
35   @endverbatim         
36   ******************************************************************************
37   * @attention
38   *
39   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
40   *
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.
51   *
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.
62   *
63   ******************************************************************************
64   */ 
65
66 /* Includes ------------------------------------------------------------------*/
67 #include "stm32f4xx_hal.h"
68
69 /** @addtogroup STM32F4xx_HAL_Driver
70   * @{
71   */
72
73 /** @defgroup FLASH_RAMFUNC 
74   * @brief FLASH functions executed from RAM
75   * @{
76   */
77
78 #ifdef HAL_FLASH_MODULE_ENABLED
79
80 #if defined(STM32F411xE)
81
82 /* Private typedef -----------------------------------------------------------*/
83 /* Private define ------------------------------------------------------------*/
84 /* Private macro -------------------------------------------------------------*/
85 /* Private variables ---------------------------------------------------------*/
86 /* Private function prototypes -----------------------------------------------*/
87 /* Private functions ---------------------------------------------------------*/
88
89 /** @defgroup FLASH_RAMFUNC_Private_Functions
90   * @{
91   */
92
93 /** @defgroup FLASH_RAMFUNC_Group1 Peripheral features functions executed from internal RAM 
94   *  @brief Peripheral Extended features functions 
95   *
96 @verbatim   
97
98  ===============================================================================
99                       ##### ramfunc functions #####
100  ===============================================================================  
101     [..]
102     This subsection provides a set of functions that should be executed from RAM 
103     transfers.
104     
105 @endverbatim
106   * @{
107   */
108
109 /**
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.     
114   * @param None
115   * @retval None
116   */
117 __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void)
118 {
119   /* Enable Power ctrl clock */
120   __PWR_CLK_ENABLE();
121   /* Stop the flash interface while System Run */  
122   SET_BIT(PWR->CR, PWR_CR_FISSR);
123    
124   return HAL_OK;
125 }
126
127 /**
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.     
132   * @param None
133   * @retval None
134   */
135 __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void)
136 {
137   /* Enable Power ctrl clock */
138   __PWR_CLK_ENABLE();
139   /* Start the flash interface while System Run */
140   CLEAR_BIT(PWR->CR, PWR_CR_FISSR);
141
142   return HAL_OK;
143 }
144
145 /**
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.     
150   * @param None
151   * @retval None
152   */
153 __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void)
154 {
155   /* Enable Power ctrl clock */
156   __PWR_CLK_ENABLE();
157   /* Enable the flash sleep while System Run */
158   SET_BIT(PWR->CR, PWR_CR_FMSSR);
159
160   return HAL_OK;
161 }
162
163 /**
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.     
168   * @param None
169   * @retval None
170   */
171 __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void)
172 {
173   /* Enable Power ctrl clock */
174   __PWR_CLK_ENABLE();
175   /* Disable the flash sleep while System Run */
176   CLEAR_BIT(PWR->CR, PWR_CR_FMSSR);
177   
178   return HAL_OK;
179 }
180
181 /**
182   * @}
183   */
184
185 /**
186   * @}
187   */
188
189 #endif /* STM32F411xE */
190 #endif /* HAL_FLASH_MODULE_ENABLED */
191 /**
192   * @}
193   */
194
195 /**
196   * @}
197   */
198
199 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/