Skip to content

Commit 8a2bf64

Browse files
authored
Merge pull request #137 from rust-embedded-community/release/v0.8.0
Release/v0.8.0
2 parents 2f8303a + a1cc455 commit 8a2bf64

22 files changed

+584
-454
lines changed

CHANGELOG.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,39 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
66

77
## [Unreleased]
88

9-
* None
9+
### Changed
10+
11+
- None
12+
13+
### Added
14+
15+
- None
16+
17+
### Removed
18+
19+
- None
20+
21+
## [Version 0.8.0] - 2024-07-12
22+
23+
### Changed
24+
25+
- Fixed a bug when seeking backwards through files.
26+
- Updated to `heapless-0.8` and `embedded-hal-bus-0.2`.
27+
- No longer panics if the close fails when a `Volume` is dropped - the failure is instead ignored.
28+
29+
### Added
30+
31+
- `File` now has a `flush()` method.
32+
- `File` now has a `close()` method.
33+
34+
### Removed
35+
36+
- __Breaking Change__: Removed `CS` type-param on `SdCard` - now we use the `SpiDevice` chip-select (closing [#126])
37+
- __Breaking Change__: Removed the 74 clock cycle 'init' sequence - now applications must do this
1038

1139
## [Version 0.7.0] - 2024-02-04
1240

13-
## Changed
41+
### Changed
1442

1543
- __Breaking Change__: `Volume`, `Directory` and `File` are now smart! They hold references to the thing they were made from, and will clean themselves up when dropped. The trade-off is you can can't open multiple volumes, directories or files at the same time.
1644
- __Breaking Change__: Renamed the old types to `RawVolume`, `RawDirectory` and `RawFile`
@@ -19,18 +47,19 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
1947
- You can now open directories multiple times without error
2048
- Updated to [embedded-hal] 1.0
2149

22-
## Added
50+
### Added
2351

2452
- `RawVolume`, `RawDirectory` and `RawFile` types (like the old `Volume`, `Directory` and `File` types)
2553
- New method `make_dir_in_dir`
2654
- Empty strings and `"."` convert to `ShortFileName::this_dir()`
2755
- New API `change_dir` which changes a directory to point to some child directory (or the parent) without opening a new directory.
2856
- Updated 'shell' example to support `mkdir`, `tree` and relative/absolute paths
2957

30-
## Removed
58+
### Removed
3159

32-
* None
60+
- None
3361

62+
[#126]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/126
3463
[#74]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/74
3564
[embedded-hal]: https://crates.io/crates/embedded-hal
3665

@@ -126,7 +155,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
126155

127156
- Reduce delay waiting for response. Big speed improvements.
128157

129-
## [Version 0.1.0] - 2018-12-23
158+
## [Version 0.1.1] - 2018-12-23
130159

131160
### Changed
132161

@@ -137,7 +166,8 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
137166

138167
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/
139168
[Semantic Versioning]: http://semver.org/spec/v2.0.0.html
140-
[Unreleased]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.7.0...develop
169+
[Unreleased]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.8.0...develop
170+
[Version 0.8.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.8.0...v0.7.0
141171
[Version 0.7.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.7.0...v0.6.0
142172
[Version 0.6.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.6.0...v0.5.0
143173
[Version 0.5.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.5.0...v0.4.0

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ license = "MIT OR Apache-2.0"
88
name = "embedded-sdmmc"
99
readme = "README.md"
1010
repository = "https://github.com/rust-embedded-community/embedded-sdmmc-rs"
11-
version = "0.7.0"
11+
version = "0.8.0"
1212

1313
[dependencies]
1414
byteorder = {version = "1", default-features = false}
1515
defmt = {version = "0.3", optional = true}
1616
embedded-hal = "1.0.0"
17-
heapless = "0.7"
17+
heapless = "^0.8"
1818
log = {version = "0.4", default-features = false, optional = true}
1919

2020
[dev-dependencies]
2121
chrono = "0.4"
22-
embedded-hal-bus = "0.1.0"
22+
embedded-hal-bus = "0.2.0"
2323
env_logger = "0.10.0"
2424
flate2 = "1.0"
2525
hex-literal = "0.4.1"

LICENSE-MIT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Copyright (c) 2018-2023 Jonathan 'theJPster' Pallant and the Rust Embedded Community developers
1+
Copyright (c) 2018-2024 Jonathan 'theJPster' Pallant and the Rust Embedded Community developers
2+
Copyright (c) 2011-2018 Bill Greiman
23

34
Permission is hereby granted, free of charge, to any
45
person obtaining a copy of this software and associated

NOTICE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright Notices
2+
3+
This is a copyright notices file, as described by the Apache-2.0 license.
4+
5+
Copyright (c) 2018-2024 Jonathan 'theJPster' Pallant and the Rust Embedded Community developers
6+
Copyright (c) 2011-2018 Bill Greiman

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You will need something that implements the `BlockDevice` trait, which can read
1212

1313
```rust
1414
// Build an SD Card interface out of an SPI device, a chip-select pin and the delay object
15-
let sdcard = embedded_sdmmc::SdCard::new(sdmmc_spi, sdmmc_cs, delay);
15+
let sdcard = embedded_sdmmc::SdCard::new(sdmmc_spi, delay);
1616
// Get the card size (this also triggers card initialisation because it's not been done yet)
1717
println!("Card size is {} bytes", sdcard.num_bytes()?);
1818
// Now let's look for volumes (also known as partitions) on our block device.
@@ -27,7 +27,7 @@ let mut root_dir = volume0.open_root_dir()?;
2727
// Open a file called "MY_FILE.TXT" in the root directory
2828
// This mutably borrows the directory.
2929
let mut my_file = root_dir.open_file_in_dir("MY_FILE.TXT", embedded_sdmmc::Mode::ReadOnly)?;
30-
// Print the contents of the file
30+
// Print the contents of the file, assuming it's in ISO-8859-1 encoding
3131
while !my_file.is_eof() {
3232
let mut buffer = [0u8; 32];
3333
let num_read = my_file.read(&mut buffer)?;
@@ -59,10 +59,12 @@ let mut cont: VolumeManager<_, _, 6, 12, 4> = VolumeManager::new_with_limits(blo
5959
* Log over defmt or the common log interface (feature flags).
6060

6161
## No-std usage
62+
6263
This repository houses no examples for no-std usage, however you can check out the following examples:
63-
- [Pi Pico](https://github.com/rp-rs/rp-hal-boards/blob/main/boards/rp-pico/examples/pico_spi_sd_card.rs)
64-
- [STM32H7XX](https://github.com/stm32-rs/stm32h7xx-hal/blob/master/examples/sdmmc_fat.rs)
65-
- [atsamd(pygamer)](https://github.com/atsamd-rs/atsamd/blob/master/boards/pygamer/examples/sd_card.rs)
64+
65+
* [Pi Pico](https://github.com/rp-rs/rp-hal-boards/blob/main/boards/rp-pico/examples/pico_spi_sd_card.rs)
66+
* [STM32H7XX](https://github.com/stm32-rs/stm32h7xx-hal/blob/master/examples/sdmmc_fat.rs)
67+
* [atsamd(pygamer)](https://github.com/atsamd-rs/atsamd/blob/master/boards/pygamer/examples/sd_card.rs)
6668

6769
## Todo List (PRs welcome!)
6870

@@ -79,12 +81,14 @@ The changelog has moved to [CHANGELOG.md](/CHANGELOG.md)
7981
Licensed under either of
8082

8183
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
82-
http://www.apache.org/licenses/LICENSE-2.0)
84+
<http://www.apache.org/licenses/LICENSE-2.0>)
8385

84-
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
86+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
8587

8688
at your option.
8789

90+
Copyright notices are stored in the [NOTICE](./NOTICE) file.
91+
8892
## Contribution
8993

9094
Unless you explicitly state otherwise, any contribution intentionally

examples/readme_test.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,27 @@
33
//! We add enough stuff to make it compile, but it won't run because our fake
44
//! SPI doesn't do any replies.
55
6+
#![allow(dead_code)]
7+
68
use core::cell::RefCell;
79

8-
use embedded_sdmmc::sdcard::DummyCsPin;
10+
pub struct DummyCsPin;
11+
12+
impl embedded_hal::digital::ErrorType for DummyCsPin {
13+
type Error = core::convert::Infallible;
14+
}
15+
16+
impl embedded_hal::digital::OutputPin for DummyCsPin {
17+
#[inline(always)]
18+
fn set_low(&mut self) -> Result<(), Self::Error> {
19+
Ok(())
20+
}
21+
22+
#[inline(always)]
23+
fn set_high(&mut self) -> Result<(), Self::Error> {
24+
Ok(())
25+
}
26+
}
927

1028
struct FakeSpiBus();
1129

@@ -97,13 +115,12 @@ fn main() -> Result<(), Error> {
97115
// BEGIN Fake stuff that will be replaced with real peripherals
98116
let spi_bus = RefCell::new(FakeSpiBus());
99117
let delay = FakeDelayer();
100-
let sdmmc_spi = embedded_hal_bus::spi::RefCellDevice::new(&spi_bus, DummyCsPin, delay);
101-
let sdmmc_cs = FakeCs();
118+
let sdmmc_spi = embedded_hal_bus::spi::RefCellDevice::new(&spi_bus, DummyCsPin, delay).unwrap();
102119
let time_source = FakeTimesource();
103120
// END Fake stuff that will be replaced with real peripherals
104121

105122
// Build an SD Card interface out of an SPI device, a chip-select pin and the delay object
106-
let sdcard = embedded_sdmmc::SdCard::new(sdmmc_spi, sdmmc_cs, delay);
123+
let sdcard = embedded_sdmmc::SdCard::new(sdmmc_spi, delay);
107124
// Get the card size (this also triggers card initialisation because it's not been done yet)
108125
println!("Card size is {} bytes", sdcard.num_bytes()?);
109126
// Now let's look for volumes (also known as partitions) on our block device.
@@ -118,7 +135,7 @@ fn main() -> Result<(), Error> {
118135
// Open a file called "MY_FILE.TXT" in the root directory
119136
// This mutably borrows the directory.
120137
let mut my_file = root_dir.open_file_in_dir("MY_FILE.TXT", embedded_sdmmc::Mode::ReadOnly)?;
121-
// Print the contents of the file
138+
// Print the contents of the file, assuming it's in ISO-8859-1 encoding
122139
while !my_file.is_eof() {
123140
let mut buffer = [0u8; 32];
124141
let num_read = my_file.read(&mut buffer)?;

src/blockdevice.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
//! Block Device support
1+
//! Traits and types for working with Block Devices.
22
//!
33
//! Generic code for handling block devices, such as types for identifying
44
//! a particular block on a block device by its index.
55
6-
/// Represents a standard 512 byte block (also known as a sector). IBM PC
7-
/// formatted 5.25" and 3.5" floppy disks, SD/MMC cards up to 1 GiB in size
8-
/// and IDE/SATA Hard Drives up to about 2 TiB all have 512 byte blocks.
6+
/// A standard 512 byte block (also known as a sector).
7+
///
8+
/// IBM PC formatted 5.25" and 3.5" floppy disks, IDE/SATA Hard Drives up to
9+
/// about 2 TiB, and almost all SD/MMC cards have 512 byte blocks.
910
///
1011
/// This library does not support devices with a block size other than 512
1112
/// bytes.
@@ -15,15 +16,17 @@ pub struct Block {
1516
pub contents: [u8; Block::LEN],
1617
}
1718

18-
/// Represents the linear numeric address of a block (or sector). The first
19-
/// block on a disk gets `BlockIdx(0)` (which usually contains the Master Boot
20-
/// Record).
19+
/// The linear numeric address of a block (or sector).
20+
///
21+
/// The first block on a disk gets `BlockIdx(0)` (which usually contains the
22+
/// Master Boot Record).
2123
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
2224
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
2325
pub struct BlockIdx(pub u32);
2426

25-
/// Represents the a number of blocks (or sectors). Add this to a `BlockIdx`
26-
/// to get an actual address on disk.
27+
/// The a number of blocks (or sectors).
28+
///
29+
/// Add this to a `BlockIdx` to get an actual address on disk.
2730
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
2831
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
2932
pub struct BlockCount(pub u32);
@@ -34,7 +37,7 @@ pub struct BlockIter {
3437
current: BlockIdx,
3538
}
3639

37-
/// Represents a block device - a device which can read and write blocks (or
40+
/// A block device - a device which can read and write blocks (or
3841
/// sectors). Only supports devices which are <= 2 TiB in size.
3942
pub trait BlockDevice {
4043
/// The errors that the `BlockDevice` can return. Must be debug formattable.

src/fat/bpb.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use crate::{
66
};
77
use byteorder::{ByteOrder, LittleEndian};
88

9-
/// Represents a Boot Parameter Block. This is the first sector of a FAT
10-
/// formatted partition, and it describes various properties of the FAT
11-
/// filesystem.
9+
/// A Boot Parameter Block.
10+
///
11+
/// This is the first sector of a FAT formatted partition, and it describes
12+
/// various properties of the FAT filesystem.
1213
pub struct Bpb<'a> {
1314
data: &'a [u8; 512],
1415
pub(crate) fat_type: FatType,

src/fat/ondiskdirentry.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
use crate::{fat::FatType, Attributes, BlockIdx, ClusterId, DirEntry, ShortFileName, Timestamp};
44
use byteorder::{ByteOrder, LittleEndian};
55

6-
/// Represents a 32-byte directory entry as stored on-disk in a directory file.
6+
/// A 32-byte directory entry as stored on-disk in a directory file.
7+
///
8+
/// This is the same for FAT16 and FAT32 (except FAT16 doesn't use
9+
/// first_cluster_hi).
710
pub struct OnDiskDirEntry<'a> {
811
data: &'a [u8],
912
}
@@ -38,8 +41,6 @@ impl<'a> core::fmt::Debug for OnDiskDirEntry<'a> {
3841
}
3942
}
4043

41-
/// Represents the 32 byte directory entry. This is the same for FAT16 and
42-
/// FAT32 (except FAT16 doesn't use first_cluster_hi).
4344
impl<'a> OnDiskDirEntry<'a> {
4445
pub(crate) const LEN: usize = 32;
4546
pub(crate) const LEN_U32: u32 = 32;

0 commit comments

Comments
 (0)