You can drive sdhc card in your stm32f407 board, other stm32f4xx boards I have no test
first you need to init some GPIO, like this: ```rust pub fn gpioinit( rcc: &mut stm32::RCC, gpioc: &mut stm32::GPIOC, gpiod: &mut stm32::GPIOD, ) { // gpioc gpiod enable rcc.ahb1enr.modify(|r, w| w.gpiocen().setbit().gpioden().setbit());
gpioc.afrh.modify(|_r, w|
w.afrh8().af12()
.afrh9().af12()
.afrh10().af12()
.afrh11().af12()
.afrh12().af12());
gpiod.afrl.modify(|_r, w| w.afrl2().af12());
gpioc.moder.modify(|_r, w|
w.moder8().alternate()
.moder9().alternate()
.moder10().alternate()
.moder11().alternate()
.moder12().alternate());
gpiod.moder.modify(|_r, w| w.moder2().alternate());
gpioc.ospeedr.modify(|_r, w|
w.ospeedr8().high_speed()
.ospeedr9().high_speed()
.ospeedr10().high_speed()
.ospeedr11().high_speed()
.ospeedr12().high_speed());
gpiod.ospeedr.modify(|_r, w| w.ospeedr2().high_speed());
gpioc.otyper.modify(|_r, w|
w.ot8().push_pull()
.ot9().push_pull()
.ot10().push_pull()
.ot11().push_pull()
.ot12().push_pull());
gpiod.otyper.modify(|_r, w| w.ot2().push_pull());
gpioc.pupdr.modify(|_r, w|
w.pupdr8().pull_up()
.pupdr9().pull_up()
.pupdr10().pull_up()
.pupdr11().pull_up()
.pupdr12().pull_up());
gpiod.pupdr.modify(|_r, w| w.pupdr2().pull_up());
} ```
then you can drive your sdhc card, and do some tests ```rust let card = Card::init().unwrap(); writeln!(USART1, "{:#?}", card).unwrap(); card.erase(0, card.capacity).unwrap();
let buf = [1; 512 * 2]; card.writemultiblocks(&buf, 0, 2).unwrap();
let mut buf = [0; 512 * 2]; card.readmultiblocks(&mut buf, 0, 2).unwrap(); writeln!(USART1, "{:?}", &buf[0..buf.len()]).unwrap();
let buf = [2; 512]; card.write_block(&buf, 512).unwrap();
let mut buf = [0; 512]; card.read_block(&mut buf, 512).unwrap(); writeln!(USART1, "{:?}", &buf[0..buf.len()]).unwrap(); ```
will print in your ttl like this:
Card {
capacity: 3963617280,
block_size: 512,
rca: 1,
}
[1, 1, 1, .......]
[2, 2, 2, .......]