/* STM32L4xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();
/* Configure LED4 */
BSP_LED_Init(LED4);
/* Configure the system clock to 80 MHz */
SystemClock_80MHz();
/* User push-button (External line 13) will be used to enable or not the SMPS mode */
BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);
/* ------------------------------------------ */
/* Insert 5 seconds delay */
HAL_Delay(5000);
/********************************/
/* 80 MHZ */
/* PWR_REGULATOR_VOLTAGE_SCALE1 */
/* SMPS IS OFF */
/********************************/
/**
* @brief Move to Run SMPS mode
* @NOTE Manage all the required transitions to move from 80 MHz, SMPS off,
voltage scale range 1 to 80 MHz, SMPS on, voltage scale range 2.
* @param None
* @retval None
*/
static void test_run_range2_80mhz_SMPS(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
uint32_t SMPS_status_local = 0;
SMPS_status_local = BSP_SMPS_DeInit();
if (SMPS_status_local != SMPS_OK)
{
Error_Handler();
}
SMPS_status_local = BSP_SMPS_Init(PWR_REGULATOR_VOLTAGE_SCALE2);
if (SMPS_status_local != SMPS_OK)
{
Error_Handler();
}
/* ------------------------------------------ */
__HAL_FLASH_PREFETCH_BUFFER_DISABLE();
/* Set the System clock to 24 MHz */
/* so that SMPS can be enabled */
SystemClock_24MHz();
/* Insert 1 second delay */
HAL_Delay(1000);
/********************************/
/* 24 MHZ */
/* PWR_REGULATOR_VOLTAGE_SCALE1 */
/* SMPS IS OFF */
/********************************/
/* ------------------------------------------ */
/* PWR_REGULATOR_VOLTAGE_SCALE2 only with AD SMPS */
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);
if (SMPS_status_local != SMPS_OK)
{
Error_Handler();
}
/* Insert 1 second delay */
HAL_Delay(1000);
/********************************/
/* 24 MHZ */
/* PWR_REGULATOR_VOLTAGE_SCALE2 */
/* SMPS IS OFF */
/********************************/
/* ------------------------------------------ */
/* Enable SMPS */
/* Check of PG but not blocking */
SMPS_status_local = BSP_SMPS_Enable (0 , 1);