KugleFirmware/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c
/**
  * @brief  Wait for a FLASH Option Bytes change operation to complete.
  * @param  Timeout maximum flash operation timeout
  * @retval HAL_StatusTypeDef HAL Status
  */
@brief  Wait for a FLASH Option Bytes change operation to complete.
@param  Timeout maximum flash operation timeout
@retval HAL_StatusTypeDef HAL Status
@brief Wait for a FLASH Option Bytes change operation to complete . @param Timeout maximum flash operation timeout @retval HAL_StatusTypeDef HAL Status
HAL_StatusTypeDef FLASH_OB_WaitForLastOperation(uint32_t Timeout)
{
  uint32_t timeout = HAL_GetTick() + Timeout;
  while(FLASH->OPTSR_CUR & FLASH_OPTSR_OPT_BUSY) 
  { 
    if(Timeout != HAL_MAX_DELAY)
    {
      if(HAL_GetTick() >= timeout)
      {
        return HAL_TIMEOUT;
      }
    } 
  }
  if(FLASH->OPTSR_CUR & FLASH_OPTSR_OPTCHANGEERR)
  {
    pFlash.ErrorCode |= HAL_FLASH_ERROR_OB_CHANGE;
    FLASH->OPTCCR |= FLASH_OPTCCR_CLR_OPTCHANGEERR;
    return HAL_ERROR;    
  }
  return HAL_OK;  
}
HAL_StatusTypeDef FLASH_OB_WaitForLastOperation ( uint32_t Timeout ) { uint32_t timeout = HAL_GetTick ( ) + Timeout ; while ( FLASH -> OPTSR_CUR & FLASH_OPTSR_OPT_BUSY ) { if ( Timeout != HAL_MAX_DELAY ) { if ( HAL_GetTick ( ) >= timeout ) { return HAL_TIMEOUT ; } } } if ( FLASH -> OPTSR_CUR & FLASH_OPTSR_OPTCHANGEERR ) { pFlash . ErrorCode |= HAL_FLASH_ERROR_OB_CHANGE ; FLASH -> OPTCCR |= FLASH_OPTCCR_CLR_OPTCHANGEERR ; return HAL_ERROR ; } return HAL_OK ; }
@brief  Wait for a FLASH Option Bytes change operation to complete.
@brief Wait for a FLASH Option Bytes change operation to complete .
/* Wait for the FLASH Option Bytes change operation to complete by polling on OPT_BUSY flag to be reset.*/ /*Save the error code*/ /*Clear the OB error flag*/ /* If there is an error flag set */