diff options
| author | Grant Miller <[email protected]> | 2021-12-07 00:48:44 -0600 |
|---|---|---|
| committer | Grant Miller <[email protected]> | 2021-12-14 15:39:00 -0600 |
| commit | e75cb1a56498a2f0b48e63426e9c10c6520aead0 (patch) | |
| tree | dfd88bc762120ca8b2532b38e8f955ea32e3f796 | |
| parent | b06658c1958014f2b4dea7ec522c858457312373 (diff) | |
Regs type alias
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 8 |
1 files 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; | |||
| 22 | mod _version; | 22 | mod _version; |
| 23 | pub use _version::*; | 23 | pub use _version::*; |
| 24 | 24 | ||
| 25 | type Regs = &'static crate::pac::spi::Spi; | ||
| 26 | |||
| 25 | #[derive(Debug)] | 27 | #[derive(Debug)] |
| 26 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 28 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 27 | pub enum Error { | 29 | pub enum Error { |
| @@ -395,7 +397,7 @@ fn check_error_flags(sr: regs::Sr) -> Result<(), Error> { | |||
| 395 | Ok(()) | 397 | Ok(()) |
| 396 | } | 398 | } |
| 397 | 399 | ||
| 398 | fn spin_until_tx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> { | 400 | fn spin_until_tx_ready(regs: Regs) -> Result<(), Error> { |
| 399 | loop { | 401 | loop { |
| 400 | let sr = unsafe { regs.sr().read() }; | 402 | let sr = unsafe { regs.sr().read() }; |
| 401 | 403 | ||
| @@ -412,7 +414,7 @@ fn spin_until_tx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> | |||
| 412 | } | 414 | } |
| 413 | } | 415 | } |
| 414 | 416 | ||
| 415 | fn spin_until_rx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> { | 417 | fn spin_until_rx_ready(regs: Regs) -> Result<(), Error> { |
| 416 | loop { | 418 | loop { |
| 417 | let sr = unsafe { regs.sr().read() }; | 419 | let sr = unsafe { regs.sr().read() }; |
| 418 | 420 | ||
| @@ -440,7 +442,7 @@ impl Word for u16 { | |||
| 440 | const WORDSIZE: WordSize = WordSize::SixteenBit; | 442 | const WORDSIZE: WordSize = WordSize::SixteenBit; |
| 441 | } | 443 | } |
| 442 | 444 | ||
| 443 | fn transfer_word<W: Word>(regs: &'static crate::pac::spi::Spi, tx_word: W) -> Result<W, Error> { | 445 | fn transfer_word<W: Word>(regs: Regs, tx_word: W) -> Result<W, Error> { |
| 444 | spin_until_tx_ready(regs)?; | 446 | spin_until_tx_ready(regs)?; |
| 445 | 447 | ||
| 446 | unsafe { | 448 | unsafe { |
