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

parl_io: use ReadBuffer/WriteBuffer for async DMA #1996

Merged
merged 2 commits into from
Aug 26, 2024
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
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- DMA buffers now don't require a static lifetime. Make sure to never `mem::forget` an in-progress DMA transfer (consider using `#[deny(clippy::mem_forget)]`) (#1837)
- SHA driver now use specific structs for the hashing algorithm instead of a parameter. (#1908)
- Remove `fn free(self)` in HMAC which goes against esp-hal API guidelines (#1972)
- PARL_IO use ReadBuffer and WriteBuffer for Async DMA (#1996)

### Fixed

Expand Down
19 changes: 14 additions & 5 deletions esp-hal/src/parl_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@ pub mod asynch {

use super::{private::Instance, Error, ParlIoRx, ParlIoTx, MAX_DMA_SIZE};
use crate::{
dma::{asynch::DmaRxFuture, DmaChannel, ParlIoPeripheral},
dma::{asynch::DmaRxFuture, DmaChannel, ParlIoPeripheral, ReadBuffer, WriteBuffer},
peripherals::Interrupt,
};

Expand Down Expand Up @@ -1731,8 +1731,11 @@ pub mod asynch {
/// Perform a DMA write.
///
/// The maximum amount of data to be sent is 32736 bytes.
pub async fn write_dma_async(&mut self, words: &mut [u8]) -> Result<(), Error> {
let (ptr, len) = (words.as_ptr(), words.len());
pub async fn write_dma_async<'t, TXBUF>(&mut self, words: &'t TXBUF) -> Result<(), Error>
where
TXBUF: ReadBuffer,
{
let (ptr, len) = unsafe { words.read_buffer() };

if len > MAX_DMA_SIZE {
return Err(Error::MaxDmaTransferSizeExceeded);
Expand All @@ -1754,8 +1757,14 @@ pub mod asynch {
/// Perform a DMA write.
///
/// The maximum amount of data to be sent is 32736 bytes.
pub async fn read_dma_async(&mut self, words: &mut [u8]) -> Result<(), Error> {
let (ptr, len) = (words.as_mut_ptr(), words.len());
pub async fn read_dma_async<'t, RXBUF>(
&'t mut self,
words: &'t mut RXBUF,
) -> Result<(), Error>
where
RXBUF: WriteBuffer,
{
let (ptr, len) = unsafe { words.write_buffer() };

if !Instance::is_suc_eof_generated_externally() && len > MAX_DMA_SIZE {
return Err(Error::MaxDmaTransferSizeExceeded);
Expand Down
Loading