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

embassy_stm32: How to send a large amount of the same data using SPI? #3399

Open
jmjoy opened this issue Oct 7, 2024 · 2 comments
Open

embassy_stm32: How to send a large amount of the same data using SPI? #3399

jmjoy opened this issue Oct 7, 2024 · 2 comments

Comments

@jmjoy
Copy link

jmjoy commented Oct 7, 2024

I am using an SPI LCD screen, one of the operations is to full the screen, which is actually writing the same color data as the number of pixels on the screen.

Using the SPL library, the SPI DMA channel can be set up like this:

DMA_InitTypeDef DMA_InitStructure;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
// ...
DMA_Init(DMA_CHx, &DMA_InitStructure);

Because the memory address does not increase, the specified amount of the same data will be written to MOSI.

But I can't find a similar method in embassy_stm32::spi::Spi. It can be done using write, but if the screen pixels are large, the stack will explode, and using the heap is not advisable.

I hope there will be something like:

async fn write_n(&mut self, data: Word, n: usize) -> Result<(), Self::Error>;
@showier-drastic
Copy link
Contributor

You can open a relatively small array (such as 32bytes), and send it repeatedly.

@jmjoy
Copy link
Author

jmjoy commented Oct 8, 2024

You can open a relatively small array (such as 32bytes), and send it repeatedly.

This is a good solution for the current situation.

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

No branches or pull requests

2 participants