|
37 | 37 | #include <stm32_ll_usart.h>
|
38 | 38 | #include <stm32_ll_lpuart.h>
|
39 | 39 | #if defined(CONFIG_PM) && defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE)
|
| 40 | +#include <stm32_ll_pwr.h> |
40 | 41 | #include <stm32_ll_exti.h>
|
41 | 42 | #endif /* CONFIG_PM */
|
42 | 43 |
|
@@ -111,6 +112,25 @@ static void uart_stm32_pm_policy_state_lock_get_unconditional(void)
|
111 | 112 | }
|
112 | 113 | }
|
113 | 114 |
|
| 115 | +static inline void uart_stm32_pm_enable_wakeup_line(uint32_t wakeup_line) |
| 116 | +{ |
| 117 | +#if defined(CONFIG_SOC_SERIES_STM32WB0X) |
| 118 | + ARG_UNUSED(wakeup_line); |
| 119 | +#if defined(PWR_CR3_EIWL2) |
| 120 | + /** |
| 121 | + * If SoC is equipped with LPUART instance, |
| 122 | + * enable the associated wake-up line in PWRC. |
| 123 | + */ |
| 124 | + LL_PWR_EnableInternWU2(); |
| 125 | +#endif /* PWR_CR3_EIWL2 */ |
| 126 | +#elif defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE) |
| 127 | + if (wakeup_line != STM32_WAKEUP_LINE_NONE) { |
| 128 | + /* Enable EXTI line associated to UART wake-up event */ |
| 129 | + LL_EXTI_EnableIT_0_31(BIT(wakeup_line)); |
| 130 | + } |
| 131 | +#endif /* CONFIG_SOC_SERIES_STM32WB0X */ |
| 132 | +} |
| 133 | + |
114 | 134 | static void uart_stm32_pm_policy_state_lock_get(const struct device *dev)
|
115 | 135 | {
|
116 | 136 | struct uart_stm32_data *data = dev->data;
|
@@ -2160,12 +2180,12 @@ static int uart_stm32_registers_configure(const struct device *dev)
|
2160 | 2180 | LL_USART_EnableIT_WKUP(usart);
|
2161 | 2181 | LL_USART_ClearFlag_WKUP(usart);
|
2162 | 2182 | #endif
|
| 2183 | +#if !defined(CONFIG_SOC_SERIES_STM32WB0X) || defined(USART_CR1_UESM) |
2163 | 2184 | LL_USART_EnableInStopMode(usart);
|
| 2185 | +#endif /* !CONFIG_SOC_SERIES_STM32WB0X || USART_CR1_UESM */ |
2164 | 2186 |
|
2165 |
| - if (config->wakeup_line != STM32_WAKEUP_LINE_NONE) { |
2166 |
| - /* Prepare the WAKEUP with the expected EXTI line */ |
2167 |
| - LL_EXTI_EnableIT_0_31(BIT(config->wakeup_line)); |
2168 |
| - } |
| 2187 | + /* Enable the wake-up line signal (if applicable to hardware) */ |
| 2188 | + uart_stm32_pm_enable_wakeup_line(config->wakeup_line); |
2169 | 2189 | }
|
2170 | 2190 | #endif /* CONFIG_PM */
|
2171 | 2191 |
|
|
0 commit comments