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
esp-rs#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 and AnthonyGrondin committed Aug 8, 2024
1 parent efdc0f5 commit 465d84d
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 @@ -28,6 +28,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 465d84d

Please sign in to comment.