tdse-tp0_02-hw_sw_test

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