@@ -22,7 +22,7 @@ impl<'a> embedded_hal::blocking::spi::Transfer<u8> for FakeSpi<'a> {
2222 type Error = core:: convert:: Infallible ;
2323 fn transfer < ' w > ( & mut self , words : & ' w mut [ u8 ] ) -> Result < & ' w [ u8 ] , Self :: Error > {
2424 let result = if IS_CS_LOW . load ( Ordering :: SeqCst ) {
25- defmt:: debug!( "SD out: {:02x}" , words) ;
25+ defmt:: debug!( "SD > {:02x}" , words) ;
2626 self . 0 . with_bus_cs (
2727 1 ,
2828 if self . 1 {
@@ -34,7 +34,7 @@ impl<'a> embedded_hal::blocking::spi::Transfer<u8> for FakeSpi<'a> {
3434 spi. transfer ( words) . unwrap ( ) ;
3535 } ,
3636 ) ;
37- defmt:: debug!( "SD: {:02x}" , words) ;
37+ defmt:: debug!( "SD < {:02x}" , words) ;
3838 words
3939 } else {
4040 // Select a slot we don't use so the SD card won't be activated
@@ -47,6 +47,32 @@ impl<'a> embedded_hal::blocking::spi::Transfer<u8> for FakeSpi<'a> {
4747 }
4848}
4949
50+ impl < ' a > embedded_hal:: blocking:: spi:: Write < u8 > for FakeSpi < ' a > {
51+ type Error = core:: convert:: Infallible ;
52+ fn write ( & mut self , words : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
53+ if IS_CS_LOW . load ( Ordering :: SeqCst ) {
54+ defmt:: debug!( "SD > {:02x}" , words) ;
55+ self . 0 . with_bus_cs (
56+ 1 ,
57+ if self . 1 {
58+ CLOCK_SD_CARD_INIT
59+ } else {
60+ CLOCK_SD_CARD
61+ } ,
62+ |spi, _buffer| {
63+ spi. write ( words) . unwrap ( ) ;
64+ } ,
65+ ) ;
66+ } else {
67+ // Select a slot we don't use so the SD card won't be activated
68+ self . 0 . with_bus_cs ( 7 , CLOCK_SD_CARD_INIT , |spi, _buffer| {
69+ spi. write ( words) . unwrap ( ) ;
70+ } ) ;
71+ }
72+ Ok ( ( ) )
73+ }
74+ }
75+
5076impl embedded_hal:: digital:: v2:: OutputPin for FakeCs {
5177 type Error = core:: convert:: Infallible ;
5278 fn set_low ( & mut self ) -> Result < ( ) , Self :: Error > {
0 commit comments