Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant WithDmaSpi traits #1975

Merged
merged 1 commit into from
Aug 21, 2024
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
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- This package no longer re-exports the `esp_hal_procmacros::main` macro (#1828)
- The `AesFlavour` trait no longer has the `ENCRYPT_MODE`/`DECRYPT_MODE` associated constants (#1849)
- Removed `FlashSafeDma` (#1856)
- Remove redundant WithDmaSpi traits (#1975)

## [0.19.0] - 2024-07-15

Expand Down
58 changes: 16 additions & 42 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ use crate::{

/// Prelude for the SPI (Master) driver
pub mod prelude {
#[cfg(spi3)]
pub use super::dma::WithDmaSpi3 as _esp_hal_spi_master_dma_WithDmaSpi3;
pub use super::{
dma::WithDmaSpi2 as _esp_hal_spi_master_dma_WithDmaSpi2,
Instance as _esp_hal_spi_master_Instance,
InstanceDma as _esp_hal_spi_master_InstanceDma,
};
Expand Down Expand Up @@ -867,44 +864,19 @@ pub mod dma {
Mode,
};

pub trait WithDmaSpi2<'d, C, M, DmaMode>
where
C: DmaChannel,
C::P: SpiPeripheral,
M: DuplexMode,
DmaMode: Mode,
{
fn with_dma(
self,
channel: Channel<'d, C, DmaMode>,
) -> SpiDma<'d, crate::peripherals::SPI2, C, M, DmaMode>;
}

#[cfg(spi3)]
pub trait WithDmaSpi3<'d, C, M, DmaMode>
where
C: DmaChannel,
C::P: SpiPeripheral,
M: DuplexMode,
DmaMode: Mode,
{
fn with_dma(
self,
channel: Channel<'d, C, DmaMode>,
) -> SpiDma<'d, crate::peripherals::SPI3, C, M, DmaMode>;
}

impl<'d, C, M, DmaMode> WithDmaSpi2<'d, C, M, DmaMode> for Spi<'d, crate::peripherals::SPI2, M>
impl<'d, M> Spi<'d, crate::peripherals::SPI2, M>
where
C: DmaChannel,
C::P: SpiPeripheral + Spi2Peripheral,
M: DuplexMode,
DmaMode: Mode,
{
fn with_dma(
pub fn with_dma<C, DmaMode>(
self,
mut channel: Channel<'d, C, DmaMode>,
) -> SpiDma<'d, crate::peripherals::SPI2, C, M, DmaMode> {
) -> SpiDma<'d, crate::peripherals::SPI2, C, M, DmaMode>
where
C: DmaChannel,
C::P: SpiPeripheral + Spi2Peripheral,
DmaMode: Mode,
{
channel.tx.init_channel(); // no need to call this for both, TX and RX

SpiDma {
Expand All @@ -916,17 +888,19 @@ pub mod dma {
}

#[cfg(spi3)]
impl<'d, C, M, DmaMode> WithDmaSpi3<'d, C, M, DmaMode> for Spi<'d, crate::peripherals::SPI3, M>
impl<'d, M> Spi<'d, crate::peripherals::SPI3, M>
where
C: DmaChannel,
C::P: SpiPeripheral + Spi3Peripheral,
M: DuplexMode,
DmaMode: Mode,
{
fn with_dma(
pub fn with_dma<C, DmaMode>(
self,
mut channel: Channel<'d, C, DmaMode>,
) -> SpiDma<'d, crate::peripherals::SPI3, C, M, DmaMode> {
) -> SpiDma<'d, crate::peripherals::SPI3, C, M, DmaMode>
where
C: DmaChannel,
C::P: SpiPeripheral + Spi3Peripheral,
DmaMode: Mode,
{
channel.tx.init_channel(); // no need to call this for both, TX and RX

SpiDma {
Expand Down
5 changes: 1 addition & 4 deletions examples/src/bin/embassy_spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ use esp_hal::{
gpio::Io,
peripherals::Peripherals,
prelude::*,
spi::{
master::{prelude::*, Spi},
SpiMode,
},
spi::{master::Spi, SpiMode},
system::SystemControl,
timer::timg::TimerGroup,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/qspi_flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use esp_hal::{
peripherals::Peripherals,
prelude::*,
spi::{
master::{prelude::*, Address, Command, Spi},
master::{Address, Command, Spi},
SpiDataMode,
SpiMode,
},
Expand Down
5 changes: 1 addition & 4 deletions examples/src/bin/spi_loopback_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ use esp_hal::{
gpio::Io,
peripherals::Peripherals,
prelude::*,
spi::{
master::{prelude::*, Spi},
SpiMode,
},
spi::{master::Spi, SpiMode},
system::SystemControl,
};
use esp_println::println;
Expand Down
5 changes: 1 addition & 4 deletions hil-test/tests/spi_full_duplex_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ use esp_hal::{
gpio::Io,
peripherals::Peripherals,
prelude::*,
spi::{
master::{prelude::*, Spi},
SpiMode,
},
spi::{master::Spi, SpiMode},
system::SystemControl,
};
use hil_test as _;
Expand Down
5 changes: 1 addition & 4 deletions hil-test/tests/spi_full_duplex_dma_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ use esp_hal::{
},
peripherals::Peripherals,
prelude::*,
spi::{
master::{prelude::*, Spi},
SpiMode,
},
spi::{master::Spi, SpiMode},
system::SystemControl,
};
use hil_test as _;
Expand Down
2 changes: 1 addition & 1 deletion hil-test/tests/spi_half_duplex_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod tests {
peripherals::Peripherals,
prelude::_fugit_RateExtU32,
spi::{
master::{prelude::*, Address, Command, Spi},
master::{Address, Command, Spi},
SpiDataMode,
SpiMode,
},
Expand Down
2 changes: 1 addition & 1 deletion hil-test/tests/spi_half_duplex_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod tests {
peripherals::Peripherals,
prelude::_fugit_RateExtU32,
spi::{
master::{prelude::*, Address, Command, Spi},
master::{Address, Command, Spi},
SpiDataMode,
SpiMode,
},
Expand Down