Skip to content

Commit

Permalink
Fix invalid read test logic in sdmmc example
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
phoracek committed Sep 18, 2023
1 parent d9af4a6 commit c4efbdb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions examples/sdmmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c4efbdb

Please sign in to comment.