stm32f0xx-hal icon indicating copy to clipboard operation
stm32f0xx-hal copied to clipboard

implement FullDuplex for Spi

Open dkm opened this issue 4 years ago • 15 comments

This is a very simple impl for FullDuplex. The Transfer impl could be removed in favor of the default that is available by the availability of FullDuplex.

dkm avatar Nov 03 '20 19:11 dkm

Looks like it's not working, will push a correct version later :)

dkm avatar Nov 03 '20 19:11 dkm

Not 100% sure it's the best way to implement, but as far as I could test, it works (tested with ws2812-spi and a 10 leds chain). If you think some refactoring can be done, do not hesitate, happy to learn and implement :)

dkm avatar Nov 03 '20 20:11 dkm

I've tried to implement the check_errors. I'm not 100% sure my usage of nb::Result / Result is the best (or at least the more idiomatic). I've made it return a Result as it's not dealing with blocking anymore, but maybe that was not a good idea. Let me know if you think I should do it differently !

dkm avatar Nov 15 '20 13:11 dkm

Thanks for the help ! Also, I've left the Transfer impl as relying on the FullDuplex would cause set_bidi to be called for every byte in a mult-byte transfer... Not sure if this overhead is a problem or not, so I left the custom Transfer impl as-is.

dkm avatar Nov 16 '20 11:11 dkm

Has anyone had a chance to test those changes in real life yet?

therealprof avatar Nov 17 '20 19:11 therealprof

I guess I could hookup a nRF24L01, capture some exchanges with analyzer to provide some better test if nobody can test this with an easier setup ? I don't have anything else (except for the ws2812 I'm using that motivated this change)

dkm avatar Nov 19 '20 10:11 dkm

Sorry, I forgot to think this through. I don't have anything to test besides this ws2812 setup as all my F0 are soldered on my keyboards, so there's no way I can monitor sck and miso pins...

dkm avatar Dec 09 '20 11:12 dkm

If you design a test scenario, I have a lot of hardware to test on.

matoushybl avatar Dec 10 '20 09:12 matoushybl

Sorry, I forgot to think this through. I don't have anything to test besides this ws2812 setup as all my F0 are soldered on my keyboards, so there's no way I can monitor sck and miso pins...

If you design a test scenario, I have a lot of hardware to test on.

back on this... I was hoping I could find some f0, but found none :/. I can try to write a small program so you only need to wire something, compile and load ? Do you have some nrf24lo1 ? I could execute the program on another mcu to check it works and let you see if it's works similarly on f0?

dkm avatar Jan 13 '21 17:01 dkm

Sure, no problem. I believe that I have the NRF so there should be no problems.

I believe that the peripheral on F4 is similar, so that you can debug on it and then send it to me to try out on the F0.

matoushybl avatar Jan 14 '21 16:01 matoushybl

even better, I have some brand new f4 here!

dkm avatar Jan 14 '21 17:01 dkm

Hi. What is the status on this? Can I help in any way?

easybe avatar Oct 23 '22 11:10 easybe

@easybe Seems dormant to me. If you can test it, we can certainly get it merged.

therealprof avatar Oct 23 '22 11:10 therealprof

OK, I should be able to do that.

easybe avatar Oct 23 '22 12:10 easybe

Sorry, still haven't anything to test, but am using the code daily in a keyboard without any issue, so should be OK. Thanks Ezra if you can help with the testing.

dkm avatar Oct 23 '22 12:10 dkm