Skip to content

Commit 60f637e

Browse files
committed
Merge branch 'develop' into skip-wait-init-sequence
2 parents a821037 + 01da43c commit 60f637e

File tree

8 files changed

+34
-12
lines changed

8 files changed

+34
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
[Unreleased]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.4.0...develop
1111

12-
### Changes
13-
- Add `MAX_DIRS` and `MAX_FILES` generics to `Controller` to allow an arbitrary numbers of concurrent open directories and files.
14-
1512
## [Version 0.4.0](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.4.0)
1613

1714
### Changes
@@ -25,6 +22,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2522
- Fix `env_logger` pulling in the `std` feature in `log` in library builds.
2623
- Raise the minimum supported Rust version to 1.56.0.
2724
- Code tidy-ups and more documentation.
25+
- Add `MAX_DIRS` and `MAX_FILES` generics to `Controller` to allow an arbitrary numbers of concurrent open directories and files.
26+
- Add new constructor method `Controller::new_with_limits(block_device: D, timesource: T) -> Controller<D, T, MAX_DIRS, MAX_FILES>`
27+
to create a `Controller` with custom limits.
2828

2929
## [Version 0.3.0](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.3.0)
3030

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ designed for readability and simplicity over performance.
1111
You will need something that implements the `BlockDevice` trait, which can read and write the 512-byte blocks (or sectors) from your card. If you were to implement this over USB Mass Storage, there's no reason this crate couldn't work with a USB Thumb Drive, but we only supply a `BlockDevice` suitable for reading SD and SDHC cards over SPI.
1212

1313
```rust
14-
let mut spi_dev = embedded_sdmmc::SdMmcSpi::new(embedded_sdmmc::SdMmcSpi::new(sdmmc_spi, sdmmc_cs), time_source);
14+
let mut spi_dev = embedded_sdmmc::SdMmcSpi::new(sdmmc_spi, sdmmc_cs);
1515
write!(uart, "Init SD card...").unwrap();
1616
match spi_dev.acquire() {
1717
Ok(block) => {
@@ -42,7 +42,7 @@ let mut cont: Controller<
4242
DummyTimeSource,
4343
6,
4444
12,
45-
> = Controller::new(block, time_source);
45+
> = Controller::new_with_limits(block, time_source);
4646
```
4747

4848
## Supported features

examples/create_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn main() {
118118
.map_err(Error::DeviceError)
119119
.unwrap();
120120
println!("lbd: {:?}", lbd);
121-
let mut controller: Controller<LinuxBlockDevice, Clock, 4, 4> = Controller::new(lbd, Clock);
121+
let mut controller = Controller::new(lbd, Clock);
122122
for volume_idx in 0..=3 {
123123
let volume = controller.get_volume(VolumeIdx(volume_idx));
124124
println!("volume {}: {:#?}", volume_idx, volume);

examples/delete_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn main() {
118118
.map_err(Error::DeviceError)
119119
.unwrap();
120120
println!("lbd: {:?}", lbd);
121-
let mut controller: Controller<LinuxBlockDevice, Clock, 4, 4> = Controller::new(lbd, Clock);
121+
let mut controller = Controller::new(lbd, Clock);
122122
for volume_idx in 0..=3 {
123123
let volume = controller.get_volume(VolumeIdx(volume_idx));
124124
println!("volume {}: {:#?}", volume_idx, volume);

examples/test_mount.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn main() {
121121
.map_err(Error::DeviceError)
122122
.unwrap();
123123
println!("lbd: {:?}", lbd);
124-
let mut controller: Controller<LinuxBlockDevice, Clock, 4, 4> = Controller::new(lbd, Clock);
124+
let mut controller = Controller::new(lbd, Clock);
125125
for i in 0..=3 {
126126
let volume = controller.get_volume(VolumeIdx(i));
127127
println!("volume {}: {:#?}", i, volume);

examples/write_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn main() {
118118
.map_err(Error::DeviceError)
119119
.unwrap();
120120
println!("lbd: {:?}", lbd);
121-
let mut controller: Controller<LinuxBlockDevice, Clock, 4, 4> = Controller::new(lbd, Clock);
121+
let mut controller = Controller::new(lbd, Clock);
122122
for volume_idx in 0..=3 {
123123
let volume = controller.get_volume(VolumeIdx(volume_idx));
124124
println!("volume {}: {:#?}", volume_idx, volume);

src/controller.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ where
2929
open_files: [(VolumeIdx, Cluster); MAX_FILES],
3030
}
3131

32+
impl<D, T> Controller<D, T, 4, 4>
33+
where
34+
D: BlockDevice,
35+
T: TimeSource,
36+
<D as BlockDevice>::Error: core::fmt::Debug,
37+
{
38+
/// Create a new Disk Controller using a generic `BlockDevice`. From this
39+
/// controller we can open volumes (partitions) and with those we can open
40+
/// files.
41+
///
42+
/// This creates a Controller with default values
43+
/// MAX_DIRS = 4, MAX_FILES = 4. Call `Controller::new_with_limits(block_device, timesource)`
44+
/// if you need different limits.
45+
pub fn new(block_device: D, timesource: T) -> Controller<D, T, 4, 4> {
46+
Self::new_with_limits(block_device, timesource)
47+
}
48+
}
49+
3250
impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize> Controller<D, T, MAX_DIRS, MAX_FILES>
3351
where
3452
D: BlockDevice,
@@ -38,7 +56,10 @@ where
3856
/// Create a new Disk Controller using a generic `BlockDevice`. From this
3957
/// controller we can open volumes (partitions) and with those we can open
4058
/// files.
41-
pub fn new(block_device: D, timesource: T) -> Controller<D, T, MAX_DIRS, MAX_FILES> {
59+
pub fn new_with_limits(
60+
block_device: D,
61+
timesource: T,
62+
) -> Controller<D, T, MAX_DIRS, MAX_FILES> {
4263
debug!("Creating new embedded-sdmmc::Controller");
4364
Controller {
4465
block_device,

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,9 @@ mod tests {
460460

461461
#[test]
462462
fn partition0() {
463-
let mut c: Controller<DummyBlockDevice, Clock, 4, 4> =
464-
Controller::new(DummyBlockDevice, Clock);
463+
let mut c: Controller<DummyBlockDevice, Clock, 2, 2> =
464+
Controller::new_with_limits(DummyBlockDevice, Clock);
465+
465466
let v = c.get_volume(VolumeIdx(0)).unwrap();
466467
assert_eq!(
467468
v,

0 commit comments

Comments
 (0)