Exemplo n.º 1
0
/**
  * @brief  Pre Sleep Processing
  * @param  ulExpectedIdleTime: Expected time in idle state
  * @retval None
  */
void PreSleepProcessing(unsigned long ulExpectedIdleTime)
{
  /* Called by the kernel before it places the MCU into a sleep mode because
  configPRE_SLEEP_PROCESSING() is #defined to PreSleepProcessing().
  
  NOTE:  Additional actions can be taken here to get the power consumption
  even lower.  For example, peripherals can be turned off here, and then back
  on again in the post sleep processing function.  For maximum power saving
  ensure all unused pins are in their lowest power state. */
  
  /* Avoid compiler warnings about the unused parameter. */
  (void) ulExpectedIdleTime;
  
  /* Disable the peripheral clock during Low Power (Sleep) mode.*/
  __GPIOG_CLK_SLEEP_DISABLE();
}
Exemplo n.º 2
0
/**
  * @brief  Configure the system for power optimization
  *
  * @note	This API configures the system to be ready for low power mode
  * 		- Unused GPIO in Analog mode
  * 		- Fast Wakeup
  * 		- Verefint disabled in low power mode
  * 		- FLASH in low power mode
  *
  * @param  None
  * @retval None
  */
void SystemPower_Config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
  
  /**
  * Disable FLASH in SLEEP Mode
  */
  __HAL_FLASH_SLEEP_POWERDOWN_ENABLE();

  //SO: TO BE VERIFIED FOR L4
  /* Enable Power Clock */
  __HAL_RCC_PWR_CLK_ENABLE();
  
  /**
  * Enable Ultra low power and Fast wakeup as vrefint is not used in that project
  */
  //SO: TO BE VERIFIED FOR L4 (these APIs are not available for L4)
  //HAL_PWREx_EnableUltraLowPower();
  //HAL_PWREx_EnableFastWakeUp();

  /*
  * Select HSI as system clock source after Wake Up from Stop mode
  */
    //__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_StopWakeUpClock_MSI); //SO: TO BE VERIFIED FOR L4 (why not this?)
  __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_StopWakeUpClock_HSI);
  
  /*
  * Disable all GPIOs clock in SLEEP mode
  */
#if (JTAG_SUPPORTED == 0)
  __GPIOA_CLK_SLEEP_DISABLE();
#endif
  __GPIOB_CLK_SLEEP_DISABLE();
  __GPIOC_CLK_SLEEP_DISABLE();
  __GPIOD_CLK_SLEEP_DISABLE();
  __GPIOE_CLK_SLEEP_DISABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOF_CLK_SLEEP_DISABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOG_CLK_SLEEP_DISABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOH_CLK_SLEEP_DISABLE();
  
  /*
  * Enable GPIOs clock
  */
  __GPIOA_CLK_ENABLE();
  __GPIOB_CLK_ENABLE();
  __GPIOC_CLK_ENABLE();
  __GPIOD_CLK_ENABLE();
  __GPIOE_CLK_ENABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOF_CLK_ENABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOG_CLK_ENABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOH_CLK_ENABLE();

  /*
  * Configure all GPIO port pins in Analog mode with no pull
  */
  GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStructure.Speed = GPIO_SPEED_HIGH; //SO: TO BE VERIFIED FOR L4
  GPIO_InitStructure.Pull = GPIO_NOPULL;
  GPIO_InitStructure.Pin = GPIO_PIN_All;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); //SO: TO BE VERIFIED FOR L4
  HAL_GPIO_Init(GPIOF, &GPIO_InitStructure); //SO: TO BE VERIFIED FOR L4
  HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); //SO: TO BE VERIFIED FOR L4
  HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);
  
#if (JTAG_SUPPORTED == 1)
  GPIO_InitStructure.Pin = (GPIO_PIN_All ^ (GPIO_PIN_13 | GPIO_PIN_14));
#endif
  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); 
  
  /*
  * Disable GPIOs clock
  */
  __GPIOA_CLK_DISABLE();
  __GPIOB_CLK_DISABLE();
  __GPIOC_CLK_DISABLE();
  __GPIOD_CLK_DISABLE();
  __GPIOE_CLK_DISABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOF_CLK_DISABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOG_CLK_DISABLE(); //SO: TO BE VERIFIED FOR L4
  __GPIOH_CLK_DISABLE();
  
  return;
}