Skip to content

Commit

Permalink
ESP32(SPI): Disable the write side when reading is being done in DMA … (
Browse files Browse the repository at this point in the history
#1894)

* ESP32(SPI): Disable the write side when reading is being done in DMA mode

* disable and re-enable MISO and MOSI in write and transfer methods

* changelog
  • Loading branch information
JurajSadel authored Aug 7, 2024
1 parent 56d8d58 commit 54ee364
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix I2S async-tx (#1833)
- Fix PARL_IO async-rx (#1851)
- SPI: Clear DMA interrupts before (not after) DMA starts (#1859)
- SPI: disable and re-enable MISO and MOSI in `start_transfer_dma`, `start_read_bytes_dma` and `start_write_bytes_dma` accordingly (#1894)

### Removed

Expand Down
15 changes: 15 additions & 0 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,11 @@ where
tx.is_done();
rx.is_done();

// re-enable the MISO and MOSI
reg_block
.user()
.modify(|_, w| w.usr_miso().bit(true).usr_mosi().bit(true));

self.enable_dma();
self.update();

Expand Down Expand Up @@ -2082,6 +2087,11 @@ where

tx.is_done();

// disable MISO and re-enable MOSI
reg_block
.user()
.modify(|_, w| w.usr_miso().bit(false).usr_mosi().bit(true));

self.enable_dma();
self.update();

Expand Down Expand Up @@ -2113,6 +2123,11 @@ where

rx.is_done();

// re-enable MISO and disable MOSI
reg_block
.user()
.modify(|_, w| w.usr_miso().bit(true).usr_mosi().bit(false));

self.enable_dma();
self.update();

Expand Down

0 comments on commit 54ee364

Please sign in to comment.