@@ -12,7 +12,7 @@ use crate::rcc::{Enable, GetBusFreq, Rcc, Reset};
12
12
use crate :: stm32:: SPI4 ;
13
13
use crate :: stm32:: { spi1, SPI1 , SPI2 , SPI3 } ;
14
14
use crate :: time:: Hertz ;
15
- use core:: { ptr , ops:: Deref } ;
15
+ use core:: { ops:: Deref , ptr } ;
16
16
17
17
use embedded_hal:: spi:: ErrorKind ;
18
18
pub use embedded_hal:: spi:: { Mode , Phase , Polarity , MODE_0 , MODE_1 , MODE_2 , MODE_3 } ;
@@ -86,11 +86,7 @@ impl FrameSize for u16 {
86
86
}
87
87
88
88
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
94
90
{
95
91
const DMA_MUX_RESOURCE : DmaMuxResources ;
96
92
}
@@ -140,9 +136,7 @@ impl<SPI: Instance, PINS> Spi<SPI, PINS> {
140
136
}
141
137
142
138
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 ( ) ) ;
146
140
Spi {
147
141
spi : self . spi ,
148
142
pins : self . pins ,
@@ -316,9 +310,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u8> for Spi<SPI,
316
310
// flush data from previous operations, otherwise we'd get unwanted data
317
311
self . flush_inner ( ) ?;
318
312
// 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 ( ) ) ;
322
314
self . set_bidi ( ) ;
323
315
324
316
let half_len = len / 2 ;
@@ -382,9 +374,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u8> for Spi<SPI,
382
374
u16:: from_le_bytes ( unsafe { * two. as_ptr ( ) . cast ( ) } ) ) ;
383
375
384
376
// 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 ( ) ) ;
388
378
389
379
// same prefill as in read, this time with actual data
390
380
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,
440
430
441
431
self . flush_inner ( ) ?;
442
432
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 ( ) ) ;
446
434
let half_len = len / 2 ;
447
435
let pair_left = len % 2 ;
448
436
@@ -495,9 +483,7 @@ impl<SPI: Instance, PINS: Pins<SPI>> embedded_hal::spi::SpiBus<u16> for Spi<SPI,
495
483
// flush data from previous operations, otherwise we'd get unwanted data
496
484
self . flush_inner ( ) ?;
497
485
// 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 ( ) ) ;
501
487
self . set_bidi ( ) ;
502
488
// prefill write fifo so that the clock doen't stop while fetch the read byte
503
489
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,
530
516
531
517
self . flush_inner ( ) ?;
532
518
// 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 ( ) ) ;
536
520
self . set_bidi ( ) ;
537
521
let common_len = core:: cmp:: min ( read. len ( ) , write. len ( ) ) ;
538
522
// 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,
567
551
568
552
self . flush_inner ( ) ?;
569
553
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 ( ) ) ;
573
555
let prefill = core:: cmp:: min ( self . tx_fifo_cap ( ) as usize / 2 , len) ;
574
556
575
557
for w in & words[ ..prefill] {
0 commit comments