Consider splitting SPI API into separate parts for sending/receiving
I believe that my original design for the SPI API isn't quite optimal. The current architecture works well enough for non-DMA uses, and I've managed to make it work with DMA too. But implementing send_all and receive_all, i.e. using DMA for only sending or receiving, will require additional changes to spi::Transfer, making everything more complicated.
I believe the following design would be better: Split the API into separate parts for sending and receiving, like this (pseudocode):
pub struct SPI {
pub rx: Rx,
pub tx: Tx,
// other private fields
}
In this model, Rx would have a read_all method and Tx would have a write_all method, that would use the DMA in a simple way, pretty much like USART does too. SPI would still have transfer_all and the FullDuplex implementation.
spi::Transfer would have to stay as it is (no way around that, I believe), but at least this would allow for methods like write_all, without adding DMA wrappers to the SPI module.
I will look into this the next time I work on that code, but don't have any plans right now for when/if that might happen. If anyone else wants to pick this up, please go ahead!