@@ -22,7 +22,7 @@ const DEFAULT_DELAY_COUNT: u32 = 32_000;
22
22
/// Built from an SPI peripheral and a Chip
23
23
/// Select pin. We need Chip Select to be separate so we can clock out some
24
24
/// bytes without Chip Select asserted (which puts the card into SPI mode).
25
- pub struct SdMmcSpi < SPI , CS >
25
+ pub struct SdCard < SPI , CS >
26
26
where
27
27
SPI : embedded_hal:: blocking:: spi:: Transfer < u8 > ,
28
28
CS : embedded_hal:: digital:: v2:: OutputPin ,
@@ -35,15 +35,16 @@ where
35
35
}
36
36
37
37
/// An initialized block device used to access the SD card.
38
- /// **Caution**: any data must be flushed manually before dropping `BlockSpi`, see `deinit`.
38
+ ///
39
+ /// **Caution**: any data must be flushed manually before dropping `AcquiredSdCard`, see `deinit`.
39
40
/// Uses SPI mode.
40
- pub struct BlockSpi < ' a , SPI , CS > ( & ' a mut SdMmcSpi < SPI , CS > )
41
+ pub struct AcquiredSdCard < ' a , SPI , CS > ( & ' a mut SdCard < SPI , CS > )
41
42
where
42
43
SPI : embedded_hal:: blocking:: spi:: Transfer < u8 > ,
43
44
CS : embedded_hal:: digital:: v2:: OutputPin ,
44
45
<SPI as embedded_hal:: blocking:: spi:: Transfer < u8 > >:: Error : core:: fmt:: Debug ;
45
46
46
- /// The possible errors `SdMmcSpi` can generate.
47
+ /// The possible errors this crate can generate.
47
48
#[ cfg_attr( feature = "defmt-log" , derive( defmt:: Format ) ) ]
48
49
#[ derive( Debug , Copy , Clone ) ]
49
50
pub enum Error {
@@ -77,7 +78,7 @@ pub enum Error {
77
78
GpioError ,
78
79
}
79
80
80
- /// The possible states `SdMmcSpi ` can be in.
81
+ /// The possible states `SdCard ` can be in.
81
82
#[ cfg_attr( feature = "defmt-log" , derive( defmt:: Format ) ) ]
82
83
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
83
84
pub enum State {
@@ -92,6 +93,7 @@ pub enum State {
92
93
/// The different types of card we support.
93
94
#[ cfg_attr( feature = "defmt-log" , derive( defmt:: Format ) ) ]
94
95
#[ derive( Debug , Copy , Clone , PartialEq ) ]
96
+ #[ allow( clippy:: upper_case_acronyms) ]
95
97
enum CardType {
96
98
SD1 ,
97
99
SD2 ,
@@ -137,15 +139,15 @@ impl Default for AcquireOpts {
137
139
}
138
140
}
139
141
140
- impl < SPI , CS > SdMmcSpi < SPI , CS >
142
+ impl < SPI , CS > SdCard < SPI , CS >
141
143
where
142
144
SPI : embedded_hal:: blocking:: spi:: Transfer < u8 > ,
143
145
CS : embedded_hal:: digital:: v2:: OutputPin ,
144
146
<SPI as embedded_hal:: blocking:: spi:: Transfer < u8 > >:: Error : core:: fmt:: Debug ,
145
147
{
146
148
/// Create a new SD/MMC interface using a raw SPI interface.
147
- pub fn new ( spi : SPI , cs : CS ) -> SdMmcSpi < SPI , CS > {
148
- SdMmcSpi {
149
+ pub fn new ( spi : SPI , cs : CS ) -> SdCard < SPI , CS > {
150
+ SdCard {
149
151
spi : RefCell :: new ( spi) ,
150
152
cs : RefCell :: new ( cs) ,
151
153
card_type : CardType :: SD1 ,
@@ -165,12 +167,15 @@ where
165
167
}
166
168
167
169
/// Initializes the card into a known state
168
- pub fn acquire ( & mut self ) -> Result < BlockSpi < SPI , CS > , Error > {
170
+ pub fn acquire ( & mut self ) -> Result < AcquiredSdCard < SPI , CS > , Error > {
169
171
self . acquire_with_opts ( Default :: default ( ) )
170
172
}
171
173
172
174
/// Initializes the card into a known state
173
- pub fn acquire_with_opts ( & mut self , options : AcquireOpts ) -> Result < BlockSpi < SPI , CS > , Error > {
175
+ pub fn acquire_with_opts (
176
+ & mut self ,
177
+ options : AcquireOpts ,
178
+ ) -> Result < AcquiredSdCard < SPI , CS > , Error > {
174
179
debug ! ( "acquiring card with opts: {:?}" , options) ;
175
180
let f = |s : & mut Self | {
176
181
// Assume it hasn't worked
@@ -269,7 +274,7 @@ where
269
274
let result = f ( self ) ;
270
275
self . cs_high ( ) ?;
271
276
let _ = self . receive ( ) ;
272
- result. map ( move |( ) | BlockSpi ( self ) )
277
+ result. map ( move |( ) | AcquiredSdCard ( self ) )
273
278
}
274
279
275
280
/// Perform a function that might error with the chipselect low.
@@ -377,7 +382,7 @@ where
377
382
}
378
383
}
379
384
380
- impl < SPI , CS > BlockSpi < ' _ , SPI , CS >
385
+ impl < SPI , CS > AcquiredSdCard < ' _ , SPI , CS >
381
386
where
382
387
SPI : embedded_hal:: blocking:: spi:: Transfer < u8 > ,
383
388
CS : embedded_hal:: digital:: v2:: OutputPin ,
@@ -517,7 +522,7 @@ impl<U: BlockDevice, T: Deref<Target = U>> BlockDevice for T {
517
522
}
518
523
}
519
524
520
- impl < SPI , CS > BlockDevice for BlockSpi < ' _ , SPI , CS >
525
+ impl < SPI , CS > BlockDevice for AcquiredSdCard < ' _ , SPI , CS >
521
526
where
522
527
SPI : embedded_hal:: blocking:: spi:: Transfer < u8 > ,
523
528
<SPI as embedded_hal:: blocking:: spi:: Transfer < u8 > >:: Error : core:: fmt:: Debug ,
@@ -595,7 +600,7 @@ where
595
600
}
596
601
}
597
602
598
- impl < SPI , CS > Drop for BlockSpi < ' _ , SPI , CS >
603
+ impl < SPI , CS > Drop for AcquiredSdCard < ' _ , SPI , CS >
599
604
where
600
605
SPI : embedded_hal:: blocking:: spi:: Transfer < u8 > ,
601
606
<SPI as embedded_hal:: blocking:: spi:: Transfer < u8 > >:: Error : core:: fmt:: Debug ,
0 commit comments