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

Preliminary I2S Implementation #262

Merged
merged 1 commit into from
Nov 17, 2022
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
52 changes: 52 additions & 0 deletions esp-hal-common/src/dma/gdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,38 @@ macro_rules! impl_channel {
ret
}

fn last_out_dscr_address() -> usize {
let dma = unsafe { &*crate::pac::DMA::PTR };
dma.[<out_eof_des_addr_ch $num>].read().out_eof_des_addr().bits() as usize
}

fn is_out_eof_interrupt_set() -> bool {
let dma = unsafe { &*crate::pac::DMA::PTR };

#[cfg(not(esp32s3))]
let ret = dma.[<int_raw_ch $num>].read().out_eof().bit();
#[cfg(esp32s3)]
let ret = dma.[<out_int_raw_ch $num>].read().out_eof().bit();

ret
}

fn reset_out_eof_interrupt() {
let dma = unsafe { &*crate::pac::DMA::PTR };

#[cfg(not(esp32s3))]
dma.[<int_clr_ch $num>].write(|w| {
w.out_eof()
.set_bit()
});

#[cfg(esp32s3)]
dma.[<out_int_clr_ch $num>].write(|w| {
w.out_eof()
.set_bit()
});
}

fn set_in_burstmode(burst_mode: bool) {
let dma = unsafe { &*crate::pac::DMA::PTR };

Expand Down Expand Up @@ -225,6 +257,11 @@ macro_rules! impl_channel {

ret
}

fn last_in_dscr_address() -> usize {
let dma = unsafe { &*crate::pac::DMA::PTR };
dma.[<in_dscr_bf0_ch $num>].read().inlink_dscr_bf0().bits() as usize
}
}

pub struct [<Channel $num TxImpl>] {}
Expand Down Expand Up @@ -252,6 +289,12 @@ macro_rules! impl_channel {
descriptors: tx_descriptors,
burst_mode,
tx_impl: tx_impl,
write_offset: 0,
write_descr_ptr: core::ptr::null(),
available: 0,
last_seen_handled_descriptor_ptr: core::ptr::null(),
buffer_start: core::ptr::null(),
buffer_len: 0,
_phantom: PhantomData::default(),
};

Expand All @@ -262,6 +305,12 @@ macro_rules! impl_channel {
descriptors: rx_descriptors,
burst_mode,
rx_impl: rx_impl,
read_offset: 0,
read_descr_ptr: core::ptr::null(),
available: 0,
last_seen_handled_descriptor_ptr: core::ptr::null(),
buffer_start: core::ptr::null(),
buffer_len: 0,
_phantom: PhantomData::default(),
};

Expand All @@ -279,6 +328,9 @@ macro_rules! impl_channel {
// with GDMA every channel can be used for any peripheral
impl SpiPeripheral for [<SuitablePeripheral $num>] {}
impl Spi2Peripheral for [<SuitablePeripheral $num>] {}
impl I2sPeripheral for [<SuitablePeripheral $num>] {}
impl I2s0Peripheral for [<SuitablePeripheral $num>] {}
impl I2s1Peripheral for [<SuitablePeripheral $num>] {}
}
};
}
Expand Down
Loading