-
Notifications
You must be signed in to change notification settings - Fork 102
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
How to perform SPI write before starting DMA transfer? #472
Comments
I'm this situation, why wouldn't you just use DMA to send the command as
well as the data? It seems simpler to me (in C as well as Rust) to set up
the SPI and DMA peripherals to work together, then send one short DMA
transfer with the command, followed by a longer DMA transfer with the data.
…On Tue, Nov 28, 2023, 11:08 PM Joshua Bassett ***@***.***> wrote:
Is it possible to do a normal SPI write before starting a DMA transfer?
For example, in the SPI RTIC example
<https://github.com/stm32-rs/stm32h7xx-hal/blob/master/examples/spi-dma-rtic.rs#L160-L170>
it would be nice to be able to do something like this:
transfer.start(|spi| {
// Write a command before beginning the transfer
cs.set_low();
dc.set_low();
spi.write(&[0x11u8, 0x22, 0x33]);
cs.set_high();
dc.set_high();
// Write frame buffer using DMA transfer
cs.set_low();
spi.enable_dma_tx();
spi.inner_mut().cr1.modify(|_, w| w.spe().enabled());
spi.inner_mut().cr1.modify(|_, w| w.cstart().started());});
I am trying to use DMA to write the frame buffer to an OLED display
(SSD1322), but I need to write a couple of commands to the display before
sending the data.
Any suggestions?
—
Reply to this email directly, view it on GitHub
<#472>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUS5FPZTCV4ZDKCWZ7O6BLYG27LZAVCNFSM6AAAAAA763CRKWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYTKOBSHAYTIMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@mlamoore Thanks for the reply. I need to send 3 commands to the display (row address, column address, write enable) before sending the frame buffer data. Sending the commands and frame buffer with DMA would require extra state so the interrupt handler knows what to do next. e.g. The DC signal needs to be asserted for data, and deasserted for commands. The CS signal needs to be asserted/deasserted for each transaction. In C, this is three blocking |
@mlamoore Hi again. I am still looking for a solution. Do you know of any examples of how to do multiple DMA transfers, like you suggested? Does this require freeing each DMA transfer when it is complete to gain access to the resources (i.e. SPI instance) and start another transfer? |
Is it possible to do a normal SPI write before starting a DMA transfer?
I am trying to use DMA to write the frame buffer to an OLED display (SSD1322), but I need to write a couple of commands to the display before sending the pixel data.
For example, building on the SPI DMA example it would be nice to be able to do something like this:
Unfortunately the types make this impossible, as the SPI reference passed to the closure is disabled.
Any suggestions?
It would be nice to just use a similar API to the I2C DMA example:
The text was updated successfully, but these errors were encountered: