From 591612db7e5f8f8dd5120b12a55c00da38a510a8 Mon Sep 17 00:00:00 2001 From: Andres Vahter Date: Mon, 23 Oct 2023 22:39:24 +0300 Subject: [PATCH] stm32 uart: return error if rx and tx not enabled --- embassy-stm32/src/usart/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 880ca416..09d5a59d 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -108,6 +108,7 @@ pub enum StopBits { pub enum ConfigError { BaudrateTooLow, BaudrateTooHigh, + RxOrTxNotEnabled, } #[non_exhaustive] @@ -866,7 +867,7 @@ fn configure( enable_tx: bool, ) -> Result<(), ConfigError> { if !enable_rx && !enable_tx { - panic!("USART: At least one of RX or TX should be enabled"); + return Err(ConfigError::RxOrTxNotEnabled); } #[cfg(not(usart_v4))]