Replace generic inner with arguments
This commit is contained in:
parent
407540c8fe
commit
d799af9dd8
@ -165,12 +165,12 @@ impl<'d, M: Mode> UartTx<'d, M> {
|
|||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Uart::<M>::init(T::info(), Some(tx.into()), None, None, None, config);
|
Uart::<M>::init(T::info(), Some(tx.into()), None, None, None, config);
|
||||||
Self::new_inner::<T>(Some(tx_dma.into()))
|
Self::new_inner(T::info(), Some(tx_dma.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_inner<T: Instance>(tx_dma: Option<Peri<'d, AnyChannel>>) -> Self {
|
fn new_inner(info: &'static Info, tx_dma: Option<Peri<'d, AnyChannel>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
info: T::info(),
|
info,
|
||||||
tx_dma,
|
tx_dma,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ impl<'d> UartTx<'d, Blocking> {
|
|||||||
/// Create a new UART TX instance for blocking mode operations.
|
/// Create a new UART TX instance for blocking mode operations.
|
||||||
pub fn new_blocking<T: Instance>(_uart: Peri<'d, T>, tx: Peri<'d, impl TxPin<T>>, config: Config) -> Self {
|
pub fn new_blocking<T: Instance>(_uart: Peri<'d, T>, tx: Peri<'d, impl TxPin<T>>, config: Config) -> Self {
|
||||||
Uart::<Blocking>::init(T::info(), Some(tx.into()), None, None, None, config);
|
Uart::<Blocking>::init(T::info(), Some(tx.into()), None, None, None, config);
|
||||||
Self::new_inner::<T>(None)
|
Self::new_inner(T::info(), None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert this uart TX instance into a buffered uart using the provided
|
/// Convert this uart TX instance into a buffered uart using the provided
|
||||||
@ -281,20 +281,25 @@ impl<'d, M: Mode> UartRx<'d, M> {
|
|||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Uart::<M>::init(T::info(), None, Some(rx.into()), None, None, config);
|
Uart::<M>::init(T::info(), None, Some(rx.into()), None, None, config);
|
||||||
Self::new_inner::<T>(true, Some(rx_dma.into()))
|
Self::new_inner(T::info(), T::dma_state(), true, Some(rx_dma.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_inner<T: Instance>(has_irq: bool, rx_dma: Option<Peri<'d, AnyChannel>>) -> Self {
|
fn new_inner(
|
||||||
|
info: &'static Info,
|
||||||
|
dma_state: &'static DmaState,
|
||||||
|
has_irq: bool,
|
||||||
|
rx_dma: Option<Peri<'d, AnyChannel>>,
|
||||||
|
) -> Self {
|
||||||
debug_assert_eq!(has_irq, rx_dma.is_some());
|
debug_assert_eq!(has_irq, rx_dma.is_some());
|
||||||
if has_irq {
|
if has_irq {
|
||||||
// disable all error interrupts initially
|
// disable all error interrupts initially
|
||||||
T::info().regs.uartimsc().write(|w| w.0 = 0);
|
info.regs.uartimsc().write(|w| w.0 = 0);
|
||||||
T::Interrupt::unpend();
|
info.interrupt.unpend();
|
||||||
unsafe { T::Interrupt::enable() };
|
unsafe { info.interrupt.enable() };
|
||||||
}
|
}
|
||||||
Self {
|
Self {
|
||||||
info: T::info(),
|
info,
|
||||||
dma_state: T::dma_state(),
|
dma_state,
|
||||||
rx_dma,
|
rx_dma,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
@ -355,7 +360,7 @@ impl<'d> UartRx<'d, Blocking> {
|
|||||||
/// Create a new UART RX instance for blocking mode operations.
|
/// Create a new UART RX instance for blocking mode operations.
|
||||||
pub fn new_blocking<T: Instance>(_uart: Peri<'d, T>, rx: Peri<'d, impl RxPin<T>>, config: Config) -> Self {
|
pub fn new_blocking<T: Instance>(_uart: Peri<'d, T>, rx: Peri<'d, impl RxPin<T>>, config: Config) -> Self {
|
||||||
Uart::<Blocking>::init(T::info(), None, Some(rx.into()), None, None, config);
|
Uart::<Blocking>::init(T::info(), None, Some(rx.into()), None, None, config);
|
||||||
Self::new_inner::<T>(false, None)
|
Self::new_inner(T::info(), T::dma_state(), false, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert this uart RX instance into a buffered uart using the provided
|
/// Convert this uart RX instance into a buffered uart using the provided
|
||||||
@ -835,8 +840,8 @@ impl<'d, M: Mode> Uart<'d, M> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
tx: UartTx::new_inner::<T>(tx_dma),
|
tx: UartTx::new_inner(T::info(), tx_dma),
|
||||||
rx: UartRx::new_inner::<T>(has_irq, rx_dma),
|
rx: UartRx::new_inner(T::info(), T::dma_state(), has_irq, rx_dma),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user