From 706879e0856c8f78593f5d78d56c23c460486054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Thu, 9 Jan 2025 11:01:28 +0100 Subject: [PATCH] Document that UART TX should be set up first --- esp-hal/src/uart.rs | 10 ++++++++++ hil-test/tests/uart.rs | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index 287afd98d..2674e9043 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -830,6 +830,11 @@ where /// Assign the RX pin for UART instance. /// /// Sets the specified pin to input and connects it to the UART RX signal. + /// + /// Note: when you listen for the output of the UART peripheral, you should + /// configure the driver side (i.e. the TX pin), or ensure that the line is + /// initially high, to avoid receiving a non-data byte caused by an + /// initial low signal level. pub fn with_rx(self, rx: impl Peripheral

+ 'd) -> Self { crate::into_mapped_ref!(rx); rx.init_input(Pull::Up, Internal); @@ -1046,6 +1051,11 @@ where /// Assign the RX pin for UART instance. /// /// Sets the specified pin to input and connects it to the UART RX signal. + /// + /// Note: when you listen for the output of the UART peripheral, you should + /// configure the driver side (i.e. the TX pin), or ensure that the line is + /// initially high, to avoid receiving a non-data byte caused by an + /// initial low signal level. pub fn with_rx(self, rx: impl Peripheral

+ 'd) -> Self { crate::into_mapped_ref!(rx); rx.init_input(Pull::Up, Internal); diff --git a/hil-test/tests/uart.rs b/hil-test/tests/uart.rs index c3722c021..b768bb54b 100644 --- a/hil-test/tests/uart.rs +++ b/hil-test/tests/uart.rs @@ -26,9 +26,7 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let (_, pin) = hil_test::common_test_pins!(peripherals); - - let (rx, tx) = pin.split(); + let (rx, tx) = hil_test::common_test_pins!(peripherals); let uart = Uart::new(peripherals.UART1, uart::Config::default()) .unwrap()