Skip to content

Commit

Permalink
PARL_IO RX for ESP32-C6 / H2 (#760)
Browse files Browse the repository at this point in the history
* PARL_IO RX for ESP32-C6 / H2

* Add PARL_IO RX to README.md

* Remove logger-init from PARL_IO_RX examples
  • Loading branch information
bjoernQ authored Aug 29, 2023
1 parent 7d5e1de commit 9a89487
Show file tree
Hide file tree
Showing 11 changed files with 1,327 additions and 76 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add HMAC peripheral support (#755)
- Add multicore-aware embassy executor for Xtensa MCUs (#723).
- Add interrupt-executor for Xtensa MCUs (#723).
- Add PARL_IO RX driver for ESP32-C6 / ESP32-H2 (#760)

### Changed

Expand Down
22 changes: 22 additions & 0 deletions esp-hal-common/src/dma/gdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,28 @@ macro_rules! impl_channel {
ret
}

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

#[cfg(not(any(esp32c6, esp32h2, esp32s3)))]
let ret = dma.[<int_raw_ch $num>].read().in_dscr_empty().bit();
#[cfg(any(esp32c6, esp32h2, esp32s3))]
let ret = dma.[<in_int_raw_ch $num>].read().in_dscr_empty().bit();

ret
}

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

#[cfg(not(any(esp32c6, esp32h2, esp32s3)))]
let ret = dma.[<int_raw_ch $num>].read().in_err_eof().bit();
#[cfg(any(esp32c6, esp32h2, esp32s3))]
let ret = dma.[<in_int_raw_ch $num>].read().in_err_eof().bit();

ret
}

fn set_in_peripheral(peripheral: u8) {
let dma = unsafe { &*crate::peripherals::DMA::PTR };

Expand Down
17 changes: 17 additions & 0 deletions esp-hal-common/src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,15 @@ pub trait RxPrivate {

fn drain_buffer(&mut self, dst: &mut [u8]) -> Result<usize, DmaError>;

/// Descriptor error detected
fn has_error(&self) -> bool;

/// ERR_DSCR_EMPTY error detected
fn has_dscr_empty_error(&self) -> bool;

/// ERR_EOF error detected
fn has_eof_error(&self) -> bool;

#[cfg(feature = "async")]
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker;
}
Expand Down Expand Up @@ -554,6 +561,14 @@ where
R::has_in_descriptor_error()
}

fn has_dscr_empty_error(&self) -> bool {
R::has_in_descriptor_error_dscr_empty()
}

fn has_eof_error(&self) -> bool {
R::has_in_descriptor_error_err_eof()
}

#[cfg(feature = "async")]
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker {
T::waker()
Expand Down Expand Up @@ -904,6 +919,8 @@ pub trait RegisterAccess {
fn reset_in();
fn set_in_descriptors(address: u32);
fn has_in_descriptor_error() -> bool;
fn has_in_descriptor_error_dscr_empty() -> bool;
fn has_in_descriptor_error_err_eof() -> bool;
fn set_in_peripheral(peripheral: u8);
fn start_in();
fn is_in_done() -> bool;
Expand Down
20 changes: 20 additions & 0 deletions esp-hal-common/src/dma/pdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ macro_rules! ImplSpiChannel {
spi.dma_int_raw.read().inlink_dscr_error_int_raw().bit()
}

fn has_in_descriptor_error_dscr_empty() -> bool {
let spi = unsafe { &*crate::peripherals::[<SPI $num>]::PTR };
spi.dma_int_raw.read().inlink_dscr_empty_int_raw().bit()
}

fn has_in_descriptor_error_err_eof() -> bool {
let spi = unsafe { &*crate::peripherals::[<SPI $num>]::PTR };
spi.dma_int_raw.read().in_err_eof_int_raw().bit()
}

fn set_in_peripheral(_peripheral: u8) {
// no-op
}
Expand Down Expand Up @@ -421,6 +431,16 @@ macro_rules! ImplI2sChannel {
reg_block.int_raw.read().in_dscr_err_int_raw().bit()
}

fn has_in_descriptor_error_dscr_empty() -> bool {
let reg_block = unsafe { &*crate::peripherals::[<$peripheral>]::PTR };
reg_block.int_raw.read().in_dscr_empty_int_raw().bit()
}

fn has_in_descriptor_error_err_eof() -> bool {
let reg_block = unsafe { &*crate::peripherals::[<$peripheral>]::PTR };
reg_block.int_raw.read().in_err_eof_int_raw().bit()
}

fn set_in_peripheral(_peripheral: u8) {
// no-op
}
Expand Down
Loading

0 comments on commit 9a89487

Please sign in to comment.