stm32f4xx_flash_ramfunc.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_flash_ramfunc.c
  4. * @author MCD Application Team
  5. * @version V1.8.1
  6. * @date 27-January-2022
  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. *
  13. @verbatim
  14. ==============================================================================
  15. ##### APIs executed from Internal RAM #####
  16. ==============================================================================
  17. [..]
  18. *** ARM Compiler ***
  19. --------------------
  20. [..] RAM functions are defined using the toolchain options.
  21. Functions that are be executed in RAM should reside in a separate
  22. source module. Using the 'Options for File' dialog you can simply change
  23. the 'Code / Const' area of a module to a memory space in physical RAM.
  24. Available memory areas are declared in the 'Target' tab of the
  25. Options for Target' dialog.
  26. *** ICCARM Compiler ***
  27. -----------------------
  28. [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
  29. *** GNU Compiler ***
  30. --------------------
  31. [..] RAM functions are defined using a specific toolchain attribute
  32. "__attribute__((section(".RamFunc")))".
  33. @endverbatim
  34. ******************************************************************************
  35. * @attention
  36. *
  37. * Copyright (c) 2016 STMicroelectronics.
  38. * All rights reserved.
  39. *
  40. * This software is licensed under terms that can be found in the LICENSE file
  41. * in the root directory of this software component.
  42. * If no LICENSE file comes with this software, it is provided AS-IS.
  43. *
  44. ******************************************************************************
  45. */
  46. /* Includes ------------------------------------------------------------------*/
  47. #include "stm32f4xx_flash_ramfunc.h"
  48. /** @addtogroup STM32F4xx_StdPeriph_Driver
  49. * @{
  50. */
  51. /** @defgroup FLASH RAMFUNC
  52. * @brief FLASH RAMFUNC driver modules
  53. * @{
  54. */
  55. /* Private typedef -----------------------------------------------------------*/
  56. /* Private define ------------------------------------------------------------*/
  57. /* Private macro -------------------------------------------------------------*/
  58. /* Private variables ---------------------------------------------------------*/
  59. /* Private function prototypes -----------------------------------------------*/
  60. /* Private functions ---------------------------------------------------------*/
  61. /** @defgroup FLASH_RAMFUNC_Private_Functions
  62. * @{
  63. */
  64. /** @defgroup FLASH_RAMFUNC_Group1 Peripheral features functions executed from internal RAM
  65. * @brief Peripheral Extended features functions
  66. *
  67. @verbatim
  68. ===============================================================================
  69. ##### ramfunc functions #####
  70. ===============================================================================
  71. [..]
  72. This subsection provides a set of functions that should be executed from RAM
  73. transfers.
  74. @endverbatim
  75. * @{
  76. */
  77. /**
  78. * @brief Start/Stop the flash interface while System Run
  79. * @note This mode is only available for STM32F411xx devices.
  80. * @note This mode could n't be set while executing with the flash itself.
  81. * It should be done with specific routine executed from RAM.
  82. * @param NewState: new state of the Smart Card mode.
  83. * This parameter can be: ENABLE or DISABLE.
  84. * @retval None
  85. */
  86. __RAM_FUNC FLASH_FlashInterfaceCmd(FunctionalState NewState)
  87. {
  88. if (NewState != DISABLE)
  89. {
  90. /* Start the flash interface while System Run */
  91. CLEAR_BIT(PWR->CR, PWR_CR_FISSR);
  92. }
  93. else
  94. {
  95. /* Stop the flash interface while System Run */
  96. SET_BIT(PWR->CR, PWR_CR_FISSR);
  97. }
  98. }
  99. /**
  100. * @brief Enable/Disable the flash sleep while System Run
  101. * @note This mode is only available for STM32F411xx devices.
  102. * @note This mode could n't be set while executing with the flash itself.
  103. * It should be done with specific routine executed from RAM.
  104. * @param NewState: new state of the Smart Card mode.
  105. * This parameter can be: ENABLE or DISABLE.
  106. * @retval None
  107. */
  108. __RAM_FUNC FLASH_FlashSleepModeCmd(FunctionalState NewState)
  109. {
  110. if (NewState != DISABLE)
  111. {
  112. /* Enable the flash sleep while System Run */
  113. SET_BIT(PWR->CR, PWR_CR_FMSSR);
  114. }
  115. else
  116. {
  117. /* Disable the flash sleep while System Run */
  118. CLEAR_BIT(PWR->CR, PWR_CR_FMSSR);
  119. }
  120. }
  121. /**
  122. * @}
  123. */
  124. /**
  125. * @}
  126. */
  127. /**
  128. * @}
  129. */
  130. /**
  131. * @}
  132. */