Skip to content

Commit 5029cf9

Browse files
tim-seossburrbull
authored andcommitted
RFC draft - patch to add IrDA SIR mode support to the usart code.
1 parent dfc92fa commit 5029cf9

File tree

3 files changed

+366
-207
lines changed

3 files changed

+366
-207
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- `i2c_scanner` example [#758]
1313
- port LTDC implementation and example from stm32f7xx-hal [#731]
14+
- IrDA mode for USARTs
1415

1516
### Changed
1617

src/serial/config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ pub enum DmaConfig {
4949
TxRx,
5050
}
5151

52+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
53+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
54+
pub enum IrdaMode {
55+
#[doc = "IrDA mode disabled"]
56+
None,
57+
#[doc = "IrDA SIR rx/tx enabled in 'normal' mode"]
58+
Normal,
59+
#[doc = "IrDA SIR 'low-power' mode"]
60+
LowPower,
61+
}
62+
5263
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5364
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5465
pub struct Config {
@@ -57,6 +68,7 @@ pub struct Config {
5768
pub parity: Parity,
5869
pub stopbits: StopBits,
5970
pub dma: DmaConfig,
71+
pub irda: IrdaMode,
6072
}
6173

6274
impl Config {
@@ -99,6 +111,11 @@ impl Config {
99111
self.dma = dma;
100112
self
101113
}
114+
115+
pub fn irda(mut self, irda: IrdaMode) -> Self {
116+
self.irda = irda;
117+
self
118+
}
102119
}
103120

104121
#[derive(Debug)]
@@ -113,6 +130,7 @@ impl Default for Config {
113130
parity: Parity::ParityNone,
114131
stopbits: StopBits::STOP1,
115132
dma: DmaConfig::None,
133+
irda: IrdaMode::None,
116134
}
117135
}
118136
}

0 commit comments

Comments
 (0)