8
8
use super :: sdmmc_proto:: * ;
9
9
use super :: { Block , BlockCount , BlockDevice , BlockIdx } ;
10
10
use core:: cell:: RefCell ;
11
- use nb:: block;
12
11
13
12
const DEFAULT_DELAY_COUNT : u32 = 32_000 ;
14
13
@@ -17,9 +16,9 @@ const DEFAULT_DELAY_COUNT: u32 = 32_000;
17
16
/// bytes without Chip Select asserted (which puts the card into SPI mode).
18
17
pub struct SdMmcSpi < SPI , CS >
19
18
where
20
- SPI : embedded_hal:: spi:: FullDuplex < u8 > ,
19
+ SPI : embedded_hal:: blocking :: spi:: Transfer < u8 > ,
21
20
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 ,
23
22
{
24
23
spi : RefCell < SPI > ,
25
24
cs : RefCell < CS > ,
@@ -106,9 +105,9 @@ impl Delay {
106
105
107
106
impl < SPI , CS > SdMmcSpi < SPI , CS >
108
107
where
109
- SPI : embedded_hal:: spi:: FullDuplex < u8 > ,
108
+ SPI : embedded_hal:: blocking :: spi:: Transfer < u8 > ,
110
109
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 ,
112
111
{
113
112
/// Create a new SD/MMC controller using a raw SPI interface.
114
113
pub fn new ( spi : SPI , cs : CS ) -> SdMmcSpi < SPI , CS > {
@@ -417,8 +416,9 @@ where
417
416
/// Send one byte and receive one byte.
418
417
fn transfer ( & self , out : u8 ) -> Result < u8 , Error > {
419
418
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 )
422
422
}
423
423
424
424
/// Spin until the card returns 0xFF, or we spin too many times and
@@ -438,8 +438,8 @@ where
438
438
439
439
impl < SPI , CS > BlockDevice for SdMmcSpi < SPI , CS >
440
440
where
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 ,
443
443
CS : embedded_hal:: digital:: v2:: OutputPin ,
444
444
{
445
445
type Error = Error ;
0 commit comments