Closed victorandrehc closed 2 months ago
gently pokes @chris-durand
Totally forgot about this one … Will look at it tomorrow.
@victorandrehc I've pushed some changes to modify the driver in a way that it also supports DMA and conversion sequences on STM32F0. Could you check if the change would be acceptable for your use case?
The changed API additionally supports another sequence mode where the channels to be converted are specified as a bit mask. That's the only method available on F0 or if you need channels 16-18 to be part of the sequence or the length is bigger than 8.
The enableScanMode()
and disableScanMode()
methods are not required anymore and channels are configured using the following three functions:
single channel mode:
bool setChannel(Channel channel);
in-order sequence conversion mode with CHSELRMOD:
bool setChannels(std::span<const Channel> channels);
sequence conversion mode specified as mask:
bool setChannels(ChannelMask_t channels);
@chris-durand I am going to review this later this week (probably on Wednesday)
Hi @chris-durand after some careful analysis we think your suggestion suit us fine.
Hi @chris-durand, is there anything i can do to help you merging this PR?
Hi @victorandrehc,
thanks for the reminder and sorry for the long wait. I did some more minor clean-up and consider this ready to merge in the current state. My original intention was to add and test an additional F0 DMA example but I was busier than expected and didn't find the time. We can merge this without it.
One last thing I felt I had to change was the naming of the enableDmaRequests()
/ disableDmaRequests()
methods. The name suggests that disableDmaRequests()
would completely disable the generation of DMA requests, but it actually doesn't. It configures whether requests would still be generated after DMA transfer completion for DMA circular mode. As a reader of application code who isn't familiar with the driver implementation it would be hard to understand that from the function names.
To clean this up I'd suggest replacing enableDmaRequests()
, disableDmaRequests()
, enableDmaMode()
, disableDmaMode()
with a single setDmaMode(mode)
function that takes a DmaMode
enum parameter with the values Disabled
, OneShot
and Circular
like in the F3/G4/H7 driver. That also prevents erroneously setting enableDmaRequests()
without enabling DMA. I've pushed that change as an additional commit. Would you be fine with it? If yes, we can go ahead and merge.
I'm kind of confident I didn't break anything but if a short hardware test is easy for you I'd appreciate it.