Subversion Repositories EDIS_Ignition

Rev

Rev 2 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**
  2.   ******************************************************************************
  3.   * @file    stm32f1xx_hal_pwr.h
  4.   * @author  MCD Application Team
  5.   * @brief   Header file of PWR HAL module.
  6.   ******************************************************************************
  7.   * @attention
  8.   *
  9.   * Copyright (c) 2016 STMicroelectronics.
  10.   * All rights reserved.
  11.   *
  12.   * This software is licensed under terms that can be found in the LICENSE file
  13.   * in the root directory of this software component.
  14.   * If no LICENSE file comes with this software, it is provided AS-IS.
  15.   *
  16.   ******************************************************************************
  17.   */
  18.  
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F1xx_HAL_PWR_H
  21. #define __STM32F1xx_HAL_PWR_H
  22.  
  23. #ifdef __cplusplus
  24.  extern "C" {
  25. #endif
  26.  
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f1xx_hal_def.h"
  29.  
  30. /** @addtogroup STM32F1xx_HAL_Driver
  31.   * @{
  32.   */
  33.  
  34. /** @addtogroup PWR
  35.   * @{
  36.   */
  37.  
  38. /* Exported types ------------------------------------------------------------*/
  39.  
  40. /** @defgroup PWR_Exported_Types PWR Exported Types
  41.   * @{
  42.   */
  43.  
  44. /**
  45.   * @brief  PWR PVD configuration structure definition
  46.   */
  47. typedef struct
  48. {
  49.   uint32_t PVDLevel;   /*!< PVDLevel: Specifies the PVD detection level.
  50.                             This parameter can be a value of @ref PWR_PVD_detection_level */
  51.  
  52.   uint32_t Mode;      /*!< Mode: Specifies the operating mode for the selected pins.
  53.                            This parameter can be a value of @ref PWR_PVD_Mode */
  54. }PWR_PVDTypeDef;
  55.  
  56.  
  57. /**
  58.   * @}
  59.   */
  60.  
  61.  
  62. /* Internal constants --------------------------------------------------------*/
  63.  
  64. /** @addtogroup PWR_Private_Constants
  65.   * @{
  66.   */
  67.  
  68. #define PWR_EXTI_LINE_PVD  ((uint32_t)0x00010000)  /*!< External interrupt line 16 Connected to the PVD EXTI Line */
  69.  
  70. /**
  71.   * @}
  72.   */
  73.  
  74.  
  75. /* Exported constants --------------------------------------------------------*/
  76.  
  77. /** @defgroup PWR_Exported_Constants PWR Exported Constants
  78.   * @{
  79.   */
  80.  
  81. /** @defgroup PWR_PVD_detection_level PWR PVD detection level
  82.   * @{
  83.   */
  84. #define PWR_PVDLEVEL_0                  PWR_CR_PLS_2V2
  85. #define PWR_PVDLEVEL_1                  PWR_CR_PLS_2V3
  86. #define PWR_PVDLEVEL_2                  PWR_CR_PLS_2V4
  87. #define PWR_PVDLEVEL_3                  PWR_CR_PLS_2V5
  88. #define PWR_PVDLEVEL_4                  PWR_CR_PLS_2V6
  89. #define PWR_PVDLEVEL_5                  PWR_CR_PLS_2V7
  90. #define PWR_PVDLEVEL_6                  PWR_CR_PLS_2V8
  91. #define PWR_PVDLEVEL_7                  PWR_CR_PLS_2V9
  92.                                                          
  93. /**
  94.   * @}
  95.   */
  96.  
  97. /** @defgroup PWR_PVD_Mode PWR PVD Mode
  98.   * @{
  99.   */
  100. #define PWR_PVD_MODE_NORMAL                 0x00000000U   /*!< basic mode is used */
  101. #define PWR_PVD_MODE_IT_RISING              0x00010001U   /*!< External Interrupt Mode with Rising edge trigger detection */
  102. #define PWR_PVD_MODE_IT_FALLING             0x00010002U   /*!< External Interrupt Mode with Falling edge trigger detection */
  103. #define PWR_PVD_MODE_IT_RISING_FALLING      0x00010003U   /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
  104. #define PWR_PVD_MODE_EVENT_RISING           0x00020001U   /*!< Event Mode with Rising edge trigger detection */
  105. #define PWR_PVD_MODE_EVENT_FALLING          0x00020002U   /*!< Event Mode with Falling edge trigger detection */
  106. #define PWR_PVD_MODE_EVENT_RISING_FALLING   0x00020003U   /*!< Event Mode with Rising/Falling edge trigger detection */
  107.  
  108. /**
  109.   * @}
  110.   */
  111.  
  112.  
  113. /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins
  114.   * @{
  115.   */
  116.  
  117. #define PWR_WAKEUP_PIN1                 PWR_CSR_EWUP
  118.  
  119. /**
  120.   * @}
  121.   */
  122.  
  123. /** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR Regulator state in SLEEP/STOP mode
  124.   * @{
  125.   */
  126. #define PWR_MAINREGULATOR_ON                        0x00000000U
  127. #define PWR_LOWPOWERREGULATOR_ON                    PWR_CR_LPDS
  128.  
  129. /**
  130.   * @}
  131.   */
  132.  
  133. /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
  134.   * @{
  135.   */
  136. #define PWR_SLEEPENTRY_WFI              ((uint8_t)0x01)
  137. #define PWR_SLEEPENTRY_WFE              ((uint8_t)0x02)
  138.  
  139. /**
  140.   * @}
  141.   */
  142.  
  143. /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
  144.   * @{
  145.   */
  146. #define PWR_STOPENTRY_WFI               ((uint8_t)0x01)
  147. #define PWR_STOPENTRY_WFE               ((uint8_t)0x02)
  148.  
  149. /**
  150.   * @}
  151.   */
  152.  
  153. /** @defgroup PWR_Flag PWR Flag
  154.   * @{
  155.   */
  156. #define PWR_FLAG_WU                     PWR_CSR_WUF
  157. #define PWR_FLAG_SB                     PWR_CSR_SBF
  158. #define PWR_FLAG_PVDO                   PWR_CSR_PVDO
  159.  
  160.  
  161. /**
  162.   * @}
  163.   */
  164.  
  165. /**
  166.   * @}
  167.   */
  168.  
  169. /* Exported macro ------------------------------------------------------------*/
  170. /** @defgroup PWR_Exported_Macros PWR Exported Macros
  171.   * @{
  172.   */
  173.  
  174. /** @brief  Check PWR flag is set or not.
  175.   * @param  __FLAG__: specifies the flag to check.
  176.   *           This parameter can be one of the following values:
  177.   *            @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
  178.   *                  was received from the WKUP pin or from the RTC alarm
  179.   *                  An additional wakeup event is detected if the WKUP pin is enabled
  180.   *                  (by setting the EWUP bit) when the WKUP pin level is already high.
  181.   *            @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
  182.   *                  resumed from StandBy mode.
  183.   *            @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  184.   *                  by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
  185.   *                  For this reason, this bit is equal to 0 after Standby or reset
  186.   *                  until the PVDE bit is set.
  187.   * @retval The new state of __FLAG__ (TRUE or FALSE).
  188.   */
  189. #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
  190.  
  191. /** @brief  Clear the PWR's pending flags.
  192.   * @param  __FLAG__: specifies the flag to clear.
  193.   *          This parameter can be one of the following values:
  194.   *            @arg PWR_FLAG_WU: Wake Up flag
  195.   *            @arg PWR_FLAG_SB: StandBy flag
  196.   */
  197. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CR, ((__FLAG__) << 2))
  198.  
  199. /**
  200.   * @brief Enable interrupt on PVD Exti Line 16.
  201.   * @retval None.
  202.   */
  203. #define __HAL_PWR_PVD_EXTI_ENABLE_IT()      SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
  204.  
  205. /**
  206.   * @brief Disable interrupt on PVD Exti Line 16.
  207.   * @retval None.
  208.   */
  209. #define __HAL_PWR_PVD_EXTI_DISABLE_IT()     CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
  210.  
  211. /**
  212.   * @brief Enable event on PVD Exti Line 16.
  213.   * @retval None.
  214.   */
  215. #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT()   SET_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
  216.  
  217. /**
  218.   * @brief Disable event on PVD Exti Line 16.
  219.   * @retval None.
  220.   */
  221. #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT()  CLEAR_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
  222.  
  223.  
  224. /**
  225.   * @brief  PVD EXTI line configuration: set falling edge trigger.  
  226.   * @retval None.
  227.   */
  228. #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE()  SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
  229.  
  230.  
  231. /**
  232.   * @brief Disable the PVD Extended Interrupt Falling Trigger.
  233.   * @retval None.
  234.   */
  235. #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE()  CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
  236.  
  237.  
  238. /**
  239.   * @brief  PVD EXTI line configuration: set rising edge trigger.
  240.   * @retval None.
  241.   */
  242. #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE()   SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
  243.  
  244. /**
  245.   * @brief Disable the PVD Extended Interrupt Rising Trigger.
  246.   * This parameter can be:
  247.   * @retval None.
  248.   */
  249. #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE()  CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
  250.  
  251. /**
  252.   * @brief  PVD EXTI line configuration: set rising & falling edge trigger.
  253.   * @retval None.
  254.   */
  255. #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE()   __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
  256.  
  257. /**
  258.   * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
  259.   * This parameter can be:
  260.   * @retval None.
  261.   */
  262. #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE()  __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
  263.  
  264.  
  265.  
  266. /**
  267.   * @brief Check whether the specified PVD EXTI interrupt flag is set or not.
  268.   * @retval EXTI PVD Line Status.
  269.   */
  270. #define __HAL_PWR_PVD_EXTI_GET_FLAG()       (EXTI->PR & (PWR_EXTI_LINE_PVD))
  271.  
  272. /**
  273.   * @brief Clear the PVD EXTI flag.
  274.   * @retval None.
  275.   */
  276. #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG()     (EXTI->PR = (PWR_EXTI_LINE_PVD))
  277.  
  278. /**
  279.   * @brief Generate a Software interrupt on selected EXTI line.
  280.   * @retval None.
  281.   */
  282. #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT()  SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD)
  283. /**
  284.   * @}
  285.   */
  286.  
  287. /* Private macro -------------------------------------------------------------*/
  288. /** @defgroup PWR_Private_Macros PWR Private Macros
  289.   * @{
  290.   */
  291. #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
  292.                                  ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
  293.                                  ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
  294.                                  ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
  295.  
  296.  
  297. #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
  298.                               ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
  299.                               ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
  300.                               ((MODE) == PWR_PVD_MODE_NORMAL))
  301.  
  302. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1))
  303.  
  304. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
  305.                                      ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
  306.  
  307. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
  308.  
  309. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  310.  
  311. /**
  312.   * @}
  313.   */
  314.  
  315.  
  316.  
  317. /* Exported functions --------------------------------------------------------*/
  318.  
  319. /** @addtogroup PWR_Exported_Functions PWR Exported Functions
  320.   * @{
  321.   */
  322.  
  323. /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
  324.   * @{
  325.   */
  326.  
  327. /* Initialization and de-initialization functions *******************************/
  328. void HAL_PWR_DeInit(void);
  329. void HAL_PWR_EnableBkUpAccess(void);
  330. void HAL_PWR_DisableBkUpAccess(void);
  331.  
  332. /**
  333.   * @}
  334.   */
  335.  
  336. /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
  337.   * @{
  338.   */
  339.  
  340. /* Peripheral Control functions  ************************************************/
  341. void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
  342. /* #define HAL_PWR_ConfigPVD 12*/
  343. void HAL_PWR_EnablePVD(void);
  344. void HAL_PWR_DisablePVD(void);
  345.  
  346. /* WakeUp pins configuration functions ****************************************/
  347. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
  348. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
  349.  
  350. /* Low Power modes configuration functions ************************************/
  351. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  352. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
  353. void HAL_PWR_EnterSTANDBYMode(void);
  354.  
  355. void HAL_PWR_EnableSleepOnExit(void);
  356. void HAL_PWR_DisableSleepOnExit(void);
  357. void HAL_PWR_EnableSEVOnPend(void);
  358. void HAL_PWR_DisableSEVOnPend(void);
  359.  
  360.  
  361.  
  362. void HAL_PWR_PVD_IRQHandler(void);
  363. void HAL_PWR_PVDCallback(void);
  364. /**
  365.   * @}
  366.   */
  367.  
  368. /**
  369.   * @}
  370.   */
  371.  
  372. /**
  373.   * @}
  374.   */
  375.  
  376. /**
  377.   * @}
  378.   */
  379.  
  380. #ifdef __cplusplus
  381. }
  382. #endif
  383.  
  384.  
  385. #endif /* __STM32F1xx_HAL_PWR_H */
  386.