embassy_stm32_plus/builder/uart/uart5/
rx.rs

1use embassy_stm32::mode::Async;
2use embassy_stm32::peripherals::{PD2, UART5};
3use embassy_stm32::usart::{Config, ConfigError, UartRx};
4use crate::builder::uart::base::UartBase;
5
6/// uart5 rx builder
7pub struct Uart5RxBuilder {
8    /// uart5 base device
9    pub base: UartBase<UART5>,
10    /// rx pin
11    pub rx: PD2,
12}
13
14/// custom method
15impl Uart5RxBuilder {
16    /// create builder
17    #[deprecated(note = "no any dma support RxDma<UART5>")]
18    #[inline]
19    pub fn new(uart: UART5, rx: PD2) -> Uart5RxBuilder {
20        Self { base: UartBase::new(uart), rx }
21    }
22
23    /// set uart config
24    #[inline]
25    pub fn config(mut self, config: Config) -> Self {
26        self.base.set_config(config);
27        self
28    }
29
30    /// build uart rx that supports read data
31    #[deprecated(note = "no any dma support RxDma<UART5>")]
32    #[inline]
33    pub fn build(self) -> Result<UartRx<'static, Async>, ConfigError> {
34        Err(ConfigError::RxOrTxNotEnabled)
35    }
36}