From 89b90ad98592b1dff3f5004e1ec4087f2e29a792 Mon Sep 17 00:00:00 2001 From: Petr Horacek Date: Mon, 18 Sep 2023 18:10:13 +0200 Subject: [PATCH] Fix invalid read test logic in sdmmc example The read check is processing a buffer 10 blocks long. The check then reads data from the SD card 10 times to then report the speed of "Read 10 blocks at X bytes/second". The problem is that it actually reads 10*10 blocks. With this patch, read_blocks is used correctly to populate a continuous buffer. Signed-off-by: Petr Horacek --- CHANGELOG.md | 1 + examples/sdmmc.rs | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce1f7b10..d6db015b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Update `smoltcp` dependency to `0.9.0` * MSRV increased to 1.65.0 * add `IntoAf` trait to restrict `into_alternate` [#346] +* sdmmc: Fix read speed test. ## [v0.14.0] 2023-03-22 diff --git a/examples/sdmmc.rs b/examples/sdmmc.rs index 2bfd68f8..900cc002 100644 --- a/examples/sdmmc.rs +++ b/examples/sdmmc.rs @@ -145,15 +145,13 @@ fn main() -> ! { info!(""); // Read test - let mut buffer = [0u8; 5120]; + let mut buffer = [0u8; 512 * 10]; cp.DWT.enable_cycle_counter(); let start = pac::DWT::cycle_count(); - for i in 0..10 { - // Read 10 blocks - sdmmc.read_blocks(10 * i, &mut buffer).unwrap(); - } + // Read 10 blocks + sdmmc.read_blocks(0, &mut buffer).unwrap(); let end = pac::DWT::cycle_count(); let duration = (end - start) as f32 / ccdr.clocks.c_ck().raw() as f32;