Skip to content

Commit d3caae5

Browse files
committed
bsp: add support for the STM32U5xx soc
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 3f26f9b commit d3caae5

File tree

2 files changed

+74
-9
lines changed

2 files changed

+74
-9
lines changed

src/STM32LowPower.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void STM32LowPower::programRtcWakeUp(uint32_t ms, LP_Mode lp_mode)
191191
break;
192192
default:
193193
case SHUTDOWN_MODE:
194-
#if defined(STM32L4xx) || defined(STM32L5xx)
194+
#if defined(STM32L4xx) || defined(STM32L5xx) || defined(STM32U5xx)
195195
// For shutdown mode LSE have to be used (STM32L4 or STM32L5 series only)
196196
clkSrc = STM32RTC::LSE_CLOCK;
197197
#else

src/low_power.c

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ static void (*WakeUpUartCb)(void) = NULL;
3737

3838
#if defined(PWR_FLAG_WUF)
3939
#define PWR_FLAG_WU PWR_FLAG_WUF
40+
#elif defined(PWR_WAKEUP_ALL_FLAG)
41+
#define PWR_FLAG_WU PWR_WAKEUP_ALL_FLAG
42+
#endif
43+
#if defined(PWR_FLAG_SBF)
44+
#define PWR_FLAG_SB PWR_FLAG_SBF
4045
#endif
4146

4247
/**
@@ -82,7 +87,14 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
8287
PinName p = digitalPinToPinName(pin);
8388
if (p != NC) {
8489
#ifdef PWR_WAKEUP_PIN1
85-
if (p == SYS_WKUP1) {
90+
if ((p == SYS_WKUP1)
91+
#ifdef PWR_WAKEUP_PIN1_1
92+
|| (p == SYS_WKUP1_1)
93+
#endif
94+
#ifdef PWR_WAKEUP_PIN1_2
95+
|| (p == SYS_WKUP1_2)
96+
#endif
97+
) {
8698
wkup_pin = PWR_WAKEUP_PIN1;
8799
#ifdef PWR_WAKEUP_PIN1_HIGH
88100
if (mode != RISING) {
@@ -92,7 +104,14 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
92104
}
93105
#endif /* PWR_WAKEUP_PIN1 */
94106
#ifdef PWR_WAKEUP_PIN2
95-
if (p == SYS_WKUP2) {
107+
if ((p == SYS_WKUP2)
108+
#ifdef PWR_WAKEUP_PIN2_1
109+
|| (p == SYS_WKUP2_1)
110+
#endif
111+
#ifdef PWR_WAKEUP_PIN2_2
112+
|| (p == SYS_WKUP2_2)
113+
#endif
114+
) {
96115
wkup_pin = PWR_WAKEUP_PIN2;
97116
#ifdef PWR_WAKEUP_PIN2_HIGH
98117
if (mode != RISING) {
@@ -102,7 +121,14 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
102121
}
103122
#endif /* PWR_WAKEUP_PIN2 */
104123
#ifdef PWR_WAKEUP_PIN3
105-
if (p == SYS_WKUP3) {
124+
if ((p == SYS_WKUP3)
125+
#ifdef PWR_WAKEUP_PIN3_1
126+
|| (p == SYS_WKUP3_1)
127+
#endif
128+
#ifdef PWR_WAKEUP_PIN3_2
129+
|| (p == SYS_WKUP3_2)
130+
#endif
131+
) {
106132
wkup_pin = PWR_WAKEUP_PIN3;
107133
#ifdef PWR_WAKEUP_PIN3_HIGH
108134
if (mode != RISING) {
@@ -112,7 +138,14 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
112138
}
113139
#endif /* PWR_WAKEUP_PIN3 */
114140
#ifdef PWR_WAKEUP_PIN4
115-
if (p == SYS_WKUP4) {
141+
if ((p == SYS_WKUP4)
142+
#ifdef PWR_WAKEUP_PIN4_1
143+
|| (p == SYS_WKUP4_1)
144+
#endif
145+
#ifdef PWR_WAKEUP_PIN4_2
146+
|| (p == SYS_WKUP4_2)
147+
#endif
148+
) {
116149
wkup_pin = PWR_WAKEUP_PIN4;
117150
#ifdef PWR_WAKEUP_PIN4_HIGH
118151
if (mode != RISING) {
@@ -122,7 +155,14 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
122155
}
123156
#endif /* PWR_WAKEUP_PIN4 */
124157
#ifdef PWR_WAKEUP_PIN5
125-
if (p == SYS_WKUP5) {
158+
if ((p == SYS_WKUP5)
159+
#ifdef PWR_WAKEUP_PIN5_1
160+
|| (p == SYS_WKUP5_1)
161+
#endif
162+
#ifdef PWR_WAKEUP_PIN5_2
163+
|| (p == SYS_WKUP5_2)
164+
#endif
165+
) {
126166
wkup_pin = PWR_WAKEUP_PIN5;
127167
#ifdef PWR_WAKEUP_PIN5_HIGH
128168
if (mode != RISING) {
@@ -132,7 +172,14 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
132172
}
133173
#endif /* PWR_WAKEUP_PIN5 */
134174
#ifdef PWR_WAKEUP_PIN6
135-
if (p == SYS_WKUP6) {
175+
if ((p == SYS_WKUP6)
176+
#ifdef PWR_WAKEUP_PIN6_1
177+
|| (p == SYS_WKUP6_1)
178+
#endif
179+
#ifdef PWR_WAKEUP_PIN6_2
180+
|| (p == SYS_WKUP6_2)
181+
#endif
182+
) {
136183
wkup_pin = PWR_WAKEUP_PIN6;
137184
#ifdef PWR_WAKEUP_PIN6_HIGH
138185
if (mode != RISING) {
@@ -142,12 +189,26 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
142189
}
143190
#endif /* PWR_WAKEUP_PIN6 */
144191
#ifdef PWR_WAKEUP_PIN7
145-
if (p == SYS_WKUP7) {
192+
if ((p == SYS_WKUP7)
193+
#ifdef PWR_WAKEUP_PIN7_1
194+
|| (p == SYS_WKUP7_1)
195+
#endif
196+
#ifdef PWR_WAKEUP_PIN7_2
197+
|| (p == SYS_WKUP7_2)
198+
#endif
199+
) {
146200
wkup_pin = PWR_WAKEUP_PIN7;
147201
}
148202
#endif /* PWR_WAKEUP_PIN7 */
149203
#ifdef PWR_WAKEUP_PIN8
150-
if (p == SYS_WKUP8) {
204+
if ((p == SYS_WKUP8)
205+
#ifdef PWR_WAKEUP_PIN8_1
206+
|| (p == SYS_WKUP8_1)
207+
#endif
208+
#ifdef PWR_WAKEUP_PIN8_2
209+
|| (p == SYS_WKUP8_2)
210+
#endif
211+
) {
151212
wkup_pin = PWR_WAKEUP_PIN8;
152213
}
153214
#endif /* PWR_WAKEUP_PIN8 */
@@ -201,6 +262,10 @@ void LowPower_stop(serial_t *obj)
201262
/* Enable Ultra low power mode */
202263
HAL_PWREx_EnableUltraLowPower();
203264
#endif
265+
#if defined(PWR_CR1_ULPMEN) || defined(PWR_CR3_ULPMEN)
266+
/* Enable Ultra low power mode */
267+
HAL_PWREx_EnableUltraLowPowerMode();
268+
#endif
204269
#if defined(PWR_CR_FWU)
205270
/* Enable the fast wake up from Ultra low power mode */
206271
HAL_PWREx_EnableFastWakeUp();

0 commit comments

Comments
 (0)