Skip to content
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
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update ESP32-H2 and ESP32-C6 clocks and remove `i2c_clock` for all chips but ESP32 (#592)
- Use both timers in `TIMG0` for embassy time driver when able (#609)
- Re-work `RadioExt` implementations, add support for ESP32-H2 (#627)
- Improve examples documentation (#533)
- esp32h2-hal: added README (#585)

### Fixed

Expand All @@ -61,13 +63,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a possible overlap of `.data` and `.rwtext` (#616)
- Avoid SDA/SCL being low while configuring pins for I2C

### Changed

- Improve examples documentation (#533)
- esp32h2-hal: added README (#585)

### Breaking

- Simplified user-facing SpiDma and I2s types (#626)
- Significantly simplified user-facing GPIO pin types. (#553)
- No longer re-export the `soc` module and the contents of the `interrupt` module at the package level (#607)

Expand Down
9 changes: 7 additions & 2 deletions esp-hal-common/src/dma/gdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ macro_rules! impl_channel {
#[non_exhaustive]
pub struct [<Channel $num>] {}

impl ChannelTypes for [<Channel $num>] {
type P = [<SuitablePeripheral $num>];
type Tx<'a> = ChannelTx<'a, [<Channel $num TxImpl>], [<Channel $num>]>;
type Rx<'a> = ChannelRx<'a, [<Channel $num RxImpl>], [<Channel $num>]>;
}

impl RegisterAccess for [<Channel $num>] {
fn init_channel() {
// nothing special to be done here
Expand Down Expand Up @@ -402,7 +408,7 @@ macro_rules! impl_channel {
tx_descriptors: &'a mut [u32],
rx_descriptors: &'a mut [u32],
priority: DmaPriority,
) -> Channel<ChannelTx<'a, [<Channel $num TxImpl>], [<Channel $num>]>, ChannelRx<'a, [<Channel $num RxImpl>], [<Channel $num>]>, [<SuitablePeripheral $num>]> {
) -> Channel<'a, [<Channel $num>]> {
let mut tx_impl = [<Channel $num TxImpl>] {};
tx_impl.init(burst_mode, priority);

Expand Down Expand Up @@ -436,7 +442,6 @@ macro_rules! impl_channel {
Channel {
tx: tx_channel,
rx: rx_channel,
_phantom: PhantomData::default(),
}
}
}
Expand Down
18 changes: 11 additions & 7 deletions esp-hal-common/src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,20 @@ pub trait RegisterAccess {
fn unlisten_in_eof();
fn unlisten_out_eof();
}

pub trait ChannelTypes {
type P: PeripheralMarker;
type Tx<'a>: Tx;
type Rx<'a>: Rx;
}

/// DMA Channel
pub struct Channel<TX, RX, P>
pub struct Channel<'d, C>
where
TX: Tx,
RX: Rx,
P: PeripheralMarker,
C: ChannelTypes,
{
pub(crate) tx: TX,
pub(crate) rx: RX,
_phantom: PhantomData<P>,
pub(crate) tx: C::Tx<'d>,
pub(crate) rx: C::Rx<'d>,
}

/// Trait to be implemented for an in progress dma transfer.
Expand Down
26 changes: 14 additions & 12 deletions esp-hal-common/src/dma/pdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ macro_rules! ImplSpiChannel {
#[non_exhaustive]
pub struct [<Spi $num DmaChannel>] {}

impl ChannelTypes for [<Spi $num DmaChannel>] {
type P = [<Spi $num DmaSuitablePeripheral>];
type Tx<'a> = ChannelTx<'a,[<Spi $num DmaChannelTxImpl>], [<Spi $num DmaChannel>]>;
type Rx<'a> = ChannelRx<'a,[<Spi $num DmaChannelRxImpl>], [<Spi $num DmaChannel>]>;
}

impl RegisterAccess for [<Spi $num DmaChannel>] {
fn init_channel() {
// (only) on ESP32 we need to configure DPORT for the SPI DMA channels
Expand Down Expand Up @@ -232,11 +238,7 @@ macro_rules! ImplSpiChannel {
tx_descriptors: &'a mut [u32],
rx_descriptors: &'a mut [u32],
priority: DmaPriority,
) -> Channel<
ChannelTx<'a,[<Spi $num DmaChannelTxImpl>], [<Spi $num DmaChannel>]>,
ChannelRx<'a,[<Spi $num DmaChannelRxImpl>], [<Spi $num DmaChannel>]>,
[<Spi $num DmaSuitablePeripheral>],
> {
) -> Channel<'a, [<Spi $num DmaChannel>]> {
let mut tx_impl = [<Spi $num DmaChannelTxImpl>] {};
tx_impl.init(burst_mode, priority);

Expand Down Expand Up @@ -270,7 +272,6 @@ macro_rules! ImplSpiChannel {
Channel {
tx: tx_channel,
rx: rx_channel,
_phantom: PhantomData::default(),
}
}
}
Expand All @@ -283,6 +284,12 @@ macro_rules! ImplI2sChannel {
paste::paste! {
pub struct [<I2s $num DmaChannel>] {}

impl ChannelTypes for [<I2s $num DmaChannel>] {
type P = [<I2s $num DmaSuitablePeripheral>];
type Tx<'a> = ChannelTx<'a,[<I2s $num DmaChannelTxImpl>], [<I2s $num DmaChannel>]>;
type Rx<'a> = ChannelRx<'a,[<I2s $num DmaChannelRxImpl>], [<I2s $num DmaChannel>]>;
}

impl RegisterAccess for [<I2s $num DmaChannel>] {
fn init_channel() {
// nothing to do
Expand Down Expand Up @@ -471,11 +478,7 @@ macro_rules! ImplI2sChannel {
tx_descriptors: &'a mut [u32],
rx_descriptors: &'a mut [u32],
priority: DmaPriority,
) -> Channel<
ChannelTx<'a,[<I2s $num DmaChannelTxImpl>], [<I2s $num DmaChannel>]>,
ChannelRx<'a,[<I2s $num DmaChannelRxImpl>], [<I2s $num DmaChannel>]>,
[<I2s $num DmaSuitablePeripheral>],
> {
) -> Channel<'a, [<I2s $num DmaChannel>]> {
let mut tx_impl = [<I2s $num DmaChannelTxImpl>] {};
tx_impl.init(burst_mode, priority);

Expand Down Expand Up @@ -509,7 +512,6 @@ macro_rules! ImplI2sChannel {
Channel {
tx: tx_channel,
rx: rx_channel,
_phantom: PhantomData::default(),
}
}
}
Expand Down
Loading