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
26 changes: 14 additions & 12 deletions esp-hal-common/src/i2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
DmaError,
DmaTransfer,
},
peripheral::{Peripheral, PeripheralRef},
system::PeripheralClockControl,
InputPin,
OutputPin,
Expand Down Expand Up @@ -440,22 +441,22 @@ where
}

/// Instance of the I2S peripheral driver
pub struct I2s<I, T, P, TX, RX>
pub struct I2s<'d, I, T, P, TX, RX>
where
I: Instance<T>,
T: RegisterAccess + Clone,
P: I2sMclkPin,
TX: Tx,
RX: Rx,
{
_peripheral: I,
_peripheral: PeripheralRef<'d, I>,
_register_access: T,
_pins: P,
pub i2s_tx: TxCreator<T, TX>,
pub i2s_rx: RxCreator<T, RX>,
}

impl<I, T, P, TX, RX> I2s<I, T, P, TX, RX>
impl<'d, I, T, P, TX, RX> I2s<'d, I, T, P, TX, RX>
where
I: Instance<T>,
T: RegisterAccess + Clone,
Expand All @@ -464,7 +465,7 @@ where
RX: Rx,
{
fn new_internal<IP>(
i2s: I,
i2s: impl Peripheral<P = I> + 'd,
mut pins: P,
standard: Standard,
data_format: DataFormat,
Expand All @@ -480,6 +481,7 @@ where
// could be configured totally independently but for now handle all
// the targets the same and force same configuration for both, TX and RX

crate::into_ref!(i2s);
let mut register_access = i2s.register_access();

channel.tx.init_channel();
Expand Down Expand Up @@ -512,7 +514,7 @@ where
}

/// Construct a new I2S peripheral driver instance for the first I2S peripheral
pub trait I2s0New<I, T, P, TX, RX, IP>
pub trait I2s0New<'d, I, T, P, TX, RX, IP>
where
I: Instance<T>,
T: RegisterAccess + Clone,
Expand All @@ -523,7 +525,7 @@ where
RX: Rx,
{
fn new(
i2s: I,
i2s: impl Peripheral<P = I> + 'd,
pins: P,
standard: Standard,
data_format: DataFormat,
Expand All @@ -534,7 +536,7 @@ where
) -> Self;
}

impl<I, T, P, TX, RX, IP> I2s0New<I, T, P, TX, RX, IP> for I2s<I, T, P, TX, RX>
impl<'d, I, T, P, TX, RX, IP> I2s0New<'d, I, T, P, TX, RX, IP> for I2s<'d, I, T, P, TX, RX>
where
I: Instance<T> + I2s0Instance,
T: RegisterAccess + Clone,
Expand All @@ -544,7 +546,7 @@ where
IP: I2sPeripheral + I2s0Peripheral,
{
fn new(
i2s: I,
i2s: impl Peripheral<P = I> + 'd,
pins: P,
standard: Standard,
data_format: DataFormat,
Expand All @@ -568,7 +570,7 @@ where

/// Construct a new I2S peripheral driver instance for the second I2S peripheral
#[cfg(any(esp32s3))]
pub trait I2s1New<I, T, P, TX, RX, IP>
pub trait I2s1New<'d, I, T, P, TX, RX, IP>
where
I: Instance<T>,
T: RegisterAccess + Clone,
Expand All @@ -579,7 +581,7 @@ where
RX: Rx,
{
fn new(
i2s: I,
i2s: impl Peripheral<P = I> + 'd,
pins: P,
standard: Standard,
data_format: DataFormat,
Expand All @@ -591,7 +593,7 @@ where
}

#[cfg(any(esp32s3))]
impl<I, T, P, TX, RX, IP> I2s1New<I, T, P, TX, RX, IP> for I2s<I, T, P, TX, RX>
impl<'d, I, T, P, TX, RX, IP> I2s1New<'d, I, T, P, TX, RX, IP> for I2s<'d, I, T, P, TX, RX>
where
I: Instance<T> + I2s1Instance,
T: RegisterAccess + Clone,
Expand All @@ -601,7 +603,7 @@ where
IP: I2sPeripheral + I2s1Peripheral,
{
fn new(
i2s: I,
i2s: impl Peripheral<P = I> + 'd,
pins: P,
standard: Standard,
data_format: DataFormat,
Expand Down
2 changes: 2 additions & 0 deletions esp-hal-common/src/peripherals/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ mod peripherals {
DPORT,
LEDC,
RMT,
I2S0,
I2S1,
}
}
1 change: 1 addition & 0 deletions esp-hal-common/src/peripherals/esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ mod peripherals {
SYSTEM,
LEDC,
RMT,
I2S,
}
}
1 change: 1 addition & 0 deletions esp-hal-common/src/peripherals/esp32s2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ mod peripherals {
SYSTEM,
LEDC,
RMT,
I2S,
}
}
2 changes: 2 additions & 0 deletions esp-hal-common/src/peripherals/esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,7 @@ mod peripherals {
SYSTEM,
LEDC,
RMT,
I2S0,
I2S1,
}
}