diff options
author | Bob McWhirter <bmcwhirt@redhat.com> | 2021-07-13 10:46:31 -0400 |
---|---|---|
committer | Bob McWhirter <bmcwhirt@redhat.com> | 2021-07-13 10:46:31 -0400 |
commit | 604a25ec5de6f8007f9ad61f315ea03d0d292829 (patch) | |
tree | f82400116feea01afb838dbf2d3f502c05f4de9b /embassy-stm32 | |
parent | 8fbea38a5b3eada58943a3d3b346ca4944bfc896 (diff) | |
download | embassy-604a25ec5de6f8007f9ad61f315ea03d0d292829.zip |
Reduce number of traits and impls.
Diffstat (limited to 'embassy-stm32')
-rw-r--r-- | embassy-stm32/src/bdma/mod.rs | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/embassy-stm32/src/bdma/mod.rs b/embassy-stm32/src/bdma/mod.rs index b94563e3..8448185a 100644 --- a/embassy-stm32/src/bdma/mod.rs +++ b/embassy-stm32/src/bdma/mod.rs @@ -394,46 +394,20 @@ pac::interrupts! { #[cfg(usart)] use crate::usart; -#[cfg(not(dmamux))] -pac::peripheral_dma_channels! { - ($peri:ident, usart, $kind:ident, RX, $channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { - impl usart::RxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - impl usart::sealed::RxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - }; - - ($peri:ident, usart, $kind:ident, TX, $channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { - impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - }; - - ($peri:ident, uart, $kind:ident, RX, $channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { - impl usart::RxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - impl usart::sealed::RxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - }; - - ($peri:ident, uart, $kind:ident, TX, $channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { - impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - }; -} - -#[cfg(dmamux)] pac::peripherals! { (usart, $peri:ident) => { - pac::bdma_channels! { - ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { - impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - }; - } + impl<T:Channel + crate::dma_traits::WriteDma<crate::peripherals::$peri>> usart::TxDma<crate::peripherals::$peri> for T {} + impl<T:Channel + crate::dma_traits::WriteDma<crate::peripherals::$peri>> usart::sealed::TxDma<crate::peripherals::$peri> for T {} + + impl<T:Channel + crate::dma_traits::ReadDma<crate::peripherals::$peri>> usart::RxDma<crate::peripherals::$peri> for T {} + impl<T:Channel + crate::dma_traits::ReadDma<crate::peripherals::$peri>> usart::sealed::RxDma<crate::peripherals::$peri> for T {} }; (uart, $peri:ident) => { - pac::bdma_channels! { - ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { - impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } - }; - } + impl<T:Channel + crate::dma_traits::WriteDma<crate::peripherals::$peri>> usart::TxDma<crate::peripherals::$peri> for T {} + impl<T:Channel + crate::dma_traits::WriteDma<crate::peripherals::$peri>> usart::sealed::TxDma<crate::peripherals::$peri> for T {} + + impl<T:Channel + crate::dma_traits::ReadDma<crate::peripherals::$peri>> usart::RxDma<crate::peripherals::$peri> for T {} + impl<T:Channel + crate::dma_traits::ReadDma<crate::peripherals::$peri>> usart::sealed::RxDma<crate::peripherals::$peri> for T {} }; } |