Skip to content

Commit c05ca30

Browse files
committed
listen CTS
1 parent 7ea9716 commit c05ca30

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12-
- Serial flow control enable
12+
- Serial flow control enable [#775]
1313
- `i2c_scanner` example [#758]
1414
- Enable `sdio` for stm32f446
1515
- port LTDC implementation and example from stm32f7xx-hal [#731]
@@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3636
[#758]: https://github.com/stm32-rs/stm32f4xx-hal/pull/758
3737
[#773]: https://github.com/stm32-rs/stm32f4xx-hal/pull/773
3838

39+
[#775]: https://github.com/stm32-rs/stm32f4xx-hal/pull/775
40+
3941
## [v0.21.0] - 2024-05-30
4042

4143
### Changed

src/serial.rs

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ pub enum CFlag {
111111
TransmissionComplete = 1 << 6,
112112
/// LIN break detection flag
113113
LinBreak = 1 << 8,
114+
/// Clear to send flag
115+
Cts = 1 << 9,
114116
}
115117

116118
pub mod config;

src/serial/uart_impls.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,22 @@ macro_rules! uartCommon {
268268
pub trait RBFlowControlImpl {
269269
fn enable_rts(&self, state: bool);
270270
fn enable_cts(&self, state: bool);
271+
fn listen_cts(&self, state: bool);
271272
}
272273

273274
impl RBFlowControlImpl for RegisterBlockUsart {
275+
#[inline(always)]
274276
fn enable_rts(&self, state: bool) {
275277
self.cr3().modify(|_, w| w.rtse().bit(state));
276278
}
279+
#[inline(always)]
277280
fn enable_cts(&self, state: bool) {
278281
self.cr3().modify(|_, w| w.ctse().bit(state));
279282
}
283+
#[inline(always)]
284+
fn listen_cts(&self, state: bool) {
285+
self.cr3().modify(|_, w| w.ctsie().bit(state))
286+
}
280287
}
281288

282289
impl RegisterBlockImpl for RegisterBlockUsart {
@@ -545,7 +552,7 @@ where {
545552

546553
impl<UART: Instance + SerialFlowControl, WORD> Serial<UART, WORD>
547554
where
548-
UART::RegisterBlock: RBFlowControlImpl,
555+
UART::RB: RBFlowControlImpl,
549556
{
550557
pub fn with_rts(self, rts: impl Into<UART::Rts>) -> Self {
551558
self.rx.usart.enable_rts(true);
@@ -569,6 +576,12 @@ where
569576
pub fn disable_clear_to_send(&mut self) {
570577
self.tx.usart.enable_cts(false);
571578
}
579+
pub fn listen_clear_to_send(&mut self) {
580+
self.tx.usart.listen_cts(true)
581+
}
582+
pub fn unlisten_clear_to_send(&mut self) {
583+
self.tx.usart.listen_cts(false)
584+
}
572585
}
573586

574587
impl<UART: Instance, WORD> RxISR for Serial<UART, WORD>

0 commit comments

Comments
 (0)