From e75cb1a56498a2f0b48e63426e9c10c6520aead0 Mon Sep 17 00:00:00 2001 From: Grant Miller Date: Tue, 7 Dec 2021 00:48:44 -0600 Subject: [PATCH] Regs type alias --- embassy-stm32/src/spi/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 8befaf529..f47347265 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs @@ -22,6 +22,8 @@ use embassy_traits::spi as traits; mod _version; pub use _version::*; +type Regs = &'static crate::pac::spi::Spi; + #[derive(Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Error { @@ -395,7 +397,7 @@ fn check_error_flags(sr: regs::Sr) -> Result<(), Error> { Ok(()) } -fn spin_until_tx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> { +fn spin_until_tx_ready(regs: Regs) -> Result<(), Error> { loop { let sr = unsafe { regs.sr().read() }; @@ -412,7 +414,7 @@ fn spin_until_tx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> } } -fn spin_until_rx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> { +fn spin_until_rx_ready(regs: Regs) -> Result<(), Error> { loop { let sr = unsafe { regs.sr().read() }; @@ -440,7 +442,7 @@ impl Word for u16 { const WORDSIZE: WordSize = WordSize::SixteenBit; } -fn transfer_word(regs: &'static crate::pac::spi::Spi, tx_word: W) -> Result { +fn transfer_word(regs: Regs, tx_word: W) -> Result { spin_until_tx_ready(regs)?; unsafe {