Skip to content

should use SpiBus, not SpiDevice #126

Closed
@Dirbaio

Description

@Dirbaio

/// Built from an [`SpiDevice`] implementation and a Chip Select pin.
/// Unfortunately, We need control of the chip select pin separately from the [`SpiDevice`]
/// implementation so we can clock out some bytes without Chip Select asserted
/// (which is necessary to make the SD card actually release the Spi bus after performing
/// operations on it, according to the spec). To support this, we provide [`DummyCsPin`]
/// which should be provided to your chosen [`SpiDevice`] implementation rather than the card's
/// actual CS pin. Then provide the actual CS pin to [`SdCard`]'s constructor.

If you take a CS pin directly, you have to use SpiBus, not SpiDevice.

Using SpiDevice with a dummy CS pin breaks bus sharing. (the bus looks "free" to the mutex between transactions, so it might grant the mutex to some other driver, which will break because this lib still has the CS pin asserted)

embedded-hal docs explicitly say not to do this https://docs.rs/embedded-hal/latest/embedded_hal/spi/index.html#for-driver-authors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions