Skip to content

Commit

Permalink
SPI: Clear DMA interrupts before (not after) DMA starts (esp-rs#1859)
Browse files Browse the repository at this point in the history
* SPI: Clear DMA interrupts before (not after) DMA starts

* Fix Rust 1.80 doc thingy

---------

Co-authored-by: Dominic Fischer <[email protected]>
  • Loading branch information
Dominaezzz and Dominic Fischer authored Jul 26, 2024
1 parent c6207c0 commit 2744a5d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improve error detection in the I2C driver (#1847)
- Fix I2S async-tx (#1833)
- Fix PARL_IO async-rx (#1851)
- SPI: Clear DMA interrupts before (not after) DMA starts (#1859)

### Removed

Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/otg_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ pub mod asynch {
///
/// * `ep_out_buffer` - An internal buffer used to temporarily store
/// received packets.
///
/// Must be large enough to fit all OUT endpoint max packet sizes.
/// Endpoint allocation will fail if it is too small.
pub fn new(_peri: Usb<'d>, ep_out_buffer: &'d mut [u8], config: Config) -> Self {
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/soc/esp32/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
//! two different banks:
//! * `InterruptStatusRegisterAccessBank0`
//! * `InterruptStatusRegisterAccessBank1`.
//!
//! This trait provides functions to read the interrupt status and NMI status
//! registers for both the `PRO CPU` and `APP CPU`. The implementation uses the
//! `gpio` peripheral to access the appropriate registers.
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/soc/esp32s2/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
//! two different banks:
//! * `InterruptStatusRegisterAccessBank0`
//! * `InterruptStatusRegisterAccessBank1`.
//!
//! This trait provides functions to read the interrupt status and NMI status
//! registers for both the `PRO CPU` and `APP CPU`. The implementation uses the
//! `gpio` peripheral to access the appropriate registers.
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/soc/esp32s3/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
//! two different banks:
//! * `InterruptStatusRegisterAccessBank0`
//! * `InterruptStatusRegisterAccessBank1`.
//!
//! This trait provides functions to read the interrupt status and NMI status
//! registers for both the `PRO CPU` and `APP CPU`. The implementation uses the
//! `gpio` peripheral to access the appropriate registers.
Expand Down
6 changes: 3 additions & 3 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2036,14 +2036,14 @@ where
self.update();

reset_dma_before_load_dma_dscr(reg_block);
self.clear_dma_interrupts();
tx_chain.fill_for_tx(false, write_buffer_ptr, write_buffer_len)?;
tx.prepare_transfer_without_start(self.dma_peripheral(), tx_chain)
.and_then(|_| tx.start_transfer())?;
rx_chain.fill_for_rx(false, read_buffer_ptr, read_buffer_len)?;
rx.prepare_transfer_without_start(self.dma_peripheral(), rx_chain)
.and_then(|_| rx.start_transfer())?;

self.clear_dma_interrupts();
reset_dma_before_usr_cmd(reg_block);

reg_block.cmd().modify(|_, w| w.usr().set_bit());
Expand Down Expand Up @@ -2086,13 +2086,13 @@ where
self.update();

reset_dma_before_load_dma_dscr(reg_block);
self.clear_dma_interrupts();
chain.fill_for_tx(false, ptr, len)?;
unsafe {
tx.prepare_transfer_without_start(self.dma_peripheral(), chain)
.and_then(|_| tx.start_transfer())?;
}

self.clear_dma_interrupts();
reset_dma_before_usr_cmd(reg_block);

reg_block.cmd().modify(|_, w| w.usr().set_bit());
Expand All @@ -2117,11 +2117,11 @@ where
self.update();

reset_dma_before_load_dma_dscr(reg_block);
self.clear_dma_interrupts();
chain.fill_for_rx(false, ptr, len)?;
rx.prepare_transfer_without_start(self.dma_peripheral(), chain)
.and_then(|_| rx.start_transfer())?;

self.clear_dma_interrupts();
reset_dma_before_usr_cmd(reg_block);

reg_block.cmd().modify(|_, w| w.usr().set_bit());
Expand Down

0 comments on commit 2744a5d

Please sign in to comment.