KugleFirmware/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c
/**
  * @brief  Configure the main internal regulator output voltage.
  * @param  VoltageScaling: Specifies the regulator output voltage to achieve
  *         a tradeoff between performance and power consumption.
  *          This parameter can be one of the following values:
  *            @arg PWR_REGULATOR_VOLTAGE_SCALE1: Regulator voltage output range 1 mode.
  *            @arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output range 2 mode.
  *            @arg PWR_REGULATOR_VOLTAGE_SCALE3: Regulator voltage output range 3 mode.
  * @note   When moving from Range 1 to Range 2, the system frequency must be decreased
  *         before calling HAL_PWREx_ControlVoltageScaling() API.
  *         When moving from Range 2 to Range 1, the system frequency can be increased
  *         after calling HAL_PWREx_ControlVoltageScaling() API.
  * @note   When moving from a Range to an other one, the API waits for VOSRDY flag to be
  *         set before returning the status. If the flag is not set within 1000 microseconds,
  *         HAL_TIMEOUT status is reported.
  * @retval HAL Status
  */
@brief  Configure the main internal regulator output voltage.
@param  VoltageScaling: Specifies the regulator output voltage to achieve
a tradeoff between performance and power consumption.
This parameter can be one of the following values:
@arg PWR_REGULATOR_VOLTAGE_SCALE1: Regulator voltage output range 1 mode.
@arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output range 2 mode.
@arg PWR_REGULATOR_VOLTAGE_SCALE3: Regulator voltage output range 3 mode.
@note   When moving from Range 1 to Range 2, the system frequency must be decreased
before calling HAL_PWREx_ControlVoltageScaling() API.
When moving from Range 2 to Range 1, the system frequency can be increased
after calling HAL_PWREx_ControlVoltageScaling() API.
@note   When moving from a Range to an other one, the API waits for VOSRDY flag to be
set before returning the status. If the flag is not set within 1000 microseconds,
HAL_TIMEOUT status is reported.
@retval HAL Status
@brief Configure the main internal regulator output voltage . @param VoltageScaling : Specifies the regulator output voltage to achieve a tradeoff between performance and power consumption . This parameter can be one of the following values : @arg PWR_REGULATOR_VOLTAGE_SCALE1 : Regulator voltage output range 1 mode . @arg PWR_REGULATOR_VOLTAGE_SCALE2 : Regulator voltage output range 2 mode . @arg PWR_REGULATOR_VOLTAGE_SCALE3 : Regulator voltage output range 3 mode . @note When moving from Range 1 to Range 2 the system frequency must be decreased before calling HAL_PWREx_ControlVoltageScaling () API . When moving from Range 2 to Range 1 the system frequency can be increased after calling HAL_PWREx_ControlVoltageScaling () API . @note When moving from a Range to an other one the API waits for VOSRDY flag to be set before returning the status . If the flag is not set within 1000 microseconds HAL_TIMEOUT status is reported . @retval HAL Status
HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling)
{
  uint32_t tickstart = 0;
  assert_param(IS_PWR_REGULATOR_VOLTAGE(VoltageScaling));
  MODIFY_REG(PWR->D3CR, PWR_D3CR_VOS, VoltageScaling);
  tickstart = HAL_GetTick();
  while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY))
  {
    if((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY_US)
    {
      return HAL_TIMEOUT;
    }
  }
  return HAL_OK;
}
HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling ( uint32_t VoltageScaling ) { uint32_t tickstart = 0 ; assert_param ( IS_PWR_REGULATOR_VOLTAGE ( VoltageScaling ) ) ; MODIFY_REG ( PWR -> D3CR , PWR_D3CR_VOS , VoltageScaling ) ; tickstart = HAL_GetTick ( ) ; while ( ! __HAL_PWR_GET_FLAG ( PWR_FLAG_VOSRDY ) ) { if ( ( HAL_GetTick ( ) - tickstart ) > PWR_FLAG_SETTING_DELAY_US ) { return HAL_TIMEOUT ; } } return HAL_OK ; }
@brief  Configure the main internal regulator output voltage.
@brief Configure the main internal regulator output voltage .
/* Set the voltage range */ /* Get tick */ /* Wait until the VOSRDY flag is set */