mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
Merge pull request #3415 from bkueng/stm32_uart_rx_pull
stm32: add RX Pull configuration option to USART
This commit is contained in:
commit
45d4b1dd3e
@ -210,7 +210,7 @@ impl<'d> BufferedUart<'d> {
|
|||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
Self::new_inner(
|
Self::new_inner(
|
||||||
peri,
|
peri,
|
||||||
new_pin!(rx, AfType::input(Pull::None)),
|
new_pin!(rx, AfType::input(config.rx_pull)),
|
||||||
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
|
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -260,7 +260,7 @@ impl<'d> BufferedUart<'d> {
|
|||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
Self::new_inner(
|
Self::new_inner(
|
||||||
peri,
|
peri,
|
||||||
new_pin!(rx, AfType::input(Pull::None)),
|
new_pin!(rx, AfType::input(config.rx_pull)),
|
||||||
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
|
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -167,6 +167,9 @@ pub struct Config {
|
|||||||
#[cfg(any(usart_v3, usart_v4))]
|
#[cfg(any(usart_v3, usart_v4))]
|
||||||
pub invert_rx: bool,
|
pub invert_rx: bool,
|
||||||
|
|
||||||
|
/// Set the pull configuration for the RX pin.
|
||||||
|
pub rx_pull: Pull,
|
||||||
|
|
||||||
// private: set by new_half_duplex, not by the user.
|
// private: set by new_half_duplex, not by the user.
|
||||||
half_duplex: bool,
|
half_duplex: bool,
|
||||||
}
|
}
|
||||||
@ -175,7 +178,7 @@ impl Config {
|
|||||||
fn tx_af(&self) -> AfType {
|
fn tx_af(&self) -> AfType {
|
||||||
#[cfg(any(usart_v3, usart_v4))]
|
#[cfg(any(usart_v3, usart_v4))]
|
||||||
if self.swap_rx_tx {
|
if self.swap_rx_tx {
|
||||||
return AfType::input(Pull::None);
|
return AfType::input(self.rx_pull);
|
||||||
};
|
};
|
||||||
AfType::output(OutputType::PushPull, Speed::Medium)
|
AfType::output(OutputType::PushPull, Speed::Medium)
|
||||||
}
|
}
|
||||||
@ -185,7 +188,7 @@ impl Config {
|
|||||||
if self.swap_rx_tx {
|
if self.swap_rx_tx {
|
||||||
return AfType::output(OutputType::PushPull, Speed::Medium);
|
return AfType::output(OutputType::PushPull, Speed::Medium);
|
||||||
};
|
};
|
||||||
AfType::input(Pull::None)
|
AfType::input(self.rx_pull)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +209,7 @@ impl Default for Config {
|
|||||||
invert_tx: false,
|
invert_tx: false,
|
||||||
#[cfg(any(usart_v3, usart_v4))]
|
#[cfg(any(usart_v3, usart_v4))]
|
||||||
invert_rx: false,
|
invert_rx: false,
|
||||||
|
rx_pull: Pull::None,
|
||||||
half_duplex: false,
|
half_duplex: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,7 +452,7 @@ impl<'d> UartTx<'d, Blocking> {
|
|||||||
Self::new_inner(
|
Self::new_inner(
|
||||||
peri,
|
peri,
|
||||||
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
|
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
|
||||||
new_pin!(cts, AfType::input(Pull::None)),
|
new_pin!(cts, AfType::input(config.rx_pull)),
|
||||||
None,
|
None,
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
@ -567,7 +571,7 @@ impl<'d> UartRx<'d, Async> {
|
|||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
Self::new_inner(
|
Self::new_inner(
|
||||||
peri,
|
peri,
|
||||||
new_pin!(rx, AfType::input(Pull::None)),
|
new_pin!(rx, AfType::input(config.rx_pull)),
|
||||||
None,
|
None,
|
||||||
new_dma!(rx_dma),
|
new_dma!(rx_dma),
|
||||||
config,
|
config,
|
||||||
@ -585,7 +589,7 @@ impl<'d> UartRx<'d, Async> {
|
|||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
Self::new_inner(
|
Self::new_inner(
|
||||||
peri,
|
peri,
|
||||||
new_pin!(rx, AfType::input(Pull::None)),
|
new_pin!(rx, AfType::input(config.rx_pull)),
|
||||||
new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)),
|
new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)),
|
||||||
new_dma!(rx_dma),
|
new_dma!(rx_dma),
|
||||||
config,
|
config,
|
||||||
@ -815,7 +819,7 @@ impl<'d> UartRx<'d, Blocking> {
|
|||||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
Self::new_inner(peri, new_pin!(rx, AfType::input(Pull::None)), None, None, config)
|
Self::new_inner(peri, new_pin!(rx, AfType::input(config.rx_pull)), None, None, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new rx-only UART with a request-to-send pin
|
/// Create a new rx-only UART with a request-to-send pin
|
||||||
@ -827,7 +831,7 @@ impl<'d> UartRx<'d, Blocking> {
|
|||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
Self::new_inner(
|
Self::new_inner(
|
||||||
peri,
|
peri,
|
||||||
new_pin!(rx, AfType::input(Pull::None)),
|
new_pin!(rx, AfType::input(config.rx_pull)),
|
||||||
new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)),
|
new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)),
|
||||||
None,
|
None,
|
||||||
config,
|
config,
|
||||||
|
Loading…
Reference in New Issue
Block a user