Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

162 lines
4.6 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_pwr_ex.c
  4. * @author MCD Application Team
  5. * @brief Extended PWR HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of the Power Controller (PWR) peripheral:
  8. * + Extended Initialization and de-initialization functions
  9. * + Extended Peripheral Control functions
  10. *
  11. ******************************************************************************
  12. * @attention
  13. *
  14. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  15. * All rights reserved.</center></h2>
  16. *
  17. * This software component is licensed by ST under BSD 3-Clause license,
  18. * the "License"; You may not use this file except in compliance with the
  19. * License. You may obtain a copy of the License at:
  20. * opensource.org/licenses/BSD-3-Clause
  21. *
  22. ******************************************************************************
  23. */
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l1xx_hal.h"
  26. /** @addtogroup STM32L1xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup PWREx PWREx
  30. * @brief PWR HAL module driver
  31. * @{
  32. */
  33. #ifdef HAL_PWR_MODULE_ENABLED
  34. /* Private typedef -----------------------------------------------------------*/
  35. /* Private define ------------------------------------------------------------*/
  36. /* Private macro -------------------------------------------------------------*/
  37. /* Private variables ---------------------------------------------------------*/
  38. /* Private function prototypes -----------------------------------------------*/
  39. /* Private functions ---------------------------------------------------------*/
  40. /** @defgroup PWREx_Exported_Functions PWREx Exported Functions
  41. * @{
  42. */
  43. /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions
  44. * @brief Low Power modes configuration functions
  45. *
  46. @verbatim
  47. ===============================================================================
  48. ##### Peripheral extended features functions #####
  49. ===============================================================================
  50. @endverbatim
  51. * @{
  52. */
  53. /**
  54. * @brief Return Voltage Scaling Range.
  55. * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3)
  56. */
  57. uint32_t HAL_PWREx_GetVoltageRange(void)
  58. {
  59. return (PWR->CR & PWR_CR_VOS);
  60. }
  61. /**
  62. * @brief Enables the Fast WakeUp from Ultra Low Power mode.
  63. * @note This bit works in conjunction with ULP bit.
  64. * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when
  65. * exiting from low power mode.
  66. * @retval None
  67. */
  68. void HAL_PWREx_EnableFastWakeUp(void)
  69. {
  70. /* Enable the fast wake up */
  71. *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;
  72. }
  73. /**
  74. * @brief Disables the Fast WakeUp from Ultra Low Power mode.
  75. * @retval None
  76. */
  77. void HAL_PWREx_DisableFastWakeUp(void)
  78. {
  79. /* Disable the fast wake up */
  80. *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;
  81. }
  82. /**
  83. * @brief Enables the Ultra Low Power mode
  84. * @retval None
  85. */
  86. void HAL_PWREx_EnableUltraLowPower(void)
  87. {
  88. /* Enable the Ultra Low Power mode */
  89. *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;
  90. }
  91. /**
  92. * @brief Disables the Ultra Low Power mode
  93. * @retval None
  94. */
  95. void HAL_PWREx_DisableUltraLowPower(void)
  96. {
  97. /* Disable the Ultra Low Power mode */
  98. *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;
  99. }
  100. /**
  101. * @brief Enters the Low Power Run mode.
  102. * @note Low power run mode can only be entered when VCORE is in range 2.
  103. * In addition, the dynamic voltage scaling must not be used when Low
  104. * power run mode is selected. Only Stop and Sleep modes with regulator
  105. * configured in Low power mode is allowed when Low power run mode is
  106. * selected.
  107. * @note In Low power run mode, all I/O pins keep the same state as in Run mode.
  108. * @retval None
  109. */
  110. void HAL_PWREx_EnableLowPowerRunMode(void)
  111. {
  112. /* Enters the Low Power Run mode */
  113. *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;
  114. *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE;
  115. }
  116. /**
  117. * @brief Exits the Low Power Run mode.
  118. * @retval None
  119. */
  120. HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)
  121. {
  122. /* Exits the Low Power Run mode */
  123. *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE;
  124. *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;
  125. return HAL_OK;
  126. }
  127. /**
  128. * @}
  129. */
  130. /**
  131. * @}
  132. */
  133. #endif /* HAL_PWR_MODULE_ENABLED */
  134. /**
  135. * @}
  136. */
  137. /**
  138. * @}
  139. */
  140. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/