STM32L4xx_HAL_Driver  1.14.0
Extended Peripheral Control functions

Extended Peripheral Control functions. More...

Functions

uint32_t HAL_PWREx_GetVoltageRange (void)
 Return Voltage Scaling Range. More...
 
HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling (uint32_t VoltageScaling)
 Configure the main internal regulator output voltage. More...
 
void HAL_PWREx_EnableBatteryCharging (uint32_t ResistorSelection)
 Enable battery charging. When VDD is present, charge the external battery on VBAT thru an internal resistor. More...
 
void HAL_PWREx_DisableBatteryCharging (void)
 Disable battery charging. More...
 
void HAL_PWREx_EnableVddUSB (void)
 Enable VDDUSB supply. More...
 
void HAL_PWREx_DisableVddUSB (void)
 Disable VDDUSB supply. More...
 
void HAL_PWREx_EnableVddIO2 (void)
 Enable VDDIO2 supply. More...
 
void HAL_PWREx_DisableVddIO2 (void)
 Disable VDDIO2 supply. More...
 
void HAL_PWREx_EnableInternalWakeUpLine (void)
 Enable Internal Wake-up Line. More...
 
void HAL_PWREx_DisableInternalWakeUpLine (void)
 Disable Internal Wake-up Line. More...
 
HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullUp (uint32_t GPIO, uint32_t GPIONumber)
 Enable GPIO pull-up state in Standby and Shutdown modes. More...
 
HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullUp (uint32_t GPIO, uint32_t GPIONumber)
 Disable GPIO pull-up state in Standby mode and Shutdown modes. More...
 
HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullDown (uint32_t GPIO, uint32_t GPIONumber)
 Enable GPIO pull-down state in Standby and Shutdown modes. More...
 
HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullDown (uint32_t GPIO, uint32_t GPIONumber)
 Disable GPIO pull-down state in Standby and Shutdown modes. More...
 
void HAL_PWREx_EnablePullUpPullDownConfig (void)
 Enable pull-up and pull-down configuration. More...
 
void HAL_PWREx_DisablePullUpPullDownConfig (void)
 Disable pull-up and pull-down configuration. More...
 
void HAL_PWREx_EnableSRAM2ContentRetention (void)
 Enable SRAM2 content retention in Standby mode. More...
 
void HAL_PWREx_DisableSRAM2ContentRetention (void)
 Disable SRAM2 content retention in Standby mode. More...
 
void HAL_PWREx_EnableSRAM3ContentRetention (void)
 Enable SRAM3 content retention in Stop 2 mode. More...
 
void HAL_PWREx_DisableSRAM3ContentRetention (void)
 Disable SRAM3 content retention in Stop 2 mode. More...
 
void HAL_PWREx_EnableDSIPinsPDActivation (void)
 Enable pull-down activation on DSI pins. More...
 
void HAL_PWREx_DisableDSIPinsPDActivation (void)
 Disable pull-down activation on DSI pins. More...
 
void HAL_PWREx_EnablePVM1 (void)
 Enable the Power Voltage Monitoring 1: VDDUSB versus 1.2V. More...
 
void HAL_PWREx_DisablePVM1 (void)
 Disable the Power Voltage Monitoring 1: VDDUSB versus 1.2V. More...
 
void HAL_PWREx_EnablePVM2 (void)
 Enable the Power Voltage Monitoring 2: VDDIO2 versus 0.9V. More...
 
void HAL_PWREx_DisablePVM2 (void)
 Disable the Power Voltage Monitoring 2: VDDIO2 versus 0.9V. More...
 
void HAL_PWREx_EnablePVM3 (void)
 Enable the Power Voltage Monitoring 3: VDDA versus 1.62V. More...
 
void HAL_PWREx_DisablePVM3 (void)
 Disable the Power Voltage Monitoring 3: VDDA versus 1.62V. More...
 
void HAL_PWREx_EnablePVM4 (void)
 Enable the Power Voltage Monitoring 4: VDDA versus 2.2V. More...
 
void HAL_PWREx_DisablePVM4 (void)
 Disable the Power Voltage Monitoring 4: VDDA versus 2.2V. More...
 
HAL_StatusTypeDef HAL_PWREx_ConfigPVM (PWR_PVMTypeDef *sConfigPVM)
 Configure the Peripheral Voltage Monitoring (PVM). More...
 
void HAL_PWREx_EnableBORPVD_ULP (void)
 Enable Ultra Low Power BORL, BORH and PVD for STOP2 and Standby modes. More...
 
void HAL_PWREx_DisableBORPVD_ULP (void)
 Disable Ultra Low Power BORL, BORH and PVD for STOP2 and Standby modes. More...
 
void HAL_PWREx_EnableExtSMPS_0V95 (void)
 Enable the CFLDO working @ 0.95V. More...
 
void HAL_PWREx_DisableExtSMPS_0V95 (void)
 Disable the CFLDO working @ 0.95V. More...
 
void HAL_PWREx_EnableLowPowerRunMode (void)
 Enter Low-power Run mode. More...
 
HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode (void)
 Exit Low-power Run mode. More...
 
void HAL_PWREx_EnterSTOP0Mode (uint8_t STOPEntry)
 Enter Stop 0 mode. More...
 
void HAL_PWREx_EnterSTOP1Mode (uint8_t STOPEntry)
 Enter Stop 1 mode. More...
 
void HAL_PWREx_EnterSTOP2Mode (uint8_t STOPEntry)
 Enter Stop 2 mode. More...
 
void HAL_PWREx_EnterSHUTDOWNMode (void)
 Enter Shutdown mode. More...
 
void HAL_PWREx_PVD_PVM_IRQHandler (void)
 This function handles the PWR PVD/PVMx interrupt request. More...
 
void HAL_PWREx_PVM1Callback (void)
 PWR PVM1 interrupt callback. More...
 
void HAL_PWREx_PVM2Callback (void)
 PWR PVM2 interrupt callback. More...
 
void HAL_PWREx_PVM3Callback (void)
 PWR PVM3 interrupt callback. More...
 
void HAL_PWREx_PVM4Callback (void)
 PWR PVM4 interrupt callback. More...
 

Detailed Description

Extended Peripheral Control functions.

 ===============================================================================
              ##### Extended Peripheral Initialization and de-initialization functions #####
 ===============================================================================
    [..]

Function Documentation

◆ HAL_PWREx_ConfigPVM()

HAL_StatusTypeDef HAL_PWREx_ConfigPVM ( PWR_PVMTypeDef *  sConfigPVM)

Configure the Peripheral Voltage Monitoring (PVM).

Parameters
sConfigPVMpointer to a PWR_PVMTypeDef structure that contains the PVM configuration information.
Note
The API configures a single PVM according to the information contained in the input structure. To configure several PVMs, the API must be singly called for each PVM used.
Refer to the electrical characteristics of your device datasheet for more details about the voltage thresholds corresponding to each detection level and to each monitored supply.
Return values
HALstatus

Definition at line 938 of file stm32l4xx_hal_pwr_ex.c.

939 {
940  HAL_StatusTypeDef status = HAL_OK;
941 
942  /* Check the parameters */
943  assert_param(IS_PWR_PVM_TYPE(sConfigPVM->PVMType));
944  assert_param(IS_PWR_PVM_MODE(sConfigPVM->Mode));
945 
946 
947  /* Configure EXTI 35 to 38 interrupts if so required:
948  scan thru PVMType to detect which PVMx is set and
949  configure the corresponding EXTI line accordingly. */
950  switch (sConfigPVM->PVMType)
951  {
952 #if defined(PWR_CR2_PVME1)
953  case PWR_PVM_1:
954  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
955  __HAL_PWR_PVM1_EXTI_DISABLE_EVENT();
956  __HAL_PWR_PVM1_EXTI_DISABLE_IT();
957  __HAL_PWR_PVM1_EXTI_DISABLE_FALLING_EDGE();
958  __HAL_PWR_PVM1_EXTI_DISABLE_RISING_EDGE();
959 
960  /* Configure interrupt mode */
961  if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
962  {
963  __HAL_PWR_PVM1_EXTI_ENABLE_IT();
964  }
965 
966  /* Configure event mode */
967  if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
968  {
969  __HAL_PWR_PVM1_EXTI_ENABLE_EVENT();
970  }
971 
972  /* Configure the edge */
973  if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
974  {
975  __HAL_PWR_PVM1_EXTI_ENABLE_RISING_EDGE();
976  }
977 
978  if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
979  {
980  __HAL_PWR_PVM1_EXTI_ENABLE_FALLING_EDGE();
981  }
982  break;
983 #endif /* PWR_CR2_PVME1 */
984 
985 #if defined(PWR_CR2_PVME2)
986  case PWR_PVM_2:
987  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
988  __HAL_PWR_PVM2_EXTI_DISABLE_EVENT();
989  __HAL_PWR_PVM2_EXTI_DISABLE_IT();
990  __HAL_PWR_PVM2_EXTI_DISABLE_FALLING_EDGE();
991  __HAL_PWR_PVM2_EXTI_DISABLE_RISING_EDGE();
992 
993  /* Configure interrupt mode */
994  if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
995  {
996  __HAL_PWR_PVM2_EXTI_ENABLE_IT();
997  }
998 
999  /* Configure event mode */
1000  if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
1001  {
1002  __HAL_PWR_PVM2_EXTI_ENABLE_EVENT();
1003  }
1004 
1005  /* Configure the edge */
1006  if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
1007  {
1008  __HAL_PWR_PVM2_EXTI_ENABLE_RISING_EDGE();
1009  }
1010 
1011  if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
1012  {
1013  __HAL_PWR_PVM2_EXTI_ENABLE_FALLING_EDGE();
1014  }
1015  break;
1016 #endif /* PWR_CR2_PVME2 */
1017 
1018  case PWR_PVM_3:
1019  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
1020  __HAL_PWR_PVM3_EXTI_DISABLE_EVENT();
1021  __HAL_PWR_PVM3_EXTI_DISABLE_IT();
1022  __HAL_PWR_PVM3_EXTI_DISABLE_FALLING_EDGE();
1023  __HAL_PWR_PVM3_EXTI_DISABLE_RISING_EDGE();
1024 
1025  /* Configure interrupt mode */
1026  if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
1027  {
1028  __HAL_PWR_PVM3_EXTI_ENABLE_IT();
1029  }
1030 
1031  /* Configure event mode */
1032  if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
1033  {
1034  __HAL_PWR_PVM3_EXTI_ENABLE_EVENT();
1035  }
1036 
1037  /* Configure the edge */
1038  if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
1039  {
1040  __HAL_PWR_PVM3_EXTI_ENABLE_RISING_EDGE();
1041  }
1042 
1043  if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
1044  {
1045  __HAL_PWR_PVM3_EXTI_ENABLE_FALLING_EDGE();
1046  }
1047  break;
1048 
1049  case PWR_PVM_4:
1050  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
1051  __HAL_PWR_PVM4_EXTI_DISABLE_EVENT();
1052  __HAL_PWR_PVM4_EXTI_DISABLE_IT();
1053  __HAL_PWR_PVM4_EXTI_DISABLE_FALLING_EDGE();
1054  __HAL_PWR_PVM4_EXTI_DISABLE_RISING_EDGE();
1055 
1056  /* Configure interrupt mode */
1057  if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
1058  {
1059  __HAL_PWR_PVM4_EXTI_ENABLE_IT();
1060  }
1061 
1062  /* Configure event mode */
1063  if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
1064  {
1065  __HAL_PWR_PVM4_EXTI_ENABLE_EVENT();
1066  }
1067 
1068  /* Configure the edge */
1069  if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
1070  {
1071  __HAL_PWR_PVM4_EXTI_ENABLE_RISING_EDGE();
1072  }
1073 
1074  if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
1075  {
1076  __HAL_PWR_PVM4_EXTI_ENABLE_FALLING_EDGE();
1077  }
1078  break;
1079 
1080  default:
1081  status = HAL_ERROR;
1082  break;
1083  }
1084 
1085  return status;
1086 }
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_ControlVoltageScaling()

HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling ( uint32_t  VoltageScaling)

Configure the main internal regulator output voltage.

Parameters
VoltageScalingspecifies the regulator output voltage to achieve a tradeoff between performance and power consumption. This parameter can be one of the following values:
  • PWR_REGULATOR_VOLTAGE_SCALE1 Regulator voltage output range 1 mode, typical output voltage at 1.2 V, system frequency up to 80 MHz.
  • PWR_REGULATOR_VOLTAGE_SCALE2 Regulator voltage output range 2 mode, typical output voltage at 1.0 V, system frequency up to 26 MHz.
Note
When moving from Range 1 to Range 2, the system frequency must be decreased to a value below 26 MHz before calling HAL_PWREx_ControlVoltageScaling() API. When moving from Range 2 to Range 1, the system frequency can be increased to a value up to 80 MHz after calling HAL_PWREx_ControlVoltageScaling() API. For some devices, the system frequency can be increased up to 120 MHz.
When moving from Range 2 to Range 1, the API waits for VOSF flag to be cleared before returning the status. If the flag is not cleared within 50 microseconds, HAL_TIMEOUT status is reported.
Return values
HALStatus

Definition at line 164 of file stm32l4xx_hal_pwr_ex.c.

165 {
166  uint32_t wait_loop_index;
167 
168  assert_param(IS_PWR_VOLTAGE_SCALING_RANGE(VoltageScaling));
169 
170 #if defined(PWR_CR5_R1MODE)
171  if (VoltageScaling == PWR_REGULATOR_VOLTAGE_SCALE1_BOOST)
172  {
173  /* If current range is range 2 */
174  if (READ_BIT(PWR->CR1, PWR_CR1_VOS) == PWR_REGULATOR_VOLTAGE_SCALE2)
175  {
176  /* Make sure Range 1 Boost is enabled */
177  CLEAR_BIT(PWR->CR5, PWR_CR5_R1MODE);
178 
179  /* Set Range 1 */
180  MODIFY_REG(PWR->CR1, PWR_CR1_VOS, PWR_REGULATOR_VOLTAGE_SCALE1);
181 
182  /* Wait until VOSF is cleared */
183  wait_loop_index = ((PWR_FLAG_SETTING_DELAY_US * SystemCoreClock) / 1000000U) + 1;
184  while ((HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF)) && (wait_loop_index != 0U))
185  {
186  wait_loop_index--;
187  }
188  if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))
189  {
190  return HAL_TIMEOUT;
191  }
192  }
193  /* If current range is range 1 normal or boost mode */
194  else
195  {
196  /* Enable Range 1 Boost (no issue if bit already reset) */
197  CLEAR_BIT(PWR->CR5, PWR_CR5_R1MODE);
198  }
199  }
200  else if (VoltageScaling == PWR_REGULATOR_VOLTAGE_SCALE1)
201  {
202  /* If current range is range 2 */
203  if (READ_BIT(PWR->CR1, PWR_CR1_VOS) == PWR_REGULATOR_VOLTAGE_SCALE2)
204  {
205  /* Make sure Range 1 Boost is disabled */
206  SET_BIT(PWR->CR5, PWR_CR5_R1MODE);
207 
208  /* Set Range 1 */
209  MODIFY_REG(PWR->CR1, PWR_CR1_VOS, PWR_REGULATOR_VOLTAGE_SCALE1);
210 
211  /* Wait until VOSF is cleared */
212  wait_loop_index = ((PWR_FLAG_SETTING_DELAY_US * SystemCoreClock) / 1000000U) + 1;
213  while ((HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF)) && (wait_loop_index != 0U))
214  {
215  wait_loop_index--;
216  }
217  if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))
218  {
219  return HAL_TIMEOUT;
220  }
221  }
222  /* If current range is range 1 normal or boost mode */
223  else
224  {
225  /* Disable Range 1 Boost (no issue if bit already set) */
226  SET_BIT(PWR->CR5, PWR_CR5_R1MODE);
227  }
228  }
229  else
230  {
231  /* Set Range 2 */
232  MODIFY_REG(PWR->CR1, PWR_CR1_VOS, PWR_REGULATOR_VOLTAGE_SCALE2);
233  /* No need to wait for VOSF to be cleared for this transition */
234  /* PWR_CR5_R1MODE bit setting has no effect in Range 2 */
235  }
236 
237 #else
238 
239  /* If Set Range 1 */
240  if (VoltageScaling == PWR_REGULATOR_VOLTAGE_SCALE1)
241  {
242  if (READ_BIT(PWR->CR1, PWR_CR1_VOS) != PWR_REGULATOR_VOLTAGE_SCALE1)
243  {
244  /* Set Range 1 */
245  MODIFY_REG(PWR->CR1, PWR_CR1_VOS, PWR_REGULATOR_VOLTAGE_SCALE1);
246 
247  /* Wait until VOSF is cleared */
248  wait_loop_index = ((PWR_FLAG_SETTING_DELAY_US * SystemCoreClock) / 1000000U) + 1U;
249  while ((HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF)) && (wait_loop_index != 0U))
250  {
251  wait_loop_index--;
252  }
253  if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))
254  {
255  return HAL_TIMEOUT;
256  }
257  }
258  }
259  else
260  {
261  if (READ_BIT(PWR->CR1, PWR_CR1_VOS) != PWR_REGULATOR_VOLTAGE_SCALE2)
262  {
263  /* Set Range 2 */
264  MODIFY_REG(PWR->CR1, PWR_CR1_VOS, PWR_REGULATOR_VOLTAGE_SCALE2);
265  /* No need to wait for VOSF to be cleared for this transition */
266  }
267  }
268 #endif
269 
270  return HAL_OK;
271 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_DisableBatteryCharging()

void HAL_PWREx_DisableBatteryCharging ( void  )

Disable battery charging.

Return values
None

Definition at line 299 of file stm32l4xx_hal_pwr_ex.c.

300 {
301  CLEAR_BIT(PWR->CR4, PWR_CR4_VBE);
302 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableBORPVD_ULP()

void HAL_PWREx_DisableBORPVD_ULP ( void  )

Disable Ultra Low Power BORL, BORH and PVD for STOP2 and Standby modes.

Note
All the other modes are not affected by this bit
Return values
None

Definition at line 765 of file stm32l4xx_hal_pwr_ex.c.

766 {
767  CLEAR_BIT(PWR->CR3, PWR_CR3_ENULP);
768 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableDSIPinsPDActivation()

void HAL_PWREx_DisableDSIPinsPDActivation ( void  )

Disable pull-down activation on DSI pins.

Return values
None

Definition at line 838 of file stm32l4xx_hal_pwr_ex.c.

839 {
840  CLEAR_BIT(PWR->CR3, PWR_CR3_DSIPDEN);
841 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableExtSMPS_0V95()

void HAL_PWREx_DisableExtSMPS_0V95 ( void  )

Disable the CFLDO working @ 0.95V.

Note
Before SMPS is switched off, the regulated voltage of the internal CFLDO shall be set to 1.00V. 1.00V. is also default operating Range 2 voltage.
Return values
None

Definition at line 791 of file stm32l4xx_hal_pwr_ex.c.

792 {
793  CLEAR_BIT(PWR->CR4, PWR_CR4_EXT_SMPS_ON);
794 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableGPIOPullDown()

HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullDown ( uint32_t  GPIO,
uint32_t  GPIONumber 
)

Disable GPIO pull-down state in Standby and Shutdown modes.

Note
Reset the relevant PDy bits of PWR_PDCRx register used to configure the I/O in pull-down state in Standby and Shutdown modes.
Even if a PDy bit to reset is reserved, the other PDy bits entered as input parameter at the same time are reset.
Parameters
GPIOSpecifies the IO port. This parameter can be PWR_GPIO_A..PWR_GPIO_H (or PWR_GPIO_I depending on the devices) to select the GPIO peripheral.
GPIONumberSpecify the I/O pins numbers. This parameter can be one of the following values: PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for the port where less I/O pins are available) or the logical OR of several of them to reset several bits for a given port in a single API call.
Return values
HALStatus

Definition at line 635 of file stm32l4xx_hal_pwr_ex.c.

636 {
637  HAL_StatusTypeDef status = HAL_OK;
638 
639  assert_param(IS_PWR_GPIO(GPIO));
640  assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
641 
642  switch (GPIO)
643  {
644  case PWR_GPIO_A:
645  CLEAR_BIT(PWR->PDCRA, (GPIONumber & (~(PWR_GPIO_BIT_13|PWR_GPIO_BIT_15))));
646  break;
647  case PWR_GPIO_B:
648  CLEAR_BIT(PWR->PDCRB, (GPIONumber & (~(PWR_GPIO_BIT_4))));
649  break;
650  case PWR_GPIO_C:
651  CLEAR_BIT(PWR->PDCRC, GPIONumber);
652  break;
653 #if defined(GPIOD)
654  case PWR_GPIO_D:
655  CLEAR_BIT(PWR->PDCRD, GPIONumber);
656  break;
657 #endif
658 #if defined(GPIOE)
659  case PWR_GPIO_E:
660  CLEAR_BIT(PWR->PDCRE, GPIONumber);
661  break;
662 #endif
663 #if defined(GPIOF)
664  case PWR_GPIO_F:
665  CLEAR_BIT(PWR->PDCRF, GPIONumber);
666  break;
667 #endif
668 #if defined(GPIOG)
669  case PWR_GPIO_G:
670  CLEAR_BIT(PWR->PDCRG, GPIONumber);
671  break;
672 #endif
673  case PWR_GPIO_H:
674 #if defined (STM32L496xx) || defined (STM32L4A6xx)
675  CLEAR_BIT(PWR->PDCRH, ((GPIONumber & PWR_PORTH_AVAILABLE_PINS) & (~(PWR_GPIO_BIT_3))));
676 #else
677  CLEAR_BIT(PWR->PDCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
678 #endif
679  break;
680 #if defined(GPIOI)
681  case PWR_GPIO_I:
682  CLEAR_BIT(PWR->PDCRI, (GPIONumber & PWR_PORTI_AVAILABLE_PINS));
683  break;
684 #endif
685  default:
686  status = HAL_ERROR;
687  break;
688  }
689 
690  return status;
691 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_DisableGPIOPullUp()

HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullUp ( uint32_t  GPIO,
uint32_t  GPIONumber 
)

Disable GPIO pull-up state in Standby mode and Shutdown modes.

Note
Reset the relevant PUy bits of PWR_PUCRx register used to configure the I/O in pull-up state in Standby and Shutdown modes.
Even if a PUy bit to reset is reserved, the other PUy bits entered as input parameter at the same time are reset.
Parameters
GPIOSpecifies the IO port. This parameter can be PWR_GPIO_A, ..., PWR_GPIO_H (or PWR_GPIO_I depending on the devices) to select the GPIO peripheral.
GPIONumberSpecify the I/O pins numbers. This parameter can be one of the following values: PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for the port where less I/O pins are available) or the logical OR of several of them to reset several bits for a given port in a single API call.
Return values
HALStatus

Definition at line 475 of file stm32l4xx_hal_pwr_ex.c.

476 {
477  HAL_StatusTypeDef status = HAL_OK;
478 
479  assert_param(IS_PWR_GPIO(GPIO));
480  assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
481 
482  switch (GPIO)
483  {
484  case PWR_GPIO_A:
485  CLEAR_BIT(PWR->PUCRA, (GPIONumber & (~(PWR_GPIO_BIT_14))));
486  break;
487  case PWR_GPIO_B:
488  CLEAR_BIT(PWR->PUCRB, GPIONumber);
489  break;
490  case PWR_GPIO_C:
491  CLEAR_BIT(PWR->PUCRC, GPIONumber);
492  break;
493 #if defined(GPIOD)
494  case PWR_GPIO_D:
495  CLEAR_BIT(PWR->PUCRD, GPIONumber);
496  break;
497 #endif
498 #if defined(GPIOE)
499  case PWR_GPIO_E:
500  CLEAR_BIT(PWR->PUCRE, GPIONumber);
501  break;
502 #endif
503 #if defined(GPIOF)
504  case PWR_GPIO_F:
505  CLEAR_BIT(PWR->PUCRF, GPIONumber);
506  break;
507 #endif
508 #if defined(GPIOG)
509  case PWR_GPIO_G:
510  CLEAR_BIT(PWR->PUCRG, GPIONumber);
511  break;
512 #endif
513  case PWR_GPIO_H:
514  CLEAR_BIT(PWR->PUCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
515  break;
516 #if defined(GPIOI)
517  case PWR_GPIO_I:
518  CLEAR_BIT(PWR->PUCRI, (GPIONumber & PWR_PORTI_AVAILABLE_PINS));
519  break;
520 #endif
521  default:
522  status = HAL_ERROR;
523  break;
524  }
525 
526  return status;
527 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_DisableInternalWakeUpLine()

void HAL_PWREx_DisableInternalWakeUpLine ( void  )

Disable Internal Wake-up Line.

Return values
None

Definition at line 364 of file stm32l4xx_hal_pwr_ex.c.

365 {
366  CLEAR_BIT(PWR->CR3, PWR_CR3_EIWF);
367 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableLowPowerRunMode()

HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode ( void  )

Exit Low-power Run mode.

Note
Before HAL_PWREx_DisableLowPowerRunMode() completion, the function checks that REGLPF has been properly reset (otherwise, HAL_PWREx_DisableLowPowerRunMode returns HAL_TIMEOUT status). The system clock frequency can then be increased above 2 MHz.
Return values
HALStatus

Definition at line 1115 of file stm32l4xx_hal_pwr_ex.c.

1116 {
1117  uint32_t wait_loop_index;
1118 
1119  /* Clear LPR bit */
1120  CLEAR_BIT(PWR->CR1, PWR_CR1_LPR);
1121 
1122  /* Wait until REGLPF is reset */
1123  wait_loop_index = ((PWR_FLAG_SETTING_DELAY_US * SystemCoreClock) / 1000000U) + 1U;
1124  while ((HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_REGLPF)) && (wait_loop_index != 0U))
1125  {
1126  wait_loop_index--;
1127  }
1128  if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_REGLPF))
1129  {
1130  return HAL_TIMEOUT;
1131  }
1132 
1133  return HAL_OK;
1134 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK

◆ HAL_PWREx_DisablePullUpPullDownConfig()

void HAL_PWREx_DisablePullUpPullDownConfig ( void  )

Disable pull-up and pull-down configuration.

Note
When APC bit is cleared, the I/O pull-up and pull-down configurations defined in PWR_PUCRx and PWR_PDCRx registers are not applied in Standby and Shutdown modes.
Return values
None

Definition at line 717 of file stm32l4xx_hal_pwr_ex.c.

718 {
719  CLEAR_BIT(PWR->CR3, PWR_CR3_APC);
720 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisablePVM1()

void HAL_PWREx_DisablePVM1 ( void  )

Disable the Power Voltage Monitoring 1: VDDUSB versus 1.2V.

Return values
None

Definition at line 858 of file stm32l4xx_hal_pwr_ex.c.

859 {
860  CLEAR_BIT(PWR->CR2, PWR_PVM_1);
861 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisablePVM2()

void HAL_PWREx_DisablePVM2 ( void  )

Disable the Power Voltage Monitoring 2: VDDIO2 versus 0.9V.

Return values
None

Definition at line 879 of file stm32l4xx_hal_pwr_ex.c.

880 {
881  CLEAR_BIT(PWR->CR2, PWR_PVM_2);
882 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisablePVM3()

void HAL_PWREx_DisablePVM3 ( void  )

Disable the Power Voltage Monitoring 3: VDDA versus 1.62V.

Return values
None

Definition at line 899 of file stm32l4xx_hal_pwr_ex.c.

900 {
901  CLEAR_BIT(PWR->CR2, PWR_PVM_3);
902 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisablePVM4()

void HAL_PWREx_DisablePVM4 ( void  )

Disable the Power Voltage Monitoring 4: VDDA versus 2.2V.

Return values
None

Definition at line 918 of file stm32l4xx_hal_pwr_ex.c.

919 {
920  CLEAR_BIT(PWR->CR2, PWR_PVM_4);
921 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableSRAM2ContentRetention()

void HAL_PWREx_DisableSRAM2ContentRetention ( void  )

Disable SRAM2 content retention in Standby mode.

Note
When RRS bit is reset, SRAM2 is powered off in Standby mode and its content is lost.
Return values
None

Definition at line 742 of file stm32l4xx_hal_pwr_ex.c.

743 {
744  CLEAR_BIT(PWR->CR3, PWR_CR3_RRS);
745 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableSRAM3ContentRetention()

void HAL_PWREx_DisableSRAM3ContentRetention ( void  )

Disable SRAM3 content retention in Stop 2 mode.

Note
When RRSTP bit is reset, SRAM3 is powered off in Stop 2 mode and its content is lost.
Return values
None

Definition at line 817 of file stm32l4xx_hal_pwr_ex.c.

818 {
819  CLEAR_BIT(PWR->CR1, PWR_CR1_RRSTP);
820 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableVddIO2()

void HAL_PWREx_DisableVddIO2 ( void  )

Disable VDDIO2 supply.

Return values
None

Definition at line 343 of file stm32l4xx_hal_pwr_ex.c.

344 {
345  CLEAR_BIT(PWR->CR2, PWR_CR2_IOSV);
346 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_DisableVddUSB()

void HAL_PWREx_DisableVddUSB ( void  )

Disable VDDUSB supply.

Return values
None

Definition at line 321 of file stm32l4xx_hal_pwr_ex.c.

322 {
323  CLEAR_BIT(PWR->CR2, PWR_CR2_USV);
324 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ HAL_PWREx_EnableBatteryCharging()

void HAL_PWREx_EnableBatteryCharging ( uint32_t  ResistorSelection)

Enable battery charging. When VDD is present, charge the external battery on VBAT thru an internal resistor.

Parameters
ResistorSelectionspecifies the resistor impedance. This parameter can be one of the following values:
  • PWR_BATTERY_CHARGING_RESISTOR_5 5 kOhms resistor
  • PWR_BATTERY_CHARGING_RESISTOR_1_5 1.5 kOhms resistor
Return values
None

Definition at line 283 of file stm32l4xx_hal_pwr_ex.c.

284 {
285  assert_param(IS_PWR_BATTERY_RESISTOR_SELECT(ResistorSelection));
286 
287  /* Specify resistor selection */
288  MODIFY_REG(PWR->CR4, PWR_CR4_VBRS, ResistorSelection);
289 
290  /* Enable battery charging */
291  SET_BIT(PWR->CR4, PWR_CR4_VBE);
292 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_EnableBORPVD_ULP()

void HAL_PWREx_EnableBORPVD_ULP ( void  )

Enable Ultra Low Power BORL, BORH and PVD for STOP2 and Standby modes.

Note
All the other modes are not affected by this bit.
Return values
None

Definition at line 754 of file stm32l4xx_hal_pwr_ex.c.

755 {
756  SET_BIT(PWR->CR3, PWR_CR3_ENULP);
757 }

◆ HAL_PWREx_EnableDSIPinsPDActivation()

void HAL_PWREx_EnableDSIPinsPDActivation ( void  )

Enable pull-down activation on DSI pins.

Return values
None

Definition at line 828 of file stm32l4xx_hal_pwr_ex.c.

829 {
830  SET_BIT(PWR->CR3, PWR_CR3_DSIPDEN);
831 }

◆ HAL_PWREx_EnableExtSMPS_0V95()

void HAL_PWREx_EnableExtSMPS_0V95 ( void  )

Enable the CFLDO working @ 0.95V.

Note
When external SMPS is used & CFLDO operating in Range 2, the regulated voltage of the internal CFLDO can be reduced to 0.95V.
Return values
None

Definition at line 779 of file stm32l4xx_hal_pwr_ex.c.

780 {
781  SET_BIT(PWR->CR4, PWR_CR4_EXT_SMPS_ON);
782 }

◆ HAL_PWREx_EnableGPIOPullDown()

HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullDown ( uint32_t  GPIO,
uint32_t  GPIONumber 
)

Enable GPIO pull-down state in Standby and Shutdown modes.

Note
Set the relevant PDy bits of PWR_PDCRx register to configure the I/O in pull-down state in Standby and Shutdown modes.
This state is effective in Standby and Shutdown modes only if APC bit is set through HAL_PWREx_EnablePullUpPullDownConfig() API.
The configuration is lost when exiting the Shutdown mode due to the power-on reset, maintained when exiting the Standby mode.
To avoid any conflict at Standby and Shutdown modes exits, the corresponding PUy bit of PWR_PUCRx register is cleared unless it is reserved.
Even if a PDy bit to set is reserved, the other PDy bits entered as input parameter at the same time are set.
Parameters
GPIOSpecify the IO port. This parameter can be PWR_GPIO_A..PWR_GPIO_H (or PWR_GPIO_I depending on the devices) to select the GPIO peripheral.
GPIONumberSpecify the I/O pins numbers. This parameter can be one of the following values: PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for the port where less I/O pins are available) or the logical OR of several of them to set several bits for a given port in a single API call.
Return values
HALStatus

Definition at line 552 of file stm32l4xx_hal_pwr_ex.c.

553 {
554  HAL_StatusTypeDef status = HAL_OK;
555 
556  assert_param(IS_PWR_GPIO(GPIO));
557  assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
558 
559  switch (GPIO)
560  {
561  case PWR_GPIO_A:
562  SET_BIT(PWR->PDCRA, (GPIONumber & (~(PWR_GPIO_BIT_13|PWR_GPIO_BIT_15))));
563  CLEAR_BIT(PWR->PUCRA, (GPIONumber & (~(PWR_GPIO_BIT_14))));
564  break;
565  case PWR_GPIO_B:
566  SET_BIT(PWR->PDCRB, (GPIONumber & (~(PWR_GPIO_BIT_4))));
567  CLEAR_BIT(PWR->PUCRB, GPIONumber);
568  break;
569  case PWR_GPIO_C:
570  SET_BIT(PWR->PDCRC, GPIONumber);
571  CLEAR_BIT(PWR->PUCRC, GPIONumber);
572  break;
573 #if defined(GPIOD)
574  case PWR_GPIO_D:
575  SET_BIT(PWR->PDCRD, GPIONumber);
576  CLEAR_BIT(PWR->PUCRD, GPIONumber);
577  break;
578 #endif
579 #if defined(GPIOE)
580  case PWR_GPIO_E:
581  SET_BIT(PWR->PDCRE, GPIONumber);
582  CLEAR_BIT(PWR->PUCRE, GPIONumber);
583  break;
584 #endif
585 #if defined(GPIOF)
586  case PWR_GPIO_F:
587  SET_BIT(PWR->PDCRF, GPIONumber);
588  CLEAR_BIT(PWR->PUCRF, GPIONumber);
589  break;
590 #endif
591 #if defined(GPIOG)
592  case PWR_GPIO_G:
593  SET_BIT(PWR->PDCRG, GPIONumber);
594  CLEAR_BIT(PWR->PUCRG, GPIONumber);
595  break;
596 #endif
597  case PWR_GPIO_H:
598 #if defined (STM32L496xx) || defined (STM32L4A6xx)
599  SET_BIT(PWR->PDCRH, ((GPIONumber & PWR_PORTH_AVAILABLE_PINS) & (~(PWR_GPIO_BIT_3))));
600 #else
601  SET_BIT(PWR->PDCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
602 #endif
603  CLEAR_BIT(PWR->PUCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
604  break;
605 #if defined(GPIOI)
606  case PWR_GPIO_I:
607  SET_BIT(PWR->PDCRI, (GPIONumber & PWR_PORTI_AVAILABLE_PINS));
608  CLEAR_BIT(PWR->PUCRI, (GPIONumber & PWR_PORTI_AVAILABLE_PINS));
609  break;
610 #endif
611  default:
612  status = HAL_ERROR;
613  break;
614  }
615 
616  return status;
617 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_EnableGPIOPullUp()

HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullUp ( uint32_t  GPIO,
uint32_t  GPIONumber 
)

Enable GPIO pull-up state in Standby and Shutdown modes.

Note
Set the relevant PUy bits of PWR_PUCRx register to configure the I/O in pull-up state in Standby and Shutdown modes.
This state is effective in Standby and Shutdown modes only if APC bit is set through HAL_PWREx_EnablePullUpPullDownConfig() API.
The configuration is lost when exiting the Shutdown mode due to the power-on reset, maintained when exiting the Standby mode.
To avoid any conflict at Standby and Shutdown modes exits, the corresponding PDy bit of PWR_PDCRx register is cleared unless it is reserved.
Even if a PUy bit to set is reserved, the other PUy bits entered as input parameter at the same time are set.
Parameters
GPIOSpecify the IO port. This parameter can be PWR_GPIO_A, ..., PWR_GPIO_H (or PWR_GPIO_I depending on the devices) to select the GPIO peripheral.
GPIONumberSpecify the I/O pins numbers. This parameter can be one of the following values: PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for the port where less I/O pins are available) or the logical OR of several of them to set several bits for a given port in a single API call.
Return values
HALStatus

Definition at line 392 of file stm32l4xx_hal_pwr_ex.c.

393 {
394  HAL_StatusTypeDef status = HAL_OK;
395 
396  assert_param(IS_PWR_GPIO(GPIO));
397  assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
398 
399  switch (GPIO)
400  {
401  case PWR_GPIO_A:
402  SET_BIT(PWR->PUCRA, (GPIONumber & (~(PWR_GPIO_BIT_14))));
403  CLEAR_BIT(PWR->PDCRA, (GPIONumber & (~(PWR_GPIO_BIT_13|PWR_GPIO_BIT_15))));
404  break;
405  case PWR_GPIO_B:
406  SET_BIT(PWR->PUCRB, GPIONumber);
407  CLEAR_BIT(PWR->PDCRB, (GPIONumber & (~(PWR_GPIO_BIT_4))));
408  break;
409  case PWR_GPIO_C:
410  SET_BIT(PWR->PUCRC, GPIONumber);
411  CLEAR_BIT(PWR->PDCRC, GPIONumber);
412  break;
413 #if defined(GPIOD)
414  case PWR_GPIO_D:
415  SET_BIT(PWR->PUCRD, GPIONumber);
416  CLEAR_BIT(PWR->PDCRD, GPIONumber);
417  break;
418 #endif
419 #if defined(GPIOE)
420  case PWR_GPIO_E:
421  SET_BIT(PWR->PUCRE, GPIONumber);
422  CLEAR_BIT(PWR->PDCRE, GPIONumber);
423  break;
424 #endif
425 #if defined(GPIOF)
426  case PWR_GPIO_F:
427  SET_BIT(PWR->PUCRF, GPIONumber);
428  CLEAR_BIT(PWR->PDCRF, GPIONumber);
429  break;
430 #endif
431 #if defined(GPIOG)
432  case PWR_GPIO_G:
433  SET_BIT(PWR->PUCRG, GPIONumber);
434  CLEAR_BIT(PWR->PDCRG, GPIONumber);
435  break;
436 #endif
437  case PWR_GPIO_H:
438  SET_BIT(PWR->PUCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
439 #if defined (STM32L496xx) || defined (STM32L4A6xx)
440  CLEAR_BIT(PWR->PDCRH, ((GPIONumber & PWR_PORTH_AVAILABLE_PINS) & (~(PWR_GPIO_BIT_3))));
441 #else
442  CLEAR_BIT(PWR->PDCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
443 #endif
444  break;
445 #if defined(GPIOI)
446  case PWR_GPIO_I:
447  SET_BIT(PWR->PUCRI, (GPIONumber & PWR_PORTI_AVAILABLE_PINS));
448  CLEAR_BIT(PWR->PDCRI, (GPIONumber & PWR_PORTI_AVAILABLE_PINS));
449  break;
450 #endif
451  default:
452  status = HAL_ERROR;
453  break;
454  }
455 
456  return status;
457 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_EnableInternalWakeUpLine()

void HAL_PWREx_EnableInternalWakeUpLine ( void  )

Enable Internal Wake-up Line.

Return values
None

Definition at line 354 of file stm32l4xx_hal_pwr_ex.c.

355 {
356  SET_BIT(PWR->CR3, PWR_CR3_EIWF);
357 }

◆ HAL_PWREx_EnableLowPowerRunMode()

void HAL_PWREx_EnableLowPowerRunMode ( void  )

Enter Low-power Run mode.

Note
In Low-power Run mode, all I/O pins keep the same state as in Run mode.
When Regulator is set to PWR_LOWPOWERREGULATOR_ON, the user can optionally configure the Flash in power-down monde in setting the RUN_PD bit in FLASH_ACR register. Additionally, the clock frequency must be reduced below 2 MHz. Setting RUN_PD in FLASH_ACR then appropriately reducing the clock frequency must be done before calling HAL_PWREx_EnableLowPowerRunMode() API.
Return values
None

Definition at line 1100 of file stm32l4xx_hal_pwr_ex.c.

1101 {
1102  /* Set Regulator parameter */
1103  SET_BIT(PWR->CR1, PWR_CR1_LPR);
1104 }

◆ HAL_PWREx_EnablePullUpPullDownConfig()

void HAL_PWREx_EnablePullUpPullDownConfig ( void  )

Enable pull-up and pull-down configuration.

Note
When APC bit is set, the I/O pull-up and pull-down configurations defined in PWR_PUCRx and PWR_PDCRx registers are applied in Standby and Shutdown modes.
Pull-up set by PUy bit of PWR_PUCRx register is not activated if the corresponding PDy bit of PWR_PDCRx register is also set (pull-down configuration priority is higher). HAL_PWREx_EnableGPIOPullUp() and HAL_PWREx_EnableGPIOPullDown() API's ensure there is no conflict when setting PUy or PDy bit.
Return values
None

Definition at line 705 of file stm32l4xx_hal_pwr_ex.c.

706 {
707  SET_BIT(PWR->CR3, PWR_CR3_APC);
708 }

◆ HAL_PWREx_EnablePVM1()

void HAL_PWREx_EnablePVM1 ( void  )

Enable the Power Voltage Monitoring 1: VDDUSB versus 1.2V.

Return values
None

Definition at line 849 of file stm32l4xx_hal_pwr_ex.c.

850 {
851  SET_BIT(PWR->CR2, PWR_PVM_1);
852 }

◆ HAL_PWREx_EnablePVM2()

void HAL_PWREx_EnablePVM2 ( void  )

Enable the Power Voltage Monitoring 2: VDDIO2 versus 0.9V.

Return values
None

Definition at line 870 of file stm32l4xx_hal_pwr_ex.c.

871 {
872  SET_BIT(PWR->CR2, PWR_PVM_2);
873 }

◆ HAL_PWREx_EnablePVM3()

void HAL_PWREx_EnablePVM3 ( void  )

Enable the Power Voltage Monitoring 3: VDDA versus 1.62V.

Return values
None

Definition at line 890 of file stm32l4xx_hal_pwr_ex.c.

891 {
892  SET_BIT(PWR->CR2, PWR_PVM_3);
893 }

◆ HAL_PWREx_EnablePVM4()

void HAL_PWREx_EnablePVM4 ( void  )

Enable the Power Voltage Monitoring 4: VDDA versus 2.2V.

Return values
None

Definition at line 909 of file stm32l4xx_hal_pwr_ex.c.

910 {
911  SET_BIT(PWR->CR2, PWR_PVM_4);
912 }

◆ HAL_PWREx_EnableSRAM2ContentRetention()

void HAL_PWREx_EnableSRAM2ContentRetention ( void  )

Enable SRAM2 content retention in Standby mode.

Note
When RRS bit is set, SRAM2 is powered by the low-power regulator in Standby mode and its content is kept.
Return values
None

Definition at line 730 of file stm32l4xx_hal_pwr_ex.c.

731 {
732  SET_BIT(PWR->CR3, PWR_CR3_RRS);
733 }

◆ HAL_PWREx_EnableSRAM3ContentRetention()

void HAL_PWREx_EnableSRAM3ContentRetention ( void  )

Enable SRAM3 content retention in Stop 2 mode.

Note
When RRSTP bit is set, SRAM3 is powered by the low-power regulator in Stop 2 mode and its content is kept.
Return values
None

Definition at line 805 of file stm32l4xx_hal_pwr_ex.c.

806 {
807  SET_BIT(PWR->CR1, PWR_CR1_RRSTP);
808 }

◆ HAL_PWREx_EnableVddIO2()

void HAL_PWREx_EnableVddIO2 ( void  )

Enable VDDIO2 supply.

Note
Remove VDDIO2 electrical and logical isolation, once VDDIO2 supply is present.
Return values
None

Definition at line 333 of file stm32l4xx_hal_pwr_ex.c.

334 {
335  SET_BIT(PWR->CR2, PWR_CR2_IOSV);
336 }

◆ HAL_PWREx_EnableVddUSB()

void HAL_PWREx_EnableVddUSB ( void  )

Enable VDDUSB supply.

Note
Remove VDDUSB electrical and logical isolation, once VDDUSB supply is present.
Return values
None

Definition at line 311 of file stm32l4xx_hal_pwr_ex.c.

312 {
313  SET_BIT(PWR->CR2, PWR_CR2_USV);
314 }

◆ HAL_PWREx_EnterSHUTDOWNMode()

void HAL_PWREx_EnterSHUTDOWNMode ( void  )

Enter Shutdown mode.

Note
In Shutdown mode, the PLL, the HSI, the MSI, the LSI and the HSE oscillators are switched off. The voltage regulator is disabled and Vcore domain is powered off. SRAM1, SRAM2 and registers contents are lost except for registers in the Backup domain. The BOR is not available.
The I/Os can be configured either with a pull-up or pull-down or can be kept in analog state.
Return values
None

Definition at line 1304 of file stm32l4xx_hal_pwr_ex.c.

1305 {
1306 
1307  /* Set Shutdown mode */
1308  MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_SHUTDOWN);
1309 
1310  /* Set SLEEPDEEP bit of Cortex System Control Register */
1311  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
1312 
1313 /* This option is used to ensure that store operations are completed */
1314 #if defined ( __CC_ARM)
1315  __force_stores();
1316 #endif
1317  /* Request Wait For Interrupt */
1318  __WFI();
1319 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ HAL_PWREx_EnterSTOP0Mode()

void HAL_PWREx_EnterSTOP0Mode ( uint8_t  STOPEntry)

Enter Stop 0 mode.

Note
In Stop 0 mode, main and low voltage regulators are ON.
In Stop 0 mode, all I/O pins keep the same state as in Run mode.
All clocks in the VCORE domain are stopped; the PLL, the MSI, the HSI and the HSE oscillators are disabled. Some peripherals with the wakeup capability (I2Cx, USARTx and LPUART) can switch on the HSI to receive a frame, and switch off the HSI after receiving the frame if it is not a wakeup frame. In this case, the HSI clock is propagated only to the peripheral requesting it. SRAM1, SRAM2 and register contents are preserved. The BOR is available.
When exiting Stop 0 mode by issuing an interrupt or a wakeup event, the HSI RC oscillator is selected as system clock if STOPWUCK bit in RCC_CFGR register is set; the MSI oscillator is selected if STOPWUCK is cleared.
By keeping the internal regulator ON during Stop 0 mode, the consumption is higher although the startup time is reduced.
Parameters
STOPEntryspecifies if Stop mode in entered with WFI or WFE instruction. This parameter can be one of the following values:
  • PWR_STOPENTRY_WFI Enter Stop mode with WFI instruction
  • PWR_STOPENTRY_WFE Enter Stop mode with WFE instruction
Return values
None

Definition at line 1159 of file stm32l4xx_hal_pwr_ex.c.

1160 {
1161  /* Check the parameters */
1162  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
1163 
1164  /* Stop 0 mode with Main Regulator */
1165  MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STOP0);
1166 
1167  /* Set SLEEPDEEP bit of Cortex System Control Register */
1168  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
1169 
1170  /* Select Stop mode entry --------------------------------------------------*/
1171  if(STOPEntry == PWR_STOPENTRY_WFI)
1172  {
1173  /* Request Wait For Interrupt */
1174  __WFI();
1175  }
1176  else
1177  {
1178  /* Request Wait For Event */
1179  __SEV();
1180  __WFE();
1181  __WFE();
1182  }
1183 
1184  /* Reset SLEEPDEEP bit of Cortex System Control Register */
1185  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
1186 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_EnterSTOP1Mode()

void HAL_PWREx_EnterSTOP1Mode ( uint8_t  STOPEntry)

Enter Stop 1 mode.

Note
In Stop 1 mode, only low power voltage regulator is ON.
In Stop 1 mode, all I/O pins keep the same state as in Run mode.
All clocks in the VCORE domain are stopped; the PLL, the MSI, the HSI and the HSE oscillators are disabled. Some peripherals with the wakeup capability (I2Cx, USARTx and LPUART) can switch on the HSI to receive a frame, and switch off the HSI after receiving the frame if it is not a wakeup frame. In this case, the HSI clock is propagated only to the peripheral requesting it. SRAM1, SRAM2 and register contents are preserved. The BOR is available.
When exiting Stop 1 mode by issuing an interrupt or a wakeup event, the HSI RC oscillator is selected as system clock if STOPWUCK bit in RCC_CFGR register is set; the MSI oscillator is selected if STOPWUCK is cleared.
Due to low power mode, an additional startup delay is incurred when waking up from Stop 1 mode.
Parameters
STOPEntryspecifies if Stop mode in entered with WFI or WFE instruction. This parameter can be one of the following values:
  • PWR_STOPENTRY_WFI Enter Stop mode with WFI instruction
  • PWR_STOPENTRY_WFE Enter Stop mode with WFE instruction
Return values
None

Definition at line 1210 of file stm32l4xx_hal_pwr_ex.c.

1211 {
1212  /* Check the parameters */
1213  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
1214 
1215  /* Stop 1 mode with Low-Power Regulator */
1216  MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STOP1);
1217 
1218  /* Set SLEEPDEEP bit of Cortex System Control Register */
1219  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
1220 
1221  /* Select Stop mode entry --------------------------------------------------*/
1222  if(STOPEntry == PWR_STOPENTRY_WFI)
1223  {
1224  /* Request Wait For Interrupt */
1225  __WFI();
1226  }
1227  else
1228  {
1229  /* Request Wait For Event */
1230  __SEV();
1231  __WFE();
1232  __WFE();
1233  }
1234 
1235  /* Reset SLEEPDEEP bit of Cortex System Control Register */
1236  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
1237 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_EnterSTOP2Mode()

void HAL_PWREx_EnterSTOP2Mode ( uint8_t  STOPEntry)

Enter Stop 2 mode.

Note
In Stop 2 mode, only low power voltage regulator is ON.
In Stop 2 mode, all I/O pins keep the same state as in Run mode.
All clocks in the VCORE domain are stopped, the PLL, the MSI, the HSI and the HSE oscillators are disabled. Some peripherals with wakeup capability (LCD, LPTIM1, I2C3 and LPUART) can switch on the HSI to receive a frame, and switch off the HSI after receiving the frame if it is not a wakeup frame. In this case the HSI clock is propagated only to the peripheral requesting it. SRAM1, SRAM2 and register contents are preserved. The BOR is available. The voltage regulator is set in low-power mode but LPR bit must be cleared to enter stop 2 mode. Otherwise, Stop 1 mode is entered.
When exiting Stop 2 mode by issuing an interrupt or a wakeup event, the HSI RC oscillator is selected as system clock if STOPWUCK bit in RCC_CFGR register is set; the MSI oscillator is selected if STOPWUCK is cleared.
Parameters
STOPEntryspecifies if Stop mode in entered with WFI or WFE instruction. This parameter can be one of the following values:
  • PWR_STOPENTRY_WFI Enter Stop mode with WFI instruction
  • PWR_STOPENTRY_WFE Enter Stop mode with WFE instruction
Return values
None

Definition at line 1262 of file stm32l4xx_hal_pwr_ex.c.

1263 {
1264  /* Check the parameter */
1265  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
1266 
1267  /* Set Stop mode 2 */
1268  MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STOP2);
1269 
1270  /* Set SLEEPDEEP bit of Cortex System Control Register */
1271  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
1272 
1273  /* Select Stop mode entry --------------------------------------------------*/
1274  if(STOPEntry == PWR_STOPENTRY_WFI)
1275  {
1276  /* Request Wait For Interrupt */
1277  __WFI();
1278  }
1279  else
1280  {
1281  /* Request Wait For Event */
1282  __SEV();
1283  __WFE();
1284  __WFE();
1285  }
1286 
1287  /* Reset SLEEPDEEP bit of Cortex System Control Register */
1288  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
1289 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_PWREx_GetVoltageRange()

uint32_t HAL_PWREx_GetVoltageRange ( void  )

Return Voltage Scaling Range.

Return values
VOSbit field (PWR_REGULATOR_VOLTAGE_RANGE1 or PWR_REGULATOR_VOLTAGE_RANGE2 or PWR_REGULATOR_VOLTAGE_SCALE1_BOOST when applicable)

Definition at line 115 of file stm32l4xx_hal_pwr_ex.c.

116 {
117 #if defined(PWR_CR5_R1MODE)
118  if (READ_BIT(PWR->CR1, PWR_CR1_VOS) == PWR_REGULATOR_VOLTAGE_SCALE2)
119  {
120  return PWR_REGULATOR_VOLTAGE_SCALE2;
121  }
122  else if (READ_BIT(PWR->CR5, PWR_CR5_R1MODE) == PWR_CR5_R1MODE)
123  {
124  /* PWR_CR5_R1MODE bit set means that Range 1 Boost is disabled */
125  return PWR_REGULATOR_VOLTAGE_SCALE1;
126  }
127  else
128  {
129  return PWR_REGULATOR_VOLTAGE_SCALE1_BOOST;
130  }
131 #else
132  return (PWR->CR1 & PWR_CR1_VOS);
133 #endif
134 }

◆ HAL_PWREx_PVD_PVM_IRQHandler()

void HAL_PWREx_PVD_PVM_IRQHandler ( void  )

This function handles the PWR PVD/PVMx interrupt request.

Note
This API should be called under the PVD_PVM_IRQHandler().
Return values
None

Definition at line 1329 of file stm32l4xx_hal_pwr_ex.c.

1330 {
1331  /* Check PWR exti flag */
1332  if(__HAL_PWR_PVD_EXTI_GET_FLAG() != 0x0U)
1333  {
1334  /* PWR PVD interrupt user callback */
1336 
1337  /* Clear PVD exti pending bit */
1338  __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
1339  }
1340  /* Next, successively check PVMx exti flags */
1341 #if defined(PWR_CR2_PVME1)
1342  if(__HAL_PWR_PVM1_EXTI_GET_FLAG() != 0x0U)
1343  {
1344  /* PWR PVM1 interrupt user callback */
1346 
1347  /* Clear PVM1 exti pending bit */
1348  __HAL_PWR_PVM1_EXTI_CLEAR_FLAG();
1349  }
1350 #endif /* PWR_CR2_PVME1 */
1351 #if defined(PWR_CR2_PVME2)
1352  if(__HAL_PWR_PVM2_EXTI_GET_FLAG() != 0x0U)
1353  {
1354  /* PWR PVM2 interrupt user callback */
1356 
1357  /* Clear PVM2 exti pending bit */
1358  __HAL_PWR_PVM2_EXTI_CLEAR_FLAG();
1359  }
1360 #endif /* PWR_CR2_PVME2 */
1361  if(__HAL_PWR_PVM3_EXTI_GET_FLAG() != 0x0U)
1362  {
1363  /* PWR PVM3 interrupt user callback */
1365 
1366  /* Clear PVM3 exti pending bit */
1367  __HAL_PWR_PVM3_EXTI_CLEAR_FLAG();
1368  }
1369  if(__HAL_PWR_PVM4_EXTI_GET_FLAG() != 0x0U)
1370  {
1371  /* PWR PVM4 interrupt user callback */
1373 
1374  /* Clear PVM4 exti pending bit */
1375  __HAL_PWR_PVM4_EXTI_CLEAR_FLAG();
1376  }
1377 }
void HAL_PWREx_PVM1Callback(void)
PWR PVM1 interrupt callback.
void HAL_PWREx_PVM4Callback(void)
PWR PVM4 interrupt callback.
void HAL_PWREx_PVM2Callback(void)
PWR PVM2 interrupt callback.
void HAL_PWREx_PVM3Callback(void)
PWR PVM3 interrupt callback.
void HAL_PWR_PVDCallback(void)
PWR PVD interrupt callback.

◆ HAL_PWREx_PVM1Callback()

__weak void HAL_PWREx_PVM1Callback ( void  )

PWR PVM1 interrupt callback.

Return values
None

Definition at line 1385 of file stm32l4xx_hal_pwr_ex.c.

1386 {
1387  /* NOTE : This function should not be modified; when the callback is needed,
1388  HAL_PWREx_PVM1Callback() API can be implemented in the user file
1389  */
1390 }

◆ HAL_PWREx_PVM2Callback()

__weak void HAL_PWREx_PVM2Callback ( void  )

PWR PVM2 interrupt callback.

Return values
None

Definition at line 1398 of file stm32l4xx_hal_pwr_ex.c.

1399 {
1400  /* NOTE : This function should not be modified; when the callback is needed,
1401  HAL_PWREx_PVM2Callback() API can be implemented in the user file
1402  */
1403 }

◆ HAL_PWREx_PVM3Callback()

__weak void HAL_PWREx_PVM3Callback ( void  )

PWR PVM3 interrupt callback.

Return values
None

Definition at line 1410 of file stm32l4xx_hal_pwr_ex.c.

1411 {
1412  /* NOTE : This function should not be modified; when the callback is needed,
1413  HAL_PWREx_PVM3Callback() API can be implemented in the user file
1414  */
1415 }

◆ HAL_PWREx_PVM4Callback()

__weak void HAL_PWREx_PVM4Callback ( void  )

PWR PVM4 interrupt callback.

Return values
None

Definition at line 1421 of file stm32l4xx_hal_pwr_ex.c.

1422 {
1423  /* NOTE : This function should not be modified; when the callback is needed,
1424  HAL_PWREx_PVM4Callback() API can be implemented in the user file
1425  */
1426 }