STM32L4xx_HAL_Driver  1.14.0

Management functions. More...

Functions

HAL_StatusTypeDef HAL_FLASH_Unlock (void)
 Unlock the FLASH control register access. More...
 
HAL_StatusTypeDef HAL_FLASH_Lock (void)
 Lock the FLASH control register access. More...
 
HAL_StatusTypeDef HAL_FLASH_OB_Unlock (void)
 Unlock the FLASH Option Bytes Registers access. More...
 
HAL_StatusTypeDef HAL_FLASH_OB_Lock (void)
 Lock the FLASH Option Bytes Registers access. More...
 
HAL_StatusTypeDef HAL_FLASH_OB_Launch (void)
 Launch the option byte loading. More...
 

Detailed Description

Management functions.

 ===============================================================================
                      ##### Peripheral Control functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to control the FLASH
    memory operations.

Function Documentation

◆ HAL_FLASH_Lock()

HAL_StatusTypeDef HAL_FLASH_Lock ( void  )

Lock the FLASH control register access.

Return values
HALStatus

Definition at line 531 of file stm32l4xx_hal_flash.c.

532 {
533  /* Set the LOCK Bit to lock the FLASH Registers access */
534  SET_BIT(FLASH->CR, FLASH_CR_LOCK);
535 
536  return HAL_OK;
537 }
return HAL_OK

◆ HAL_FLASH_OB_Launch()

HAL_StatusTypeDef HAL_FLASH_OB_Launch ( void  )

Launch the option byte loading.

Return values
HALStatus

Definition at line 575 of file stm32l4xx_hal_flash.c.

576 {
577  /* Set the bit to force the option byte reloading */
578  SET_BIT(FLASH->CR, FLASH_CR_OBL_LAUNCH);
579 
580  /* Wait for last operation to be completed */
581  return(FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE));
582 }
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
Wait for a FLASH operation to complete.

◆ HAL_FLASH_OB_Lock()

HAL_StatusTypeDef HAL_FLASH_OB_Lock ( void  )

Lock the FLASH Option Bytes Registers access.

Return values
HALStatus

Definition at line 563 of file stm32l4xx_hal_flash.c.

564 {
565  /* Set the OPTLOCK Bit to lock the FLASH Option Byte Registers access */
566  SET_BIT(FLASH->CR, FLASH_CR_OPTLOCK);
567 
568  return HAL_OK;
569 }
return HAL_OK

◆ HAL_FLASH_OB_Unlock()

HAL_StatusTypeDef HAL_FLASH_OB_Unlock ( void  )

Unlock the FLASH Option Bytes Registers access.

Return values
HALStatus

Definition at line 543 of file stm32l4xx_hal_flash.c.

544 {
545  if(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) != 0U)
546  {
547  /* Authorizes the Option Byte register programming */
548  WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY1);
549  WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY2);
550  }
551  else
552  {
553  return HAL_ERROR;
554  }
555 
556  return HAL_OK;
557 }
return HAL_OK

◆ HAL_FLASH_Unlock()

HAL_StatusTypeDef HAL_FLASH_Unlock ( void  )

Unlock the FLASH control register access.

Return values
HALStatus

Definition at line 507 of file stm32l4xx_hal_flash.c.

508 {
509  HAL_StatusTypeDef status = HAL_OK;
510 
511  if(READ_BIT(FLASH->CR, FLASH_CR_LOCK) != 0U)
512  {
513  /* Authorize the FLASH Registers access */
514  WRITE_REG(FLASH->KEYR, FLASH_KEY1);
515  WRITE_REG(FLASH->KEYR, FLASH_KEY2);
516 
517  /* Verify Flash is unlocked */
518  if(READ_BIT(FLASH->CR, FLASH_CR_LOCK) != 0U)
519  {
520  status = HAL_ERROR;
521  }
522  }
523 
524  return status;
525 }
return HAL_OK