1 /**
2 ******************************************************************************
3 * @file stm32wlxx_ll_pwr.c
4 * @author MCD Application Team
5 * @brief PWR LL module driver.
6 ******************************************************************************
7 * @attention
8 *
9 * Copyright (c) 2020 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 #if defined(USE_FULL_LL_DRIVER)
19
20 /* Includes ------------------------------------------------------------------*/
21 #include "stm32wlxx_ll_pwr.h"
22 #include "stm32wlxx_ll_bus.h"
23
24 /** @addtogroup STM32WLxx_LL_Driver
25 * @{
26 */
27
28 #if defined(PWR)
29
30 /** @defgroup PWR_LL PWR
31 * @{
32 */
33
34 /* Private types -------------------------------------------------------------*/
35 /* Private variables ---------------------------------------------------------*/
36 /* Private constants ---------------------------------------------------------*/
37
38 /** @addtogroup PWR_LL_Private_Constants PWR Private Constants
39 * @{
40 */
41 /* Definitions of PWR registers reset value */
42 #define PWR_CR1_RESET_VALUE (0x00000200)
43 #define PWR_CR2_RESET_VALUE (0x00000000)
44 #define PWR_CR3_RESET_VALUE (PWR_CR3_EIWUL)
45 #define PWR_CR4_RESET_VALUE (0x00000000)
46 #define PWR_CR5_RESET_VALUE (0x00000000)
47 #define PWR_PUCRA_RESET_VALUE (0x00000000)
48 #define PWR_PDCRA_RESET_VALUE (0x00000000)
49 #define PWR_PUCRB_RESET_VALUE (0x00000000)
50 #define PWR_PDCRB_RESET_VALUE (0x00000000)
51 #define PWR_PUCRC_RESET_VALUE (0x00000000)
52 #define PWR_PDCRC_RESET_VALUE (0x00000000)
53 #define PWR_PUCRH_RESET_VALUE (0x00000000)
54 #define PWR_PDCRH_RESET_VALUE (0x00000000)
55 #if defined(DUAL_CORE)
56 #define PWR_C2CR1_RESET_VALUE (PWR_C2CR1_LPMS_2 | PWR_C2CR1_LPMS_1 | PWR_C2CR1_LPMS_0)
57 #define PWR_C2CR3_RESET_VALUE (0x00000000)
58 #endif
59 /**
60 * @}
61 */
62
63 /* Private macros ------------------------------------------------------------*/
64 /* Private function prototypes -----------------------------------------------*/
65
66 /* Exported functions --------------------------------------------------------*/
67 /** @addtogroup PWR_LL_Exported_Functions
68 * @{
69 */
70
71 /** @addtogroup PWR_LL_EF_Init
72 * @{
73 */
74
75 /**
76 * @brief De-initialize the PWR registers to their default reset values.
77 * @retval An ErrorStatus enumeration value:
78 * - SUCCESS: PWR registers are de-initialized
79 * - ERROR: not applicable
80 */
LL_PWR_DeInit(void)81 ErrorStatus LL_PWR_DeInit(void)
82 {
83 /* Apply reset values to all PWR registers */
84 LL_PWR_WriteReg(CR1, PWR_CR1_RESET_VALUE);
85 LL_PWR_WriteReg(CR2, PWR_CR2_RESET_VALUE);
86 LL_PWR_WriteReg(CR3, PWR_CR3_RESET_VALUE);
87 LL_PWR_WriteReg(CR4, PWR_CR4_RESET_VALUE);
88 LL_PWR_WriteReg(CR5, PWR_CR5_RESET_VALUE);
89 LL_PWR_WriteReg(PUCRA, PWR_PUCRA_RESET_VALUE);
90 LL_PWR_WriteReg(PDCRA, PWR_PDCRA_RESET_VALUE);
91 LL_PWR_WriteReg(PUCRB, PWR_PUCRB_RESET_VALUE);
92 LL_PWR_WriteReg(PDCRB, PWR_PDCRB_RESET_VALUE);
93 LL_PWR_WriteReg(PUCRC, PWR_PUCRC_RESET_VALUE);
94 LL_PWR_WriteReg(PDCRC, PWR_PDCRC_RESET_VALUE);
95 LL_PWR_WriteReg(PUCRH, PWR_PUCRH_RESET_VALUE);
96 LL_PWR_WriteReg(PDCRH, PWR_PDCRH_RESET_VALUE);
97 #ifdef CORE_CM0PLUS
98 LL_PWR_WriteReg(C2CR1, PWR_C2CR1_RESET_VALUE);
99 LL_PWR_WriteReg(C2CR3, PWR_C2CR3_RESET_VALUE);
100 #endif
101
102 /* Clear all flags */
103 #if defined(DUAL_CORE)
104 LL_PWR_WriteReg(SCR,
105 LL_PWR_SCR_CWUF
106 | LL_PWR_SCR_CWRFBUSYF
107 | LL_PWR_SCR_CWPVDF
108 | LL_PWR_SCR_CC2HF
109 );
110 #else
111 LL_PWR_WriteReg(SCR,
112 LL_PWR_SCR_CWUF
113 | LL_PWR_SCR_CWRFBUSYF
114 | LL_PWR_SCR_CWPVDF
115 );
116 #endif
117
118 #ifdef CORE_CM0PLUS
119 LL_PWR_WriteReg(EXTSCR,
120 LL_PWR_EXTSCR_C2CSSF
121 );
122 #else
123 LL_PWR_WriteReg(EXTSCR,
124 LL_PWR_EXTSCR_C1CSSF
125 );
126 #endif
127
128 return SUCCESS;
129 }
130
131 /**
132 * @}
133 */
134
135 /**
136 * @}
137 */
138
139 /**
140 * @}
141 */
142 #endif /* defined(PWR) */
143 /**
144 * @}
145 */
146
147 #endif /* USE_FULL_LL_DRIVER */
148
149