Skip to content

Commit cf358f5

Browse files
techmccatusbalbin
authored andcommitted
run cargo fmt
1 parent 740872e commit cf358f5

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

src/spi.rs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::rcc::{Enable, GetBusFreq, Rcc, Reset};
1212
use crate::stm32::SPI4;
1313
use crate::stm32::{spi1, SPI1, SPI2, SPI3};
1414
use crate::time::Hertz;
15-
use core::{ptr, ops::Deref};
15+
use core::{ops::Deref, ptr};
1616

1717
use embedded_hal::spi::ErrorKind;
1818
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
@@ -86,11 +86,7 @@ impl FrameSize for u16 {
8686
}
8787

8888
pub trait Instance:
89-
crate::Sealed
90-
+ Deref<Target = spi1::RegisterBlock>
91-
+ Enable
92-
+ Reset
93-
+ GetBusFreq
89+
crate::Sealed + Deref<Target = spi1::RegisterBlock> + Enable + Reset + GetBusFreq
9490
{
9591
const DMA_MUX_RESOURCE: DmaMuxResources;
9692
}
@@ -140,9 +136,7 @@ impl<SPI: Instance, PINS> Spi<SPI, PINS> {
140136
}
141137

142138
pub fn enable_tx_dma(self) -> Spi<SPI, PINS> {
143-
self.spi
144-
.cr2()
145-
.modify(|_, w| w.txdmaen().set_bit());
139+
self.spi.cr2().modify(|_, w| w.txdmaen().set_bit());
146140
Spi {
147141
spi: self.spi,
148142
pins: self.pins,
@@ -316,9 +310,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u8> for Spi<SPI,
316310
// flush data from previous operations, otherwise we'd get unwanted data
317311
self.flush_inner()?;
318312
// FIFO threshold to 16 bits
319-
self.spi
320-
.cr2()
321-
.modify(|_, w| w.frxth().clear_bit());
313+
self.spi.cr2().modify(|_, w| w.frxth().clear_bit());
322314
self.set_bidi();
323315

324316
let half_len = len / 2;
@@ -382,9 +374,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u8> for Spi<SPI,
382374
u16::from_le_bytes(unsafe { *two.as_ptr().cast() }));
383375

384376
// FIFO threshold to 16 bits
385-
self.spi
386-
.cr2()
387-
.modify(|_, w| w.frxth().clear_bit());
377+
self.spi.cr2().modify(|_, w| w.frxth().clear_bit());
388378

389379
// same prefill as in read, this time with actual data
390380
let prefill = core::cmp::min(self.tx_fifo_cap() as usize / 2, half_len);
@@ -440,9 +430,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u8> for Spi<SPI,
440430

441431
self.flush_inner()?;
442432
self.set_bidi();
443-
self.spi
444-
.cr2()
445-
.modify(|_, w| w.frxth().clear_bit());
433+
self.spi.cr2().modify(|_, w| w.frxth().clear_bit());
446434
let half_len = len / 2;
447435
let pair_left = len % 2;
448436

@@ -495,9 +483,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u16> for Spi<SPI,
495483
// flush data from previous operations, otherwise we'd get unwanted data
496484
self.flush_inner()?;
497485
// FIFO threshold to 16 bits
498-
self.spi
499-
.cr2()
500-
.modify(|_, w| w.frxth().clear_bit());
486+
self.spi.cr2().modify(|_, w| w.frxth().clear_bit());
501487
self.set_bidi();
502488
// prefill write fifo so that the clock doen't stop while fetch the read byte
503489
let prefill = core::cmp::min(self.tx_fifo_cap() as usize / 2, len);
@@ -530,9 +516,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u16> for Spi<SPI,
530516

531517
self.flush_inner()?;
532518
// FIFO threshold to 16 bits
533-
self.spi
534-
.cr2()
535-
.modify(|_, w| w.frxth().clear_bit());
519+
self.spi.cr2().modify(|_, w| w.frxth().clear_bit());
536520
self.set_bidi();
537521
let common_len = core::cmp::min(read.len(), write.len());
538522
// same prefill as in read, this time with actual data
@@ -567,9 +551,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u16> for Spi<SPI,
567551

568552
self.flush_inner()?;
569553
self.set_bidi();
570-
self.spi
571-
.cr2()
572-
.modify(|_, w| w.frxth().clear_bit());
554+
self.spi.cr2().modify(|_, w| w.frxth().clear_bit());
573555
let prefill = core::cmp::min(self.tx_fifo_cap() as usize / 2, len);
574556

575557
for w in &words[..prefill] {

0 commit comments

Comments
 (0)