@@ -103,6 +103,19 @@ impl Delay {
103
103
}
104
104
}
105
105
106
+ /// Options for acquiring the card.
107
+ #[ derive( Debug ) ]
108
+ pub struct AcquireOpts {
109
+ /// Some cards don't support CRC mode. At least a 512MiB Transcend one.
110
+ pub require_crc : bool ,
111
+ }
112
+
113
+ impl Default for AcquireOpts {
114
+ fn default ( ) -> Self {
115
+ AcquireOpts { require_crc : true }
116
+ }
117
+ }
118
+
106
119
impl < SPI , CS > SdMmcSpi < SPI , CS >
107
120
where
108
121
SPI : embedded_hal:: blocking:: spi:: Transfer < u8 > ,
@@ -139,6 +152,16 @@ where
139
152
/// This routine must be performed with an SPI clock speed of around 100 - 400 kHz.
140
153
/// Afterwards you may increase the SPI clock speed.
141
154
pub fn init ( & mut self ) -> Result < ( ) , Error > {
155
+ self . init_with_opts ( Default :: default ( ) )
156
+ }
157
+
158
+ /// De-init the card so it can't be used
159
+ pub fn deinit ( & mut self ) {
160
+ self . state = State :: NoInit ;
161
+ }
162
+
163
+ /// Initializes the card into a known state
164
+ pub fn init_with_opts ( & mut self , options : AcquireOpts ) -> Result < ( ) , Error > {
142
165
let f = |s : & mut Self | {
143
166
// Assume it hasn't worked
144
167
s. state = State :: Error ;
@@ -172,7 +195,7 @@ where
172
195
return Err ( Error :: CardNotFound ) ;
173
196
}
174
197
// Enable CRC
175
- if s. card_command ( CMD59 , 1 ) ? != R1_IDLE_STATE {
198
+ if s. card_command ( CMD59 , 1 ) ? != R1_IDLE_STATE && options . require_crc {
176
199
return Err ( Error :: CantEnableCRC ) ;
177
200
}
178
201
// Check card version
@@ -224,11 +247,6 @@ where
224
247
result
225
248
}
226
249
227
- /// De-init the card so it can't be used
228
- pub fn deinit ( & mut self ) {
229
- self . state = State :: NoInit ;
230
- }
231
-
232
250
/// Return the usable size of this SD card in bytes.
233
251
pub fn card_size_bytes ( & self ) -> Result < u64 , Error > {
234
252
self . check_state ( ) ?;
0 commit comments