File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,12 @@ use cortex_m_rt::entry;
5
5
use cortex_m_semihosting:: { hprint, hprintln} ;
6
6
use panic_semihosting as _;
7
7
8
- use stm32f4xx_hal:: { delay, prelude:: * , sdio:: Sdio , stm32} ;
8
+ use stm32f4xx_hal:: {
9
+ delay,
10
+ prelude:: * ,
11
+ sdio:: { ClockFreq , Sdio } ,
12
+ stm32,
13
+ } ;
9
14
10
15
#[ entry]
11
16
fn main ( ) -> ! {
@@ -42,7 +47,7 @@ fn main() -> ! {
42
47
43
48
// Wait for card to be ready
44
49
loop {
45
- match sdio. init_card ( ) {
50
+ match sdio. init_card ( ClockFreq :: F24Mhz ) {
46
51
Ok ( _) => break ,
47
52
Err ( _err) => ( ) ,
48
53
}
Original file line number Diff line number Diff line change @@ -115,8 +115,9 @@ enum PowerCtrl {
115
115
On = 0b11 ,
116
116
}
117
117
118
+ /// Clock frequency of a SDIO bus.
118
119
#[ allow( dead_code) ]
119
- enum ClockFreq {
120
+ pub enum ClockFreq {
120
121
F24Mhz = 0 ,
121
122
F16Mhz = 1 ,
122
123
F12Mhz = 2 ,
@@ -285,8 +286,8 @@ impl Sdio {
285
286
}
286
287
}
287
288
288
- /// initialize card
289
- pub fn init_card ( & mut self ) -> Result < ( ) , Error > {
289
+ /// Initializes card (if present) and sets the bus at the specified frequency.
290
+ pub fn init_card ( & mut self , freq : ClockFreq ) -> Result < ( ) , Error > {
290
291
// Enable power to card
291
292
self . sdio
292
293
. power
@@ -361,7 +362,7 @@ impl Sdio {
361
362
362
363
self . get_scr ( & mut card) ?;
363
364
364
- self . set_bus ( self . bw , ClockFreq :: F24Mhz , & card) ?;
365
+ self . set_bus ( self . bw , freq , & card) ?;
365
366
366
367
self . card . replace ( card) ;
367
368
self . read_card_status ( ) ?;
You can’t perform that action at this time.
0 commit comments