STM32L4xx_HAL_Driver  1.14.0

Data transfers functions. More...

Functions

__RAM_FUNC HAL_FLASHEx_EnableRunPowerDown (void)
 Enable the Power down in Run Mode. More...
 
__RAM_FUNC HAL_FLASHEx_DisableRunPowerDown (void)
 Disable the Power down in Run Mode. More...
 
__RAM_FUNC HAL_FLASHEx_OB_DBankConfig (uint32_t DBankConfig)
 Program the FLASH DBANK User Option Byte. More...
 

Detailed Description

Data transfers functions.

 ===============================================================================
                      ##### ramfunc functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions that should be executed from RAM.

Function Documentation

◆ HAL_FLASHEx_DisableRunPowerDown()

__RAM_FUNC HAL_FLASHEx_DisableRunPowerDown ( void  )

Disable the Power down in Run Mode.

Note
This function should be called and executed from SRAM memory
Return values
None

Definition at line 109 of file stm32l4xx_hal_flash_ramfunc.c.

110 {
111  /* Disable the Power Down in Run mode*/
112  __HAL_FLASH_POWER_DOWN_DISABLE();
113 
114  return HAL_OK;
115 }
return HAL_OK

◆ HAL_FLASHEx_EnableRunPowerDown()

__RAM_FUNC HAL_FLASHEx_EnableRunPowerDown ( void  )

Enable the Power down in Run Mode.

Note
This function should be called and executed from SRAM memory
Return values
None

Definition at line 95 of file stm32l4xx_hal_flash_ramfunc.c.

96 {
97  /* Enable the Power Down in Run mode*/
98  __HAL_FLASH_POWER_DOWN_ENABLE();
99 
100  return HAL_OK;
101 
102 }
return HAL_OK

◆ HAL_FLASHEx_OB_DBankConfig()

__RAM_FUNC HAL_FLASHEx_OB_DBankConfig ( uint32_t  DBankConfig)

Program the FLASH DBANK User Option Byte.

Note
To configure the user option bytes, the option lock bit OPTLOCK must be cleared with the call of the HAL_FLASH_OB_Unlock() function.
To modify the DBANK option byte, no PCROP region should be defined. To deactivate PCROP, user should perform RDP changing
Parameters
DBankConfigThe FLASH DBANK User Option Byte value. This parameter can be one of the following values:
  • OB_DBANK_128_BITS: Single-bank with 128-bits data
  • OB_DBANK_64_BITS: Dual-bank with 64-bits data
Return values
HALstatus

Definition at line 133 of file stm32l4xx_hal_flash_ramfunc.c.

134 {
135  register uint32_t count, reg;
136  HAL_StatusTypeDef status = HAL_ERROR;
137 
138  /* Process Locked */
139  __HAL_LOCK(&pFlash);
140 
141  /* Check if the PCROP is disabled */
142  reg = FLASH->PCROP1SR;
143  if (reg > FLASH->PCROP1ER)
144  {
145  reg = FLASH->PCROP2SR;
146  if (reg > FLASH->PCROP2ER)
147  {
148  /* Disable Flash prefetch */
149  __HAL_FLASH_PREFETCH_BUFFER_DISABLE();
150 
151  if (READ_BIT(FLASH->ACR, FLASH_ACR_ICEN) != 0U)
152  {
153  /* Disable Flash instruction cache */
154  __HAL_FLASH_INSTRUCTION_CACHE_DISABLE();
155 
156  /* Flush Flash instruction cache */
157  __HAL_FLASH_INSTRUCTION_CACHE_RESET();
158  }
159 
160  if (READ_BIT(FLASH->ACR, FLASH_ACR_DCEN) != 0U)
161  {
162  /* Disable Flash data cache */
163  __HAL_FLASH_DATA_CACHE_DISABLE();
164 
165  /* Flush Flash data cache */
166  __HAL_FLASH_DATA_CACHE_RESET();
167  }
168 
169  /* Disable WRP zone 1 of 1st bank if needed */
170  reg = FLASH->WRP1AR;
171  if (((reg & FLASH_WRP1AR_WRP1A_STRT) >> FLASH_WRP1AR_WRP1A_STRT_Pos) <=
172  ((reg & FLASH_WRP1AR_WRP1A_END) >> FLASH_WRP1AR_WRP1A_END_Pos))
173  {
174  MODIFY_REG(FLASH->WRP1AR, (FLASH_WRP1AR_WRP1A_STRT | FLASH_WRP1AR_WRP1A_END), FLASH_WRP1AR_WRP1A_STRT);
175  }
176 
177  /* Disable WRP zone 2 of 1st bank if needed */
178  reg = FLASH->WRP1BR;
179  if (((reg & FLASH_WRP1BR_WRP1B_STRT) >> FLASH_WRP1BR_WRP1B_STRT_Pos) <=
180  ((reg & FLASH_WRP1BR_WRP1B_END) >> FLASH_WRP1BR_WRP1B_END_Pos))
181  {
182  MODIFY_REG(FLASH->WRP1BR, (FLASH_WRP1BR_WRP1B_STRT | FLASH_WRP1BR_WRP1B_END), FLASH_WRP1BR_WRP1B_STRT);
183  }
184 
185  /* Disable WRP zone 1 of 2nd bank if needed */
186  reg = FLASH->WRP2AR;
187  if (((reg & FLASH_WRP2AR_WRP2A_STRT) >> FLASH_WRP2AR_WRP2A_STRT_Pos) <=
188  ((reg & FLASH_WRP2AR_WRP2A_END) >> FLASH_WRP2AR_WRP2A_END_Pos))
189  {
190  MODIFY_REG(FLASH->WRP2AR, (FLASH_WRP2AR_WRP2A_STRT | FLASH_WRP2AR_WRP2A_END), FLASH_WRP2AR_WRP2A_STRT);
191  }
192 
193  /* Disable WRP zone 2 of 2nd bank if needed */
194  reg = FLASH->WRP2BR;
195  if (((reg & FLASH_WRP2BR_WRP2B_STRT) >> FLASH_WRP2BR_WRP2B_STRT_Pos) <=
196  ((reg & FLASH_WRP2BR_WRP2B_END) >> FLASH_WRP2BR_WRP2B_END_Pos))
197  {
198  MODIFY_REG(FLASH->WRP2BR, (FLASH_WRP2BR_WRP2B_STRT | FLASH_WRP2BR_WRP2B_END), FLASH_WRP2BR_WRP2B_STRT);
199  }
200 
201  /* Modify the DBANK user option byte */
202  MODIFY_REG(FLASH->OPTR, FLASH_OPTR_DBANK, DBankConfig);
203 
204  /* Set OPTSTRT Bit */
205  SET_BIT(FLASH->CR, FLASH_CR_OPTSTRT);
206 
207  /* Wait for last operation to be completed */
208  /* 8 is the number of required instruction cycles for the below loop statement (timeout expressed in ms) */
209  count = FLASH_TIMEOUT_VALUE * (SystemCoreClock / 8U / 1000U);
210  do
211  {
212  if (count == 0U)
213  {
214  break;
215  }
216  count--;
217  } while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET);
218 
219  /* If the option byte program operation is completed, disable the OPTSTRT Bit */
220  CLEAR_BIT(FLASH->CR, FLASH_CR_OPTSTRT);
221 
222  /* Set the bit to force the option byte reloading */
223  SET_BIT(FLASH->CR, FLASH_CR_OBL_LAUNCH);
224  }
225  }
226 
227  /* Process Unlocked */
229 
230  return status;
231 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
FLASH_ProcessTypeDef pFlash
Variable used for Program/Erase sectors under interruption.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)