From 8a8e5c4b736adf1d83f6849d7f86c26dabf73675 Mon Sep 17 00:00:00 2001 From: chemicstry Date: Wed, 16 Mar 2022 20:20:39 +0200 Subject: Fix SDMMC v2 and add H7 example --- examples/stm32f4/src/bin/sdmmc.rs | 23 +++++++++------------ examples/stm32h7/src/bin/sdmmc.rs | 42 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 examples/stm32h7/src/bin/sdmmc.rs (limited to 'examples') diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 46ac44500..301d7dda0 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -13,28 +13,23 @@ use example_common::*; fn config() -> Config { let mut config = Config::default(); - config.rcc.hse = Some(8.mhz().into()); - config.rcc.hclk = Some(48.mhz().into()); - config.rcc.pclk2 = Some(48.mhz().into()); - config.rcc.pll48 = true; + config.rcc.sys_ck = Some(48.mhz().into()); config } #[embassy::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) -> ! { - info!("Hello World, dude!"); + info!("Hello World!"); let irq = interrupt::take!(SDIO); - let mut sdmmc = unsafe { - Sdmmc::new( - p.SDIO, - (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), - irq, - Default::default(), - p.DMA2_CH3, - ) - }; + let mut sdmmc = Sdmmc::new( + p.SDIO, + (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), + irq, + Default::default(), + p.DMA2_CH3, + ); info!("Configured clock: {}", sdmmc.clock.0); diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs new file mode 100644 index 000000000..255c5568f --- /dev/null +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -0,0 +1,42 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +#[path = "../example_common.rs"] +mod example_common; + +use embassy::executor::Spawner; +use embassy_stm32::sdmmc::Sdmmc; +use embassy_stm32::time::U32Ext; +use embassy_stm32::{interrupt, Config, Peripherals}; +use example_common::*; + +fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(200.mhz().into()); + config +} + +#[embassy::main(config = "config()")] +async fn main(_spawner: Spawner, p: Peripherals) -> ! { + info!("Hello World!"); + + let irq = interrupt::take!(SDMMC1); + + let mut sdmmc = Sdmmc::new( + p.SDMMC1, + (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), + irq, + Default::default(), + ); + + info!("Configured clock: {}", sdmmc.clock.0); + + unwrap!(sdmmc.init_card(25.mhz()).await); + + let card = unwrap!(sdmmc.card()); + + info!("Card: {:#?}", Debug2Format(card)); + + loop {} +} -- cgit