Remove SPI slave prelude (#2260)
* Remove SPI slave prelude * Changelog * Update esp-hal/src/spi/slave.rs
This commit is contained in:
parent
8e9f6b5015
commit
f5b8e4b914
@ -96,6 +96,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Removed `uart::{DefaultRxPin, DefaultTxPin}` (#2132)
|
- Removed `uart::{DefaultRxPin, DefaultTxPin}` (#2132)
|
||||||
- Removed `PcntSource` and `PcntInputConfig`. (#2134)
|
- Removed `PcntSource` and `PcntInputConfig`. (#2134)
|
||||||
- Removed the `place-spi-driver-in-ram` feature, this is now enabled via [esp-config](https://docs.rs/esp-config) (#2156)
|
- Removed the `place-spi-driver-in-ram` feature, this is now enabled via [esp-config](https://docs.rs/esp-config) (#2156)
|
||||||
|
- Removed `esp_hal::spi::slave::prelude` (#2260)
|
||||||
|
- Removed `esp_hal::spi::slave::WithDmaSpiN` traits (#2260)
|
||||||
|
|
||||||
## [0.20.1] - 2024-08-30
|
## [0.20.1] - 2024-08-30
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
//! # use esp_hal::dma::DmaPriority;
|
//! # use esp_hal::dma::DmaPriority;
|
||||||
//! # use esp_hal::dma_buffers;
|
//! # use esp_hal::dma_buffers;
|
||||||
//! # use esp_hal::spi::SpiMode;
|
//! # use esp_hal::spi::SpiMode;
|
||||||
//! # use esp_hal::spi::slave::{prelude::*, Spi};
|
//! # use esp_hal::spi::slave::Spi;
|
||||||
//! # use esp_hal::dma::Dma;
|
//! # use esp_hal::dma::Dma;
|
||||||
//! # use esp_hal::gpio::Io;
|
//! # use esp_hal::gpio::Io;
|
||||||
//! let dma = Dma::new(peripherals.DMA);
|
//! let dma = Dma::new(peripherals.DMA);
|
||||||
@ -80,17 +80,6 @@ use crate::{
|
|||||||
system::PeripheralClockControl,
|
system::PeripheralClockControl,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Prelude for the SPI (Slave) driver
|
|
||||||
pub mod prelude {
|
|
||||||
#[cfg(spi3)]
|
|
||||||
pub use super::dma::WithDmaSpi3 as _esp_hal_spi_slave_dma_WithDmaSpi3;
|
|
||||||
pub use super::{
|
|
||||||
dma::WithDmaSpi2 as _esp_hal_spi_slave_dma_WithDmaSpi2,
|
|
||||||
Instance as _esp_hal_spi_slave_Instance,
|
|
||||||
InstanceDma as _esp_hal_spi_slave_InstanceDma,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const MAX_DMA_SIZE: usize = 32768 - 32;
|
const MAX_DMA_SIZE: usize = 32768 - 32;
|
||||||
|
|
||||||
/// SPI peripheral driver
|
/// SPI peripheral driver
|
||||||
@ -181,54 +170,20 @@ pub mod dma {
|
|||||||
Mode,
|
Mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Trait for configuring DMA with SPI2 peripherals in slave mode.
|
impl<'d> Spi<'d, crate::peripherals::SPI2, FullDuplexMode> {
|
||||||
pub trait WithDmaSpi2<'d, C, DmaMode>
|
|
||||||
where
|
|
||||||
C: DmaChannel,
|
|
||||||
C::P: SpiPeripheral,
|
|
||||||
DmaMode: Mode,
|
|
||||||
{
|
|
||||||
/// Configures the SPI2 peripheral with the provided DMA channel and
|
|
||||||
/// descriptors.
|
|
||||||
fn with_dma(
|
|
||||||
self,
|
|
||||||
channel: Channel<'d, C, DmaMode>,
|
|
||||||
rx_descriptors: &'static mut [DmaDescriptor],
|
|
||||||
tx_descriptors: &'static mut [DmaDescriptor],
|
|
||||||
) -> SpiDma<'d, crate::peripherals::SPI2, C, DmaMode>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Trait for configuring DMA with SPI3 peripherals in slave mode.
|
|
||||||
#[cfg(spi3)]
|
|
||||||
pub trait WithDmaSpi3<'d, C, DmaMode>
|
|
||||||
where
|
|
||||||
C: DmaChannel,
|
|
||||||
C::P: SpiPeripheral,
|
|
||||||
DmaMode: Mode,
|
|
||||||
{
|
|
||||||
/// Configures the SPI3 peripheral with the provided DMA channel and
|
/// Configures the SPI3 peripheral with the provided DMA channel and
|
||||||
/// descriptors.
|
/// descriptors.
|
||||||
fn with_dma(
|
pub fn with_dma<C, DmaMode>(
|
||||||
self,
|
self,
|
||||||
channel: Channel<'d, C, DmaMode>,
|
channel: Channel<'d, C, DmaMode>,
|
||||||
rx_descriptors: &'static mut [DmaDescriptor],
|
rx_descriptors: &'static mut [DmaDescriptor],
|
||||||
tx_descriptors: &'static mut [DmaDescriptor],
|
tx_descriptors: &'static mut [DmaDescriptor],
|
||||||
) -> SpiDma<'d, crate::peripherals::SPI3, C, DmaMode>;
|
) -> SpiDma<'d, crate::peripherals::SPI2, C, DmaMode>
|
||||||
}
|
where
|
||||||
|
C: DmaChannel,
|
||||||
impl<'d, C, DmaMode> WithDmaSpi2<'d, C, DmaMode>
|
C::P: SpiPeripheral + Spi2Peripheral,
|
||||||
for Spi<'d, crate::peripherals::SPI2, FullDuplexMode>
|
DmaMode: Mode,
|
||||||
where
|
{
|
||||||
C: DmaChannel,
|
|
||||||
C::P: SpiPeripheral + Spi2Peripheral,
|
|
||||||
DmaMode: Mode,
|
|
||||||
{
|
|
||||||
fn with_dma(
|
|
||||||
self,
|
|
||||||
channel: Channel<'d, C, DmaMode>,
|
|
||||||
rx_descriptors: &'static mut [DmaDescriptor],
|
|
||||||
tx_descriptors: &'static mut [DmaDescriptor],
|
|
||||||
) -> SpiDma<'d, crate::peripherals::SPI2, C, DmaMode> {
|
|
||||||
SpiDma {
|
SpiDma {
|
||||||
spi: self.spi,
|
spi: self.spi,
|
||||||
channel,
|
channel,
|
||||||
@ -239,19 +194,20 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(spi3)]
|
#[cfg(spi3)]
|
||||||
impl<'d, C, DmaMode> WithDmaSpi3<'d, C, DmaMode>
|
impl<'d> Spi<'d, crate::peripherals::SPI3, FullDuplexMode> {
|
||||||
for Spi<'d, crate::peripherals::SPI3, FullDuplexMode>
|
/// Configures the SPI3 peripheral with the provided DMA channel and
|
||||||
where
|
/// descriptors.
|
||||||
C: DmaChannel,
|
pub fn with_dma<C, DmaMode>(
|
||||||
C::P: SpiPeripheral + Spi3Peripheral,
|
|
||||||
DmaMode: Mode,
|
|
||||||
{
|
|
||||||
fn with_dma(
|
|
||||||
self,
|
self,
|
||||||
channel: Channel<'d, C, DmaMode>,
|
channel: Channel<'d, C, DmaMode>,
|
||||||
rx_descriptors: &'static mut [DmaDescriptor],
|
rx_descriptors: &'static mut [DmaDescriptor],
|
||||||
tx_descriptors: &'static mut [DmaDescriptor],
|
tx_descriptors: &'static mut [DmaDescriptor],
|
||||||
) -> SpiDma<'d, crate::peripherals::SPI3, C, DmaMode> {
|
) -> SpiDma<'d, crate::peripherals::SPI3, C, DmaMode>
|
||||||
|
where
|
||||||
|
C: DmaChannel,
|
||||||
|
C::P: SpiPeripheral + Spi3Peripheral,
|
||||||
|
DmaMode: Mode,
|
||||||
|
{
|
||||||
SpiDma {
|
SpiDma {
|
||||||
spi: self.spi,
|
spi: self.spi,
|
||||||
channel,
|
channel,
|
||||||
|
|||||||
@ -36,10 +36,7 @@ use esp_hal::{
|
|||||||
dma_buffers,
|
dma_buffers,
|
||||||
gpio::{Input, Io, Level, Output, Pull},
|
gpio::{Input, Io, Level, Output, Pull},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
spi::{
|
spi::{slave::Spi, SpiMode},
|
||||||
slave::{prelude::*, Spi},
|
|
||||||
SpiMode,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user