Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DMA RX and RX/TX support to SPI #335

Merged
merged 6 commits into from
Jul 14, 2021
Merged

Conversation

Windfisch
Copy link
Contributor

Implements #200

SPI is a bit different from most other DMA-supporting peripherals, since SPI in master mode cannot receive without transmitting simultaneously. After some discussion in the #rust-embedded irc channel, we came to the conclusion that split()ting the device (like with serial) does not make much sense, because sending and receiving are inherently tied to each other; that made it necessary to finish the implementation of the already-existing (but unused) RxTxDma struct from dma.rs and add required traits.

This PR does that and adds an RxTxDma implementation to the SPI module.

Because in slave mode, this might(?) be still possible to receive without transmitting, I left the RxDma implementations in, but I am yet unsure about this.

Please do tell me if you have any suggestions :).

@Windfisch
Copy link
Contributor Author

@Windfisch
Copy link
Contributor Author

I added a release function that allows to undo with_tx_dma etc. Also, the location of setting the actual DMA bits was changed from SpiTxDma::start to with_tx_dma.

@burrbull
Copy link
Member

What about add more type aliases?
Something like

pub type Spi1TxDma<REMAP, PINS> = SpiTxDma<SPI1, REMAP, PINS, dma::C3>;

@burrbull
Copy link
Member

And do we really need SpiPayload wrapper?

@Windfisch
Copy link
Contributor Author

nope, the SpiPayload wrapper was rather useless; I have removed it and added the type aliases you suggested

@burrbull
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 14, 2021

@bors bors bot merged commit c756888 into stm32-rs:master Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants