diff --git a/CHANGELOG.md b/CHANGELOG.md index 71d1a91a9..05ea4dcf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add some miscellaneous examples for the ESP32-H2 (#548) - Add initial support for PCNT in ESP32-H2 (#551) - Add initial support for RMT in ESP32-H2 (#556) +- Add a fn to poll DMA transfers ### Fixed diff --git a/esp32-hal/examples/spi_loopback_dma.rs b/esp32-hal/examples/spi_loopback_dma.rs index 283cd147c..548716094 100644 --- a/esp32-hal/examples/spi_loopback_dma.rs +++ b/esp32-hal/examples/spi_loopback_dma.rs @@ -98,6 +98,13 @@ fn main() -> ! { let transfer = spi.dma_transfer(send, receive).unwrap(); // here we could do something else while DMA transfer is in progress + let mut i = 0; + // Check is_done until the transfer is almost done (32000 bytes at 100kHz is + // 2.56 seconds), then move to wait(). + while !transfer.is_done() && i < 10 { + delay.delay_ms(250u32); + i += 1; + } // the buffers and spi is moved into the transfer and we can get it back via // `wait` (receive, send, spi) = transfer.wait(); diff --git a/esp32c2-hal/examples/spi_loopback_dma.rs b/esp32c2-hal/examples/spi_loopback_dma.rs index 79743740d..529ec1b0c 100644 --- a/esp32c2-hal/examples/spi_loopback_dma.rs +++ b/esp32c2-hal/examples/spi_loopback_dma.rs @@ -99,6 +99,13 @@ fn main() -> ! { let transfer = spi.dma_transfer(send, receive).unwrap(); // here we could do something else while DMA transfer is in progress + let mut i = 0; + // Check is_done until the transfer is almost done (32000 bytes at 100kHz is + // 2.56 seconds), then move to wait(). + while !transfer.is_done() && i < 10 { + delay.delay_ms(250u32); + i += 1; + } // the buffers and spi is moved into the transfer and we can get it back via // `wait` (receive, send, spi) = transfer.wait(); diff --git a/esp32c3-hal/examples/spi_loopback_dma.rs b/esp32c3-hal/examples/spi_loopback_dma.rs index 8bc8910fb..f612b8601 100644 --- a/esp32c3-hal/examples/spi_loopback_dma.rs +++ b/esp32c3-hal/examples/spi_loopback_dma.rs @@ -106,6 +106,13 @@ fn main() -> ! { let transfer = spi.dma_transfer(send, receive).unwrap(); // here we could do something else while DMA transfer is in progress + let mut i = 0; + // Check is_done until the transfer is almost done (32000 bytes at 100kHz is + // 2.56 seconds), then move to wait(). + while !transfer.is_done() && i < 10 { + delay.delay_ms(250u32); + i += 1; + } // the buffers and spi is moved into the transfer and we can get it back via // `wait` (receive, send, spi) = transfer.wait(); diff --git a/esp32c6-hal/examples/spi_loopback_dma.rs b/esp32c6-hal/examples/spi_loopback_dma.rs index 945a62bcf..7f72e664d 100644 --- a/esp32c6-hal/examples/spi_loopback_dma.rs +++ b/esp32c6-hal/examples/spi_loopback_dma.rs @@ -107,6 +107,13 @@ fn main() -> ! { let transfer = spi.dma_transfer(send, receive).unwrap(); // here we could do something else while DMA transfer is in progress + let mut i = 0; + // Check is_done until the transfer is almost done (32000 bytes at 100kHz is + // 2.56 seconds), then move to wait(). + while !transfer.is_done() && i < 10 { + delay.delay_ms(250u32); + i += 1; + } // the buffers and spi is moved into the transfer and we can get it back via // `wait` (receive, send, spi) = transfer.wait(); diff --git a/esp32s2-hal/examples/spi_loopback_dma.rs b/esp32s2-hal/examples/spi_loopback_dma.rs index 0f64b55b8..15df558e9 100644 --- a/esp32s2-hal/examples/spi_loopback_dma.rs +++ b/esp32s2-hal/examples/spi_loopback_dma.rs @@ -98,6 +98,13 @@ fn main() -> ! { let transfer = spi.dma_transfer(send, receive).unwrap(); // here we could do something else while DMA transfer is in progress + let mut i = 0; + // Check is_done until the transfer is almost done (32000 bytes at 100kHz is + // 2.56 seconds), then move to wait(). + while !transfer.is_done() && i < 10 { + delay.delay_ms(250u32); + i += 1; + } // the buffers and spi is moved into the transfer and we can get it back via // `wait` (receive, send, spi) = transfer.wait(); diff --git a/esp32s3-hal/examples/spi_loopback_dma.rs b/esp32s3-hal/examples/spi_loopback_dma.rs index 0e2b6d9c6..f71b5e21c 100644 --- a/esp32s3-hal/examples/spi_loopback_dma.rs +++ b/esp32s3-hal/examples/spi_loopback_dma.rs @@ -106,6 +106,13 @@ fn main() -> ! { let transfer = spi.dma_transfer(send, receive).unwrap(); // here we could do something else while DMA transfer is in progress + let mut i = 0; + // Check is_done until the transfer is almost done (32000 bytes at 100kHz is + // 2.56 seconds), then move to wait(). + while !transfer.is_done() && i < 10 { + delay.delay_ms(250u32); + i += 1; + } // the buffers and spi is moved into the transfer and we can get it back via // `wait` (receive, send, spi) = transfer.wait();