-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Description
Hi, I'm trying to run a ADC multichannel (scan mode) continuous conversion. I dig into the code to check current status:
Continuous conversion: set cont() bit on start()
Lines 558 to 568 in 89600ec
| impl<PINS> TransferPayload for AdcDma<PINS, Continuous> { | |
| fn start(&mut self) { | |
| self.channel.start(); | |
| self.payload.adc.rb.cr2.modify(|_, w| w.cont().set_bit()); | |
| self.payload.adc.rb.cr2.modify(|_, w| w.adon().set_bit()); | |
| } | |
| fn stop(&mut self) { | |
| self.channel.stop(); | |
| self.payload.adc.rb.cr2.modify(|_, w| w.cont().clear_bit()); | |
| } | |
| } |
Scan conversion: not setting cont() bit on start() clear cont() explicitly on initialization. It is definitely not intended for continuous conversion.
Lines 608 to 617 in 89600ec
| self.rb.cr2.modify(|_, w| { | |
| w.adon() | |
| .clear_bit() | |
| .dma() | |
| .clear_bit() | |
| .cont() | |
| .clear_bit() | |
| .align() | |
| .bit(self.align.into()) | |
| }); |
I think there are several ways to support continuous scan conversion mode:
- I could add quick and dirty fix by introducing
ContinuousScanstruct (orstruct Scan { continuous: bool }if it's okay to break API), but I'm not sure if it's a right way. - I could think of generalized struct/trait which covers single/multichannel one-shot/continuous conversion scenario. Single-channel conversion could be treated as a special case of multichannel conversion anyway.
Metadata
Metadata
Assignees
Labels
No labels