aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorchemicstry <[email protected]>2022-03-16 20:20:39 +0200
committerchemicstry <[email protected]>2022-03-16 20:20:39 +0200
commit8a8e5c4b736adf1d83f6849d7f86c26dabf73675 (patch)
treea8439e348929415c0e767c4669713906aab24cc4 /examples
parent48fc48ea7d0d73c7071e0f353c52eda10ad5a1b4 (diff)
Fix SDMMC v2 and add H7 example
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32f4/src/bin/sdmmc.rs23
-rw-r--r--examples/stm32h7/src/bin/sdmmc.rs42
2 files changed, 51 insertions, 14 deletions
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::*;
13 13
14fn config() -> Config { 14fn config() -> Config {
15 let mut config = Config::default(); 15 let mut config = Config::default();
16 config.rcc.hse = Some(8.mhz().into()); 16 config.rcc.sys_ck = Some(48.mhz().into());
17 config.rcc.hclk = Some(48.mhz().into());
18 config.rcc.pclk2 = Some(48.mhz().into());
19 config.rcc.pll48 = true;
20 config 17 config
21} 18}
22 19
23#[embassy::main(config = "config()")] 20#[embassy::main(config = "config()")]
24async fn main(_spawner: Spawner, p: Peripherals) -> ! { 21async fn main(_spawner: Spawner, p: Peripherals) -> ! {
25 info!("Hello World, dude!"); 22 info!("Hello World!");
26 23
27 let irq = interrupt::take!(SDIO); 24 let irq = interrupt::take!(SDIO);
28 25
29 let mut sdmmc = unsafe { 26 let mut sdmmc = Sdmmc::new(
30 Sdmmc::new( 27 p.SDIO,
31 p.SDIO, 28 (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11),
32 (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), 29 irq,
33 irq, 30 Default::default(),
34 Default::default(), 31 p.DMA2_CH3,
35 p.DMA2_CH3, 32 );
36 )
37 };
38 33
39 info!("Configured clock: {}", sdmmc.clock.0); 34 info!("Configured clock: {}", sdmmc.clock.0);
40 35
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"]
6mod example_common;
7
8use embassy::executor::Spawner;
9use embassy_stm32::sdmmc::Sdmmc;
10use embassy_stm32::time::U32Ext;
11use embassy_stm32::{interrupt, Config, Peripherals};
12use example_common::*;
13
14fn 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()")]
21async 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}