forked from esp-rs/esp-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…esp-rs#843) * Refactor the `spi` and `spi_slave` modules into a single `spi` module * Update import paths in examples as needed * Extract some common types from `spi::master` into the root `spi` module * Fix imports in examples (again) * Documentation fixes/improvements * Remove unnecessary re-exports * Update `CHANGELOG.md`
- Loading branch information
1 parent
1ae132c
commit 0c9c832
Showing
60 changed files
with
256 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//! Serial Peripheral Interface | ||
//! | ||
//! This peripheral is capable of operating in either master or slave mode. For | ||
//! more information on these modes, please refer to the documentation in their | ||
//! respective modules. | ||
use crate::dma::DmaError; | ||
|
||
pub mod master; | ||
#[cfg(all(any(spi0, spi1, spi2, spi3), not(pdma)))] | ||
pub mod slave; | ||
|
||
/// SPI errors | ||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
#[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
pub enum Error { | ||
DmaError(DmaError), | ||
MaxDmaTransferSizeExceeded, | ||
FifoSizeExeeded, | ||
Unsupported, | ||
Unknown, | ||
} | ||
|
||
impl From<DmaError> for Error { | ||
fn from(value: DmaError) -> Self { | ||
Error::DmaError(value) | ||
} | ||
} | ||
|
||
#[cfg(feature = "eh1")] | ||
impl embedded_hal_1::spi::Error for Error { | ||
fn kind(&self) -> embedded_hal_1::spi::ErrorKind { | ||
embedded_hal_1::spi::ErrorKind::Other | ||
} | ||
} | ||
|
||
/// SPI modes | ||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
#[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
pub enum SpiMode { | ||
Mode0, | ||
Mode1, | ||
Mode2, | ||
Mode3, | ||
} | ||
|
||
pub trait DuplexMode {} | ||
pub trait IsFullDuplex: DuplexMode {} | ||
pub trait IsHalfDuplex: DuplexMode {} | ||
|
||
/// SPI data mode | ||
/// | ||
/// Single = 1 bit, 2 wires | ||
/// Dual = 2 bit, 2 wires | ||
/// Quad = 4 bit, 4 wires | ||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
#[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
pub enum SpiDataMode { | ||
Single, | ||
Dual, | ||
Quad, | ||
} | ||
|
||
/// Full-duplex operation | ||
pub struct FullDuplexMode {} | ||
impl DuplexMode for FullDuplexMode {} | ||
impl IsFullDuplex for FullDuplexMode {} | ||
|
||
/// Half-duplex operation | ||
pub struct HalfDuplexMode {} | ||
impl DuplexMode for HalfDuplexMode {} | ||
impl IsHalfDuplex for HalfDuplexMode {} |
Oops, something went wrong.