You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stm32f4xx_hal_flash_ramfunc.c 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_flash_ramfunc.c
  4. * @author MCD Application Team
  5. * @brief FLASH RAMFUNC module driver.
  6. * This file provides a FLASH firmware functions which should be
  7. * executed from internal SRAM
  8. * + Stop/Start the flash interface while System Run
  9. * + Enable/Disable the flash sleep while System Run
  10. @verbatim
  11. ==============================================================================
  12. ##### APIs executed from Internal RAM #####
  13. ==============================================================================
  14. [..]
  15. *** ARM Compiler ***
  16. --------------------
  17. [..] RAM functions are defined using the toolchain options.
  18. Functions that are be executed in RAM should reside in a separate
  19. source module. Using the 'Options for File' dialog you can simply change
  20. the 'Code / Const' area of a module to a memory space in physical RAM.
  21. Available memory areas are declared in the 'Target' tab of the
  22. Options for Target' dialog.
  23. *** ICCARM Compiler ***
  24. -----------------------
  25. [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
  26. *** GNU Compiler ***
  27. --------------------
  28. [..] RAM functions are defined using a specific toolchain attribute
  29. "__attribute__((section(".RamFunc")))".
  30. @endverbatim
  31. ******************************************************************************
  32. * @attention
  33. *
  34. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  35. * All rights reserved.</center></h2>
  36. *
  37. * This software component is licensed by ST under BSD 3-Clause license,
  38. * the "License"; You may not use this file except in compliance with the
  39. * License. You may obtain a copy of the License at:
  40. * opensource.org/licenses/BSD-3-Clause
  41. *
  42. ******************************************************************************
  43. */
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32f4xx_hal.h"
  46. /** @addtogroup STM32F4xx_HAL_Driver
  47. * @{
  48. */
  49. /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC
  50. * @brief FLASH functions executed from RAM
  51. * @{
  52. */
  53. #ifdef HAL_FLASH_MODULE_ENABLED
  54. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  55. defined(STM32F412Rx) || defined(STM32F412Cx)
  56. /* Private typedef -----------------------------------------------------------*/
  57. /* Private define ------------------------------------------------------------*/
  58. /* Private macro -------------------------------------------------------------*/
  59. /* Private variables ---------------------------------------------------------*/
  60. /* Private function prototypes -----------------------------------------------*/
  61. /* Exported functions --------------------------------------------------------*/
  62. /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions
  63. * @{
  64. */
  65. /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM
  66. * @brief Peripheral Extended features functions
  67. *
  68. @verbatim
  69. ===============================================================================
  70. ##### ramfunc functions #####
  71. ===============================================================================
  72. [..]
  73. This subsection provides a set of functions that should be executed from RAM
  74. transfers.
  75. @endverbatim
  76. * @{
  77. */
  78. /**
  79. * @brief Stop the flash interface while System Run
  80. * @note This mode is only available for STM32F41xxx/STM32F446xx devices.
  81. * @note This mode couldn't be set while executing with the flash itself.
  82. * It should be done with specific routine executed from RAM.
  83. * @retval HAL status
  84. */
  85. __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void)
  86. {
  87. /* Enable Power ctrl clock */
  88. __HAL_RCC_PWR_CLK_ENABLE();
  89. /* Stop the flash interface while System Run */
  90. SET_BIT(PWR->CR, PWR_CR_FISSR);
  91. return HAL_OK;
  92. }
  93. /**
  94. * @brief Start the flash interface while System Run
  95. * @note This mode is only available for STM32F411xx/STM32F446xx devices.
  96. * @note This mode couldn't be set while executing with the flash itself.
  97. * It should be done with specific routine executed from RAM.
  98. * @retval HAL status
  99. */
  100. __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void)
  101. {
  102. /* Enable Power ctrl clock */
  103. __HAL_RCC_PWR_CLK_ENABLE();
  104. /* Start the flash interface while System Run */
  105. CLEAR_BIT(PWR->CR, PWR_CR_FISSR);
  106. return HAL_OK;
  107. }
  108. /**
  109. * @brief Enable the flash sleep while System Run
  110. * @note This mode is only available for STM32F41xxx/STM32F446xx devices.
  111. * @note This mode could n't be set while executing with the flash itself.
  112. * It should be done with specific routine executed from RAM.
  113. * @retval HAL status
  114. */
  115. __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void)
  116. {
  117. /* Enable Power ctrl clock */
  118. __HAL_RCC_PWR_CLK_ENABLE();
  119. /* Enable the flash sleep while System Run */
  120. SET_BIT(PWR->CR, PWR_CR_FMSSR);
  121. return HAL_OK;
  122. }
  123. /**
  124. * @brief Disable the flash sleep while System Run
  125. * @note This mode is only available for STM32F41xxx/STM32F446xx devices.
  126. * @note This mode couldn't be set while executing with the flash itself.
  127. * It should be done with specific routine executed from RAM.
  128. * @retval HAL status
  129. */
  130. __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void)
  131. {
  132. /* Enable Power ctrl clock */
  133. __HAL_RCC_PWR_CLK_ENABLE();
  134. /* Disable the flash sleep while System Run */
  135. CLEAR_BIT(PWR->CR, PWR_CR_FMSSR);
  136. return HAL_OK;
  137. }
  138. /**
  139. * @}
  140. */
  141. /**
  142. * @}
  143. */
  144. #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  145. #endif /* HAL_FLASH_MODULE_ENABLED */
  146. /**
  147. * @}
  148. */
  149. /**
  150. * @}
  151. */
  152. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/