diff options
| author | chemicstry <[email protected]> | 2022-03-16 20:20:39 +0200 |
|---|---|---|
| committer | chemicstry <[email protected]> | 2022-03-16 20:20:39 +0200 |
| commit | 8a8e5c4b736adf1d83f6849d7f86c26dabf73675 (patch) | |
| tree | a8439e348929415c0e767c4669713906aab24cc4 /examples/stm32h7/src/bin/sdmmc.rs | |
| parent | 48fc48ea7d0d73c7071e0f353c52eda10ad5a1b4 (diff) | |
Fix SDMMC v2 and add H7 example
Diffstat (limited to 'examples/stm32h7/src/bin/sdmmc.rs')
| -rw-r--r-- | examples/stm32h7/src/bin/sdmmc.rs | 42 |
1 files changed, 42 insertions, 0 deletions
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 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | #[path = "../example_common.rs"] | ||
| 6 | mod example_common; | ||
| 7 | |||
| 8 | use embassy::executor::Spawner; | ||
| 9 | use embassy_stm32::sdmmc::Sdmmc; | ||
| 10 | use embassy_stm32::time::U32Ext; | ||
| 11 | use embassy_stm32::{interrupt, Config, Peripherals}; | ||
| 12 | use example_common::*; | ||
| 13 | |||
| 14 | fn config() -> Config { | ||
| 15 | let mut config = Config::default(); | ||
| 16 | config.rcc.sys_ck = Some(200.mhz().into()); | ||
| 17 | config | ||
| 18 | } | ||
| 19 | |||
| 20 | #[embassy::main(config = "config()")] | ||
| 21 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | ||
| 22 | info!("Hello World!"); | ||
| 23 | |||
| 24 | let irq = interrupt::take!(SDMMC1); | ||
| 25 | |||
| 26 | let mut sdmmc = Sdmmc::new( | ||
| 27 | p.SDMMC1, | ||
| 28 | (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), | ||
| 29 | irq, | ||
| 30 | Default::default(), | ||
| 31 | ); | ||
| 32 | |||
| 33 | info!("Configured clock: {}", sdmmc.clock.0); | ||
| 34 | |||
| 35 | unwrap!(sdmmc.init_card(25.mhz()).await); | ||
| 36 | |||
| 37 | let card = unwrap!(sdmmc.card()); | ||
| 38 | |||
| 39 | info!("Card: {:#?}", Debug2Format(card)); | ||
| 40 | |||
| 41 | loop {} | ||
| 42 | } | ||
