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