1 /**
2   ******************************************************************************
3   * @file    stm32c0xx_hal_pwr_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of PWR HAL Extended module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2022 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 STM32C0xx_HAL_PWR_EX_H
21 #define STM32C0xx_HAL_PWR_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32c0xx_hal_def.h"
29 
30 /** @addtogroup STM32C0xx_HAL_Driver
31   * @{
32   */
33 
34 /** @defgroup PWREx PWREx
35   * @brief PWR Extended HAL module driver
36   * @{
37   */
38 
39 /* Exported types ------------------------------------------------------------*/
40 /* Exported constants --------------------------------------------------------*/
41 /** @defgroup PWREx_Exported_Constants  PWR Extended Exported Constants
42   * @{
43   */
44 
45 /** @defgroup PWREx_GPIO_Pin_Mask PWR Extended GPIO Pin Mask
46   * @{
47   */
48 #define PWR_GPIO_BIT_0      (0x0001U)     /*!< GPIO port I/O pin 0  */
49 #define PWR_GPIO_BIT_1      (0x0002U)     /*!< GPIO port I/O pin 1  */
50 #define PWR_GPIO_BIT_2      (0x0004U)     /*!< GPIO port I/O pin 2  */
51 #define PWR_GPIO_BIT_3      (0x0008U)     /*!< GPIO port I/O pin 3  */
52 #define PWR_GPIO_BIT_4      (0x0010U)     /*!< GPIO port I/O pin 4  */
53 #define PWR_GPIO_BIT_5      (0x0020U)     /*!< GPIO port I/O pin 5  */
54 #define PWR_GPIO_BIT_6      (0x0040U)     /*!< GPIO port I/O pin 6  */
55 #define PWR_GPIO_BIT_7      (0x0080U)     /*!< GPIO port I/O pin 7  */
56 #define PWR_GPIO_BIT_8      (0x0100U)     /*!< GPIO port I/O pin 8  */
57 #define PWR_GPIO_BIT_9      (0x0200U)     /*!< GPIO port I/O pin 9  */
58 #define PWR_GPIO_BIT_10     (0x0400U)     /*!< GPIO port I/O pin 10 */
59 #define PWR_GPIO_BIT_11     (0x0800U)     /*!< GPIO port I/O pin 11 */
60 #define PWR_GPIO_BIT_12     (0x1000U)     /*!< GPIO port I/O pin 12 */
61 #define PWR_GPIO_BIT_13     (0x2000U)     /*!< GPIO port I/O pin 13 */
62 #define PWR_GPIO_BIT_14     (0x4000U)     /*!< GPIO port I/O pin 14 */
63 #define PWR_GPIO_BIT_15     (0x8000U)     /*!< GPIO port I/O pin 15 */
64 /**
65   * @}
66   */
67 
68 /** @defgroup PWREx_Backup_Registers  PWREx Backup Registers Definition
69   * @{
70   */
71 #define PWR_BKP_NUMBER                    4U
72 #define PWR_BKP_DR0                       0x00U
73 #define PWR_BKP_DR1                       0x01U
74 #define PWR_BKP_DR2                       0x02U
75 #define PWR_BKP_DR3                       0x03U
76 /**
77   * @}
78   */
79 
80 /** @defgroup PWREx_GPIO_Port  GPIO Port
81   * @{
82   */
83 #define PWR_GPIO_A                          (0x00000000u)  /*!< GPIO port A */
84 #define PWR_GPIO_B                          (0x00000001u)  /*!< GPIO port B */
85 #define PWR_GPIO_C                          (0x00000002u)  /*!< GPIO port C */
86 #if defined(STM32C031xx)
87 #define PWR_GPIO_D                          (0x00000003u)  /*!< GPIO port D */
88 #endif /* STM32C031xx */
89 #define PWR_GPIO_F                          (0x00000005u)  /*!< GPIO port F */
90 /**
91   * @}
92   */
93 
94 /** @defgroup PWREx_Flash_PowerDown  Flash Power Down modes
95   * @{
96   */
97 #define PWR_FLASHPD_SLEEP                   PWR_CR1_FPD_SLP    /*!< Enable Flash power down in sleep mode */
98 #define PWR_FLASHPD_STOP                    PWR_CR1_FPD_STOP   /*!< Enable Flash power down in stop mode */
99 /**
100   * @}
101   */
102 
103 
104 /**
105   * @}
106   */
107 
108 /* Exported macros -----------------------------------------------------------*/
109 /* Private macros ------------------------------------------------------------*/
110 /** @addtogroup  PWREx_Private_Macros   PWR Extended Private Macros
111   * @{
112   */
113 
114 #define IS_PWR_GPIO_BIT_NUMBER(__BIT_NUMBER__)  ((((__BIT_NUMBER__) & 0x0000FFFFu) != 0x00u) && \
115                                                  (((__BIT_NUMBER__) & 0xFFFF0000u) == 0x00u))
116 #if defined(STM32C031xx)
117 #define IS_PWR_GPIO(__GPIO__)               (((__GPIO__) == PWR_GPIO_A) || \
118                                              ((__GPIO__) == PWR_GPIO_B) || \
119                                              ((__GPIO__) == PWR_GPIO_C) || \
120                                              ((__GPIO__) == PWR_GPIO_D) || \
121                                              ((__GPIO__) == PWR_GPIO_F))
122 #elif defined (STM32C011xx)
123 #define IS_PWR_GPIO(__GPIO__)               (((__GPIO__) == PWR_GPIO_A) || \
124                                              ((__GPIO__) == PWR_GPIO_B) || \
125                                              ((__GPIO__) == PWR_GPIO_C) || \
126                                              ((__GPIO__) == PWR_GPIO_F))
127 
128 #endif /* STM32C031xx */
129 #define IS_PWR_FLASH_POWERDOWN(__MODE__)    ((((__MODE__) & (PWR_FLASHPD_SLEEP | PWR_FLASHPD_STOP)) != 0x00u) && \
130                                              (((__MODE__) & ~(PWR_FLASHPD_SLEEP | PWR_FLASHPD_STOP)) == 0x00u))
131 
132 #define IS_PWR_BKP(__BKP__)   ((__BKP__) < PWR_BKP_NUMBER)
133 
134 
135 
136 /**
137   * @}
138   */
139 
140 /* Exported functions --------------------------------------------------------*/
141 /** @defgroup PWREx_Exported_Functions  PWR Extended Exported Functions
142   * @{
143   */
144 
145 /** @defgroup PWREx_Exported_Functions_Group1  Extended Peripheral Control functions
146   * @{
147   */
148 
149 /* Peripheral Control functions  **********************************************/
150 void              HAL_PWREx_EnableInternalWakeUpLine(void);
151 void              HAL_PWREx_DisableInternalWakeUpLine(void);
152 HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber);
153 HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber);
154 HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber);
155 HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber);
156 void              HAL_PWREx_EnablePullUpPullDownConfig(void);
157 void              HAL_PWREx_DisablePullUpPullDownConfig(void);
158 void              HAL_PWREx_EnableFlashPowerDown(uint32_t PowerMode);
159 void              HAL_PWREx_DisableFlashPowerDown(uint32_t PowerMode);
160 void              HAL_PWREx_BKUPWrite(uint32_t BackupRegister, uint16_t Data);
161 uint32_t          HAL_PWREx_BKUPRead(uint32_t BackupRegister);
162 
163 /* Low Power modes configuration functions ************************************/
164 void              HAL_PWREx_EnterSHUTDOWNMode(void);
165 
166 
167 /**
168   * @}
169   */
170 
171 /**
172   * @}
173   */
174 
175 /**
176   * @}
177   */
178 
179 /**
180   * @}
181   */
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 
188 #endif /* STM32C0xx_HAL_PWR_EX_H */
189