aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Miller <[email protected]>2021-12-07 00:48:44 -0600
committerGrant Miller <[email protected]>2021-12-14 15:39:00 -0600
commite75cb1a56498a2f0b48e63426e9c10c6520aead0 (patch)
treedfd88bc762120ca8b2532b38e8f955ea32e3f796
parentb06658c1958014f2b4dea7ec522c858457312373 (diff)
Regs type alias
-rw-r--r--embassy-stm32/src/spi/mod.rs8
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;
22mod _version; 22mod _version;
23pub use _version::*; 23pub use _version::*;
24 24
25type 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))]
27pub enum Error { 29pub enum Error {
@@ -395,7 +397,7 @@ fn check_error_flags(sr: regs::Sr) -> Result<(), Error> {
395 Ok(()) 397 Ok(())
396} 398}
397 399
398fn spin_until_tx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> { 400fn 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
415fn spin_until_rx_ready(regs: &'static crate::pac::spi::Spi) -> Result<(), Error> { 417fn 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
443fn transfer_word<W: Word>(regs: &'static crate::pac::spi::Spi, tx_word: W) -> Result<W, Error> { 445fn 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 {