Skip to content

Commit

Permalink
parl_io: use ReadBuffer/WriteBuffer for async DMA (#1996)
Browse files Browse the repository at this point in the history
* parl_io: use ReadBuffer/WriteBuffer for async DMA

* CHANGELOG
  • Loading branch information
liebman authored Aug 26, 2024
1 parent b4ccb35 commit 5f0dc14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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

0 comments on commit 5f0dc14

Please sign in to comment.