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.
 
 
 

158 lines
5.3 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_flash_ramfunc.c
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-2017
  7. * @brief FLASH RAMFUNC driver.
  8. * This file provides a Flash firmware functions which should be
  9. * executed from internal SRAM
  10. * + FLASH HalfPage Programming
  11. * + FLASH Power Down in Run mode
  12. *
  13. * @verbatim
  14. ==============================================================================
  15. ##### Flash RAM functions #####
  16. ==============================================================================
  17. *** ARM Compiler ***
  18. --------------------
  19. [..] RAM functions are defined using the toolchain options.
  20. Functions that are 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. *** ICCARM Compiler ***
  26. -----------------------
  27. [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
  28. *** GNU Compiler ***
  29. --------------------
  30. [..] RAM functions are defined using a specific toolchain attribute
  31. "__attribute__((section(".RamFunc")))".
  32. @endverbatim
  33. ******************************************************************************
  34. * @attention
  35. *
  36. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  37. *
  38. * Redistribution and use in source and binary forms, with or without modification,
  39. * are permitted provided that the following conditions are met:
  40. * 1. Redistributions of source code must retain the above copyright notice,
  41. * this list of conditions and the following disclaimer.
  42. * 2. Redistributions in binary form must reproduce the above copyright notice,
  43. * this list of conditions and the following disclaimer in the documentation
  44. * and/or other materials provided with the distribution.
  45. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  46. * may be used to endorse or promote products derived from this software
  47. * without specific prior written permission.
  48. *
  49. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  50. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  52. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  53. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  55. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  56. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  57. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  58. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59. *
  60. ******************************************************************************
  61. */
  62. /* Includes ------------------------------------------------------------------*/
  63. #include "stm32l4xx_hal.h"
  64. /** @addtogroup STM32L4xx_HAL_Driver
  65. * @{
  66. */
  67. /** @defgroup FLASH_RAMFUNC FLASH_RAMFUNC
  68. * @brief FLASH functions executed from RAM
  69. * @{
  70. */
  71. #ifdef HAL_FLASH_MODULE_ENABLED
  72. /* Private typedef -----------------------------------------------------------*/
  73. /* Private define ------------------------------------------------------------*/
  74. /* Private macro -------------------------------------------------------------*/
  75. /* Private variables ---------------------------------------------------------*/
  76. extern FLASH_ProcessTypeDef pFlash;
  77. /* Private function prototypes -----------------------------------------------*/
  78. /* Exported functions -------------------------------------------------------*/
  79. /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH in RAM function Exported Functions
  80. * @{
  81. */
  82. /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions
  83. * @brief Data transfers functions
  84. *
  85. @verbatim
  86. ===============================================================================
  87. ##### ramfunc functions #####
  88. ===============================================================================
  89. [..]
  90. This subsection provides a set of functions that should be executed from RAM.
  91. @endverbatim
  92. * @{
  93. */
  94. /**
  95. * @brief Enable the Power down in Run Mode
  96. * @note This function should be called and executed from SRAM memory
  97. * @retval None
  98. */
  99. __RAM_FUNC HAL_FLASHEx_EnableRunPowerDown(void)
  100. {
  101. /* Enable the Power Down in Run mode*/
  102. __HAL_FLASH_POWER_DOWN_ENABLE();
  103. return HAL_OK;
  104. }
  105. /**
  106. * @brief Disable the Power down in Run Mode
  107. * @note This function should be called and executed from SRAM memory
  108. * @retval None
  109. */
  110. __RAM_FUNC HAL_FLASHEx_DisableRunPowerDown(void)
  111. {
  112. /* Disable the Power Down in Run mode*/
  113. __HAL_FLASH_POWER_DOWN_DISABLE();
  114. return HAL_OK;
  115. }
  116. /**
  117. * @}
  118. */
  119. /**
  120. * @}
  121. */
  122. #endif /* HAL_FLASH_MODULE_ENABLED */
  123. /**
  124. * @}
  125. */
  126. /**
  127. * @}
  128. */
  129. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/