Skip to content

Commit 224eaaf

Browse files
committed
stm32/sdmmc: switch to AFIT.
1 parent f681b9d commit 224eaaf

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

embassy-stm32/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ cortex-m = "0.7.6"
5555
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
5656
rand_core = "0.6.3"
5757
sdio-host = "0.5.0"
58-
embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "46d1b1c2ff13e31e282ec1e352421721694f126a", optional = true }
58+
embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
5959
critical-section = "1.1"
6060
atomic-polyfill = "1.0.1"
6161
stm32-metapac = "6"

embassy-stm32/src/sdmmc/mod.rs

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,58 +1651,44 @@ foreach_peripheral!(
16511651

16521652
#[cfg(feature = "embedded-sdmmc")]
16531653
mod sdmmc_rs {
1654-
use core::future::Future;
1655-
16561654
use embedded_sdmmc::{Block, BlockCount, BlockDevice, BlockIdx};
16571655

16581656
use super::*;
16591657

16601658
impl<'d, T: Instance, Dma: SdmmcDma<T>> BlockDevice for Sdmmc<'d, T, Dma> {
16611659
type Error = Error;
16621660

1663-
type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
1664-
where
1665-
Self: 'a;
1666-
1667-
type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
1668-
where
1669-
Self: 'a;
1670-
1671-
fn read<'a>(
1672-
&'a mut self,
1673-
blocks: &'a mut [Block],
1661+
async fn read(
1662+
&mut self,
1663+
blocks: &mut [Block],
16741664
start_block_idx: BlockIdx,
16751665
_reason: &str,
1676-
) -> Self::ReadFuture<'a> {
1677-
async move {
1678-
let mut address = start_block_idx.0;
1666+
) -> Result<(), Self::Error> {
1667+
let mut address = start_block_idx.0;
16791668

1680-
for block in blocks.iter_mut() {
1681-
let block: &mut [u8; 512] = &mut block.contents;
1669+
for block in blocks.iter_mut() {
1670+
let block: &mut [u8; 512] = &mut block.contents;
16821671

1683-
// NOTE(unsafe) Block uses align(4)
1684-
let block = unsafe { &mut *(block as *mut _ as *mut DataBlock) };
1685-
self.read_block(address, block).await?;
1686-
address += 1;
1687-
}
1688-
Ok(())
1672+
// NOTE(unsafe) Block uses align(4)
1673+
let block = unsafe { &mut *(block as *mut _ as *mut DataBlock) };
1674+
self.read_block(address, block).await?;
1675+
address += 1;
16891676
}
1677+
Ok(())
16901678
}
16911679

1692-
fn write<'a>(&'a mut self, blocks: &'a [Block], start_block_idx: BlockIdx) -> Self::WriteFuture<'a> {
1693-
async move {
1694-
let mut address = start_block_idx.0;
1680+
async fn write(&mut self, blocks: &[Block], start_block_idx: BlockIdx) -> Result<(), Self::Error> {
1681+
let mut address = start_block_idx.0;
16951682

1696-
for block in blocks.iter() {
1697-
let block: &[u8; 512] = &block.contents;
1683+
for block in blocks.iter() {
1684+
let block: &[u8; 512] = &block.contents;
16981685

1699-
// NOTE(unsafe) DataBlock uses align 4
1700-
let block = unsafe { &*(block as *const _ as *const DataBlock) };
1701-
self.write_block(address, block).await?;
1702-
address += 1;
1703-
}
1704-
Ok(())
1686+
// NOTE(unsafe) DataBlock uses align 4
1687+
let block = unsafe { &*(block as *const _ as *const DataBlock) };
1688+
self.write_block(address, block).await?;
1689+
address += 1;
17051690
}
1691+
Ok(())
17061692
}
17071693

17081694
fn num_blocks(&self) -> Result<BlockCount, Self::Error> {

examples/stm32f4/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
88
embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] }
99
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
1010
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] }
11-
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
11+
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc"] }
1212
embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
1313
embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] }
1414

0 commit comments

Comments
 (0)