88use super :: sdmmc_proto:: * ;
99use super :: { Block , BlockCount , BlockDevice , BlockIdx } ;
1010use core:: cell:: RefCell ;
11- use nb:: block;
1211
1312const DEFAULT_DELAY_COUNT : u32 = 32_000 ;
1413
@@ -17,9 +16,9 @@ const DEFAULT_DELAY_COUNT: u32 = 32_000;
1716/// bytes without Chip Select asserted (which puts the card into SPI mode).
1817pub struct SdMmcSpi < SPI , CS >
1918where
20- SPI : embedded_hal:: spi:: FullDuplex < u8 > ,
19+ SPI : embedded_hal:: blocking :: spi:: Transfer < u8 > ,
2120 CS : embedded_hal:: digital:: v2:: OutputPin ,
22- <SPI as embedded_hal:: spi:: FullDuplex < u8 > >:: Error : core:: fmt:: Debug ,
21+ <SPI as embedded_hal:: blocking :: spi:: Transfer < u8 > >:: Error : core:: fmt:: Debug ,
2322{
2423 spi : RefCell < SPI > ,
2524 cs : RefCell < CS > ,
@@ -106,9 +105,9 @@ impl Delay {
106105
107106impl < SPI , CS > SdMmcSpi < SPI , CS >
108107where
109- SPI : embedded_hal:: spi:: FullDuplex < u8 > ,
108+ SPI : embedded_hal:: blocking :: spi:: Transfer < u8 > ,
110109 CS : embedded_hal:: digital:: v2:: OutputPin ,
111- <SPI as embedded_hal:: spi:: FullDuplex < u8 > >:: Error : core:: fmt:: Debug ,
110+ <SPI as embedded_hal:: blocking :: spi:: Transfer < u8 > >:: Error : core:: fmt:: Debug ,
112111{
113112 /// Create a new SD/MMC controller using a raw SPI interface.
114113 pub fn new ( spi : SPI , cs : CS ) -> SdMmcSpi < SPI , CS > {
@@ -417,8 +416,9 @@ where
417416 /// Send one byte and receive one byte.
418417 fn transfer ( & self , out : u8 ) -> Result < u8 , Error > {
419418 let mut spi = self . spi . borrow_mut ( ) ;
420- block ! ( spi. send( out) ) . map_err ( |_e| Error :: Transport ) ?;
421- block ! ( spi. read( ) ) . map_err ( |_e| Error :: Transport )
419+ spi. transfer ( & mut [ out] )
420+ . map ( |b| b[ 0 ] )
421+ . map_err ( |_e| Error :: Transport )
422422 }
423423
424424 /// Spin until the card returns 0xFF, or we spin too many times and
@@ -438,8 +438,8 @@ where
438438
439439impl < SPI , CS > BlockDevice for SdMmcSpi < SPI , CS >
440440where
441- SPI : embedded_hal:: spi:: FullDuplex < u8 > ,
442- <SPI as embedded_hal:: spi:: FullDuplex < u8 > >:: Error : core:: fmt:: Debug ,
441+ SPI : embedded_hal:: blocking :: spi:: Transfer < u8 > ,
442+ <SPI as embedded_hal:: blocking :: spi:: Transfer < u8 > >:: Error : core:: fmt:: Debug ,
443443 CS : embedded_hal:: digital:: v2:: OutputPin ,
444444{
445445 type Error = Error ;
0 commit comments