Skip to content

Commit

Permalink
Preliminary I2S Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed Nov 14, 2022
1 parent c4d77d6 commit ab5f7da
Show file tree
Hide file tree
Showing 20 changed files with 3,455 additions and 114 deletions.
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

0 comments on commit ab5f7da

Please sign in to comment.