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

Erase DMA type params #2261

Merged
merged 36 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
394ff02
Split PdmaChannel into two
bugadani Oct 1, 2024
1c9fed0
Take &self in PDMA traits
bugadani Oct 1, 2024
2e1f3a9
Implement type-erased PDMA channels
bugadani Oct 1, 2024
b561a43
Remove Degraded assoc type
bugadani Oct 1, 2024
ebac0ab
Move degrade fns to base trait
bugadani Oct 1, 2024
c8ab220
Use PeripheralDmaChannel on constructors only
bugadani Oct 1, 2024
68c13cd
Remove WithDmaAes use
bugadani Oct 1, 2024
8a1bcc7
Erase DMA type params
bugadani Oct 2, 2024
a88bf54
Clean up examples/tests
bugadani Oct 2, 2024
2b8253a
Remove redundant trait bounds
bugadani Oct 3, 2024
b591eb6
Remove peripheral-specific DMA traits
bugadani Oct 3, 2024
7bafec9
Document i2s change
bugadani Oct 3, 2024
9111e56
Clean up parl_io
bugadani Oct 3, 2024
dd4605d
Deduplicate InterruptAccess
bugadani Oct 3, 2024
0e5a20f
Fix cfg
bugadani Oct 3, 2024
d2e3a4b
Implement runtime compatibility check
bugadani Oct 3, 2024
f750078
Clean up a bit
bugadani Oct 4, 2024
851c8fc
Document changes
bugadani Oct 4, 2024
a01b47c
Swap Channel type params, erase dma channel
bugadani Oct 4, 2024
a019533
Unsplit traits
bugadani Oct 4, 2024
a5cc2f3
Remove redundant cfg
bugadani Oct 4, 2024
4a91bfa
Fix docs
bugadani Oct 7, 2024
8865e99
Simplify DmaEligible
bugadani Oct 7, 2024
c705854
Remove unsafe code
bugadani Oct 7, 2024
f3c4cec
Revert "Swap Channel type params, erase dma channel"
bugadani Oct 7, 2024
ebf93db
Allow different degraded DMA types
bugadani Oct 7, 2024
4582667
Allow converting into peripheral-specific DMA channel, use it for com…
bugadani Oct 7, 2024
3c4e934
Erase PDMA types without AnyPdmaChannel
bugadani Oct 7, 2024
b9c0eb6
Hide degrade fns for now, remove from MG
bugadani Oct 7, 2024
be8ed88
Clean up SPI slave
bugadani Oct 7, 2024
a09efe9
Fix QSPI test
bugadani Oct 7, 2024
bc76e6b
Fix mem2mem, fix S3 peripherals
bugadani Oct 7, 2024
d14714d
Fix S2
bugadani Oct 7, 2024
52c500a
Remove AnyPdmaChannel
bugadani Oct 7, 2024
20fa92d
Remove PeripheralDmaChannel
bugadani Oct 8, 2024
7058e67
Remove unnecessary degrade call
bugadani Oct 8, 2024
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
3 changes: 3 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Change `DmaTxBuf` to support PSRAM on `esp32s3` (#2161)
- I2c `transaction` is now also available as a inherent function, lift size limit on `write`,`read` and `write_read` (#2262)
- SPI transactions are now cancelled if the transfer object (or async Future) is dropped. (#2216)
- The DMA channel types have been removed from peripherals (#2261)

### Fixed

Expand Down Expand Up @@ -107,6 +108,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
- The `WithDmaAes` trait has been removed (#2261)
- The `I2s::new_i2s1` constructor has been removed (#2261)

## [0.20.1] - 2024-08-30

Expand Down
22 changes: 21 additions & 1 deletion esp-hal/MIGRATING-0.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ When using the asymmetric variant of the macro to create DMA buffers and descrip
+ let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000);
```

## Removed UART constructors
## Removed constructors

### UART

The `Uart::new_with_default_pins` and `Uart::new_async_with_default_pins` constructors
have been removed. Use `new` or `new_async` instead.

### I2S1

The `I2s::new_i2s1` constructor has been removed. Use `I2s::new` instead.

## Timer changes

### `ErasedTimer` rename
Expand Down Expand Up @@ -319,3 +325,17 @@ Diff of the `psram_quad.rs` example
## eFuse

Calling `Efuse::read_field_le::<bool>()` no longer compiles. Use `Efuse::read_bit()` instead.

## DMA

The DMA channel types have been removed from peripherals.

A non-exhausitve list demonstrating this change:

```diff
-I2sTx<'static, I2S0, DmaChannel0, Async>
+I2sTx<'static, I2S0, Async>

-SpiDma<'static, esp_hal::peripherals::SPI2, DmaChannel0, HalfDuplexMode, Blocking>
+SpiDma<'static, esp_hal::peripherals::SPI2, HalfDuplexMode, Blocking>
```
82 changes: 20 additions & 62 deletions esp-hal/src/aes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,27 +235,23 @@ pub mod dma {
aes::{Key, Mode},
dma::{
dma_private::{DmaSupport, DmaSupportRx, DmaSupportTx},
AesPeripheral,
Channel,
ChannelRx,
ChannelTx,
DescriptorChain,
DmaChannel,
DmaChannelConvert,
DmaDescriptor,
DmaEligible,
DmaPeripheral,
DmaTransferRxTx,
ReadBuffer,
Rx,
Tx,
WriteBuffer,
},
peripherals::AES,
};

#[cfg(gdma)]
type DefaultChannel = crate::dma::AnyDmaChannel;
#[cfg(pdma)]
type DefaultChannel = (); // Replace with PDMA channel once support is added.

const ALIGN_SIZE: usize = core::mem::size_of::<u32>();

/// Specifies the block cipher modes available for AES operations.
Expand All @@ -275,69 +271,43 @@ pub mod dma {
}

/// A DMA capable AES instance.
pub struct AesDma<'d, C = DefaultChannel>
where
C: DmaChannel,
C::P: AesPeripheral,
{
pub struct AesDma<'d> {
/// The underlying [`Aes`](super::Aes) driver
pub aes: super::Aes<'d>,

pub(crate) channel: Channel<'d, C, crate::Blocking>,
channel: Channel<'d, <AES as DmaEligible>::Dma, crate::Blocking>,
rx_chain: DescriptorChain,
tx_chain: DescriptorChain,
}

/// Functionality for using AES with DMA.
pub trait WithDmaAes<'d, C>
where
C: DmaChannel,
C::P: AesPeripheral,
{
impl<'d> crate::aes::Aes<'d> {
/// Enable DMA for the current instance of the AES driver
fn with_dma(
self,
channel: Channel<'d, C, crate::Blocking>,
rx_descriptors: &'static mut [DmaDescriptor],
tx_descriptors: &'static mut [DmaDescriptor],
) -> AesDma<'d, C>;
}

impl<'d, C> WithDmaAes<'d, C> for crate::aes::Aes<'d>
where
C: DmaChannel,
C::P: AesPeripheral,
{
fn with_dma(
pub fn with_dma<C>(
self,
channel: Channel<'d, C, crate::Blocking>,
rx_descriptors: &'static mut [DmaDescriptor],
tx_descriptors: &'static mut [DmaDescriptor],
) -> AesDma<'d, C> {
) -> AesDma<'d>
where
Self: Sized,
C: DmaChannelConvert<<AES as DmaEligible>::Dma>,
{
AesDma {
aes: self,
channel,
channel: channel.degrade(),
rx_chain: DescriptorChain::new(rx_descriptors),
tx_chain: DescriptorChain::new(tx_descriptors),
}
}
}

impl<'d, C> core::fmt::Debug for AesDma<'d, C>
where
C: DmaChannel,
C::P: AesPeripheral,
{
impl<'d> core::fmt::Debug for AesDma<'d> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("AesDma").finish()
}
}

impl<'d, C> DmaSupport for AesDma<'d, C>
where
C: DmaChannel,
C::P: AesPeripheral,
{
impl<'d> DmaSupport for AesDma<'d> {
fn peripheral_wait_dma(&mut self, _is_rx: bool, _is_tx: bool) {
while self.aes.aes.state().read().state().bits() != 2 // DMA status DONE == 2
&& !self.channel.tx.is_done()
Expand All @@ -353,12 +323,8 @@ pub mod dma {
}
}

impl<'d, C> DmaSupportTx for AesDma<'d, C>
where
C: DmaChannel,
C::P: AesPeripheral,
{
type TX = ChannelTx<'d, C>;
impl<'d> DmaSupportTx for AesDma<'d> {
type TX = ChannelTx<'d, <AES as DmaEligible>::Dma>;

fn tx(&mut self) -> &mut Self::TX {
&mut self.channel.tx
Expand All @@ -369,12 +335,8 @@ pub mod dma {
}
}

impl<'d, C> DmaSupportRx for AesDma<'d, C>
where
C: DmaChannel,
C::P: AesPeripheral,
{
type RX = ChannelRx<'d, C>;
impl<'d> DmaSupportRx for AesDma<'d> {
type RX = ChannelRx<'d, <AES as DmaEligible>::Dma>;

fn rx(&mut self) -> &mut Self::RX {
&mut self.channel.rx
Expand All @@ -385,11 +347,7 @@ pub mod dma {
}
}

impl<'d, C> AesDma<'d, C>
where
C: DmaChannel,
C::P: AesPeripheral,
{
impl<'d> AesDma<'d> {
/// Writes the encryption key to the AES hardware, checking that its
/// length matches expected constraints.
pub fn write_key<K>(&mut self, key: K)
Expand Down
Loading