Open pdgilbert opened 3 years ago
I think this is out of scope for this crate, we provide the safety requirements of each trait, but the specifics of each design is left for the downstream implementers.
I was beginning to fear that was the case. But what is the mechanism for encouraging the different stm32*-hal
's to use a common api? Is it just accident that they all use read
and write
for character-by-character serial input and output or is that because the api is dictated in embedded-hal
or somewhere else? (And where would be a better place to ask this question, because this is probably not the right place?) Thanks, and sorry I am still suffering from newbie confusion.
I think it would be hard to come up with a good interface that would work nicely with all the different DMA hardware out there. embedded-hal
would be a good place for that interface, or maybe even this crate. However, as of today, I'm unaware of such interface.
I have been working on some examples using different
setup()
functions for differentstm32*xx_hals
and then common application code. Some time ago I put aside the serial dma examples because the different hal approaches were too different. Now these examples are some of the few I have not got working (scoreboard at https://pdgilbert.github.io/eg_stm_hal/), and I think there has been some progress adoptingembedded-dma
as a common approach.Unfortunately, there do not seem to be examples in any of the hals that I am able to recognize as representing the new approach. Below is code that works with
stm32f3xx_hal
and thesetup()
part works withstm32f1xx_hal
.stm32f3xx_hal
provides buffer using methodsread_exact()
andwrite_all()
which are used in the code below. Those methods are not provided by other hals and seem rather messy because the application code has to deal explicitly with the buffers rather than hiding them inside TxDma and RxDma objects. I think I should be using something like ReadDma and WriteDma but I am not sure.Is there a method that is or might become available in all
stm32*xx_hal
s?Which hals have implemented current best practice?
Is there a good example of buffered read and write using current best practice?
I think my setup functions should be able to return buffered version of Tx and Rx. Previously I had it working that way with
stm32f1xx_hal
using something liketx1.with_dma(channels.4)
andrx1.with_dma(channels.5)
but I thought the hal was not usingembedded-dma
at the time and the.with_dma()
method was not available in other hals.What is the object I should be looking to return and what is the method to set it up?
Can my setup functions use some
impl trait
to find the return value type for these objects, and what traits should I be using?Thanks for any insight. (I'm still a newbie so details are useful.)