@@ -278,6 +278,7 @@ where
278278 let num_blocks = match csd {
279279 Csd :: V1 ( ref contents) => contents. card_capacity_blocks ( ) ,
280280 Csd :: V2 ( ref contents) => contents. card_capacity_blocks ( ) ,
281+ Csd :: V3 ( ref contents) => contents. card_capacity_blocks ( ) ,
281282 } ;
282283 Ok ( BlockCount ( num_blocks) )
283284 }
@@ -289,6 +290,7 @@ where
289290 match csd {
290291 Csd :: V1 ( ref contents) => Ok ( contents. card_capacity_bytes ( ) ) ,
291292 Csd :: V2 ( ref contents) => Ok ( contents. card_capacity_bytes ( ) ) ,
293+ Csd :: V3 ( ref contents) => Ok ( contents. card_capacity_bytes ( ) ) ,
292294 }
293295 }
294296
@@ -298,27 +300,27 @@ where
298300 match csd {
299301 Csd :: V1 ( ref contents) => Ok ( contents. erase_single_block_enabled ( ) ) ,
300302 Csd :: V2 ( ref contents) => Ok ( contents. erase_single_block_enabled ( ) ) ,
303+ Csd :: V3 ( ref contents) => Ok ( contents. erase_single_block_enabled ( ) ) ,
301304 }
302305 }
303306
304307 /// Read the 'card specific data' block.
305308 fn read_csd ( & mut self ) -> Result < Csd , Error > {
309+ let mut csd_raw: [ u8 ; 16 ] = [ 0 ; 16 ] ;
306310 match self . card_type {
307311 Some ( CardType :: SD1 ) => {
308- let mut csd = CsdV1 :: new ( ) ;
309312 if self . card_command ( CMD9 , 0 ) ? != 0 {
310313 return Err ( Error :: RegisterReadError ) ;
311314 }
312- self . read_data ( & mut csd . data ) ?;
313- Ok ( Csd :: V1 ( csd ) )
315+ self . read_data ( & mut csd_raw ) ?;
316+ Ok ( Csd :: V1 ( CsdV1 :: from_be_bytes ( & csd_raw ) ) )
314317 }
315318 Some ( CardType :: SD2 | CardType :: SDHC ) => {
316- let mut csd = CsdV2 :: new ( ) ;
317319 if self . card_command ( CMD9 , 0 ) ? != 0 {
318320 return Err ( Error :: RegisterReadError ) ;
319321 }
320- self . read_data ( & mut csd . data ) ?;
321- Ok ( Csd :: V2 ( csd ) )
322+ self . read_data ( & mut csd_raw ) ?;
323+ Ok ( Csd :: V2 ( CsdV2 :: from_be_bytes ( & csd_raw ) ) )
322324 }
323325 None => Err ( Error :: CardNotFound ) ,
324326 }
0 commit comments