embassy_stm32_plus/builder/uart/uart5/
mod.rs

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