Skip to content

Commit

Permalink
Handle RTS pin
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Jan 23, 2025
1 parent 2974889 commit f222d97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- By default, set `tx_idle_num` to 0 so that bytes written to TX FIFO are always immediately transmitted. (#2859)
- `Rng` and `Trng` now implement `Peripheral<P = Self>` (#2992)
- SPI, UART, I2C: `with_<pin>` functions of peripheral drivers now disconnect the previously assigned pins from the peripheral. (#3012)
- Dropping a driver now disconnects pins from their peripherals. (#3012)
- SPI, UART, I2C: Dropping a driver now disconnects pins from their peripherals. (#3012)

- `Async` drivers are no longer `Send` (#2980)
- GPIO drivers now take configuration structs, and their constructors are fallible (#2990)
Expand Down
7 changes: 6 additions & 1 deletion esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ where
let rx_guard = PeripheralGuard::new(self.uart.parts().0.peripheral);
let tx_guard = PeripheralGuard::new(self.uart.parts().0.peripheral);

let rts_pin = PinGuard::new_unconnected(self.uart.info().rts_signal);
let tx_pin = PinGuard::new_unconnected(self.uart.info().tx_signal);

let mut serial = Uart {
Expand All @@ -428,6 +429,7 @@ where
uart: self.uart,
phantom: PhantomData,
guard: tx_guard,
rts_pin,
tx_pin,
},
};
Expand All @@ -448,6 +450,7 @@ pub struct UartTx<'d, Dm> {
uart: PeripheralRef<'d, AnyUart>,
phantom: PhantomData<Dm>,
guard: PeripheralGuard,
rts_pin: PinGuard,
tx_pin: PinGuard,
}

Expand Down Expand Up @@ -532,7 +535,7 @@ where
pub fn with_rts(self, rts: impl Peripheral<P = impl PeripheralOutput> + 'd) -> Self {
crate::into_mapped_ref!(rts);
rts.set_to_push_pull_output();
self.uart.info().rts_signal.connect_to(rts);
self.rts_pin = OutputConnection::connect_with_guard(rts, self.uart.info().rts_signal);

self
}
Expand Down Expand Up @@ -666,6 +669,7 @@ impl<'d> UartTx<'d, Blocking> {
uart: self.uart,
phantom: PhantomData,
guard: self.guard,
rts_pin: self.rts_pin,
tx_pin: self.tx_pin,
}
}
Expand All @@ -686,6 +690,7 @@ impl<'d> UartTx<'d, Async> {
uart: self.uart,
phantom: PhantomData,
guard: self.guard,
rts_pin: self.rts_pin,
tx_pin: self.tx_pin,
}
}
Expand Down

0 comments on commit f222d97

Please sign in to comment.