Document that UART TX should be set up first

This commit is contained in:
Dániel Buga 2025-01-09 11:01:28 +01:00
parent 9f553b1b0e
commit 706879e085
No known key found for this signature in database
2 changed files with 11 additions and 3 deletions

View File

@ -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<P = impl PeripheralInput> + '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<P = impl PeripheralInput> + 'd) -> Self {
crate::into_mapped_ref!(rx);
rx.init_input(Pull::Up, Internal);

View File

@ -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()