Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ designed for readability and simplicity over performance.

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.

To accommodate specific requirements when using SD cards on a shared SPI bus, this crate uses a bespoke `SdCardDevice` trait instead of the more commmon `embedded_hal::spi::SpiDevice` trait. Implementations for several types that wrap a `embedded-hal::spi::SpiBus` implementation are provided in the `sd_card` module. Some are guarded behind cargo features:
To accommodate specific requirements when using SD cards on a shared SPI bus, this crate uses a bespoke `SdCardSpiDevice` trait instead of the more commmon `embedded_hal::spi::SpiDevice` trait. Implementations for several types that wrap a `embedded-hal::spi::SpiBus` implementation are provided in the `sd_card` module. Some are guarded behind cargo features:

- `embedded-hal-bus-03`: adds support for `embedded-hal-bus::spi::ExclusiveDevice`. This is probably the easiest way to use this crate when the SD card is the only device on the bus.
- `embassy-sync-06`: adds support for using a blocking mutex from the `embassy-sync` crate. This allows sharing the bus between multiple tasks.
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
//! suitable for reading SD and SDHC cards over SPI.
//!
//! ```rust
//! use embedded_sdmmc::{Error, Mode, SdCard, SdCardError, TimeSource, VolumeIdx, VolumeManager, SdCardDevice};
//! use embedded_sdmmc::{Error, Mode, SdCard, SdCardError, TimeSource, VolumeIdx, VolumeManager, SdCardSpiDevice};
//!
//! fn example<S, D, T>(spi: S, delay: D, ts: T) -> Result<(), Error<SdCardError>>
//! where
//! S: SdCardDevice,
//! S: SdCardSpiDevice,
//! D: embedded_hal::delay::DelayNs,
//! T: TimeSource,
//! {
Expand Down
8 changes: 4 additions & 4 deletions src/sdcard/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait SdCardSpiDevice {
///
/// This is a convenience method equivalent to `device.transaction(&mut [Operation::Read(buf)])`.
///
/// See also: [`SdCardDevice::transaction`], [`embedded_hal::spi::SpiBus::read`]
/// See also: [`SdCardSpiDevice::transaction`], [`embedded_hal::spi::SpiBus::read`]
#[inline]
fn read(&mut self, buf: &mut [u8]) -> Result<(), SdCardDeviceError> {
self.transaction(&mut [Operation::Read(buf)])
Expand All @@ -36,7 +36,7 @@ pub trait SdCardSpiDevice {
///
/// This is a convenience method equivalent to `device.transaction(&mut [Operation::Write(buf)])`.
///
/// See also: [`SdCardDevice::transaction`], [`embedded_hal::spi::SpiBus::write`]
/// See also: [`SdCardSpiDevice::transaction`], [`embedded_hal::spi::SpiBus::write`]
#[inline]
fn write(&mut self, buf: &[u8]) -> Result<(), SdCardDeviceError> {
self.transaction(&mut [Operation::Write(buf)])
Expand All @@ -46,7 +46,7 @@ pub trait SdCardSpiDevice {
///
/// This is a convenience method equivalent to `device.transaction(&mut [Operation::Transfer(read, write)]`.
///
/// See also: [`SdCardDevice::transaction`], [`embedded_hal::spi::SpiBus::transfer`]
/// See also: [`SdCardSpiDevice::transaction`], [`embedded_hal::spi::SpiBus::transfer`]
#[inline]
fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), SdCardDeviceError> {
self.transaction(&mut [Operation::Transfer(read, write)])
Expand All @@ -56,7 +56,7 @@ pub trait SdCardSpiDevice {
///
/// This is a convenience method equivalent to `device.transaction(&mut [Operation::TransferInPlace(buf)]`.
///
/// See also: [`SdCardDevice::transaction`], [`embedded_hal::spi::SpiBus::transfer_in_place`]
/// See also: [`SdCardSpiDevice::transaction`], [`embedded_hal::spi::SpiBus::transfer_in_place`]
#[inline]
fn transfer_in_place(&mut self, buf: &mut [u8]) -> Result<(), SdCardDeviceError> {
self.transaction(&mut [Operation::TransferInPlace(buf)])
Expand Down