#[non_exhaustive]pub enum ConversionMode {
Single,
Continuous,
Discontinuous(u8),
}Expand description
The conversion mode the ADC peripheral is operating in.
The Adc can be configured through Adc::set_conversion_mode and obtained via
Adc::conversion_mode.
A conversion is either started by Adc::start_conversion,
or by an external trigger (ExternalTrigger).
§TLDR
ConversionMode::Singleonce triggered goes through the whole sequence then stops.ConversionMode::Continuousonce triggered goes through the whole sequence and repeats that process until activly stopped (e.g. by calling [Adc::start_conversion.]ConversionMode::Single)ConversionMode::Discontinuousonce triggered goes through part of the sequence in the specified step widthn + 1and has to be activly triggered to continue.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Single
In Single conversion mode, the ADC performs once all the conversions of the channels.
§Start Conditions
Inside the regular sequence, after each conversion is complete:
- The converted data are stored into the 16-bit data register
- The
Event::EndOfConversionevent is set. - An interrupt is generated if an interrupt is enabled for
Event::EndOfConversion. (Adc::enable_interrupt)
After the regular sequence is complete:
- The
Event::EndOfSequenceevent is set. - An interrupt is generated if an interrupt is enabled for
Event::EndOfSequence. (Adc::enable_interrupt)
Continuous
In continuous conversion mode, when a software or hardware regular trigger event occurs, the ADC performs once all the regular conversions of the channels and then automatically re-starts and continuously converts each conversions of the sequence.
§Note
This mode applies to regular channls only.
§Start conditions
Inside the regular sequence, after each conversion is complete:
- The converted data are stored into the 16-bit data register
- The
Event::EndOfConversionevent is set. - An interrupt is generated if an interrupt is enabled for
Event::EndOfConversion. (Adc::enable_interrupt)
After the sequence of conversions is complete:
- The
Event::EndOfSequenceevent is set. - An interrupt is generated if an interrupt is enabled for
Event::EndOfSequence. (Adc::enable_interrupt)
Discontinuous(u8)
It is used to convert a short sequence (sub-group) of n + 1 conversions (n ≤ 8) that is
part of the sequence of conversions selected via Adc::set_channel_sequence. The value
is specified by the associated enum value Discontinuous(n).
When an ExternalTrigger occurs, it starts the next n + 1 conversions selected with
Adc::set_channel_sequence registers until all the conversions in the sequence
are done. The total sequence length is defined by Adc::set_sequence_length
§Example
§Discontinuous(2)
Channels to be converted = 1, 2, 3, 6, 7, 8, 9, 10, 11
- 1st trigger:
- channels converted are 1, 2, 3 (an
Event::EndOfConversionis generated at each conversion).
- channels converted are 1, 2, 3 (an
- 2nd trigger:
- channels converted are 6, 7, 8 (an
Event::EndOfConversionis generated at each conversion).
- channels converted are 6, 7, 8 (an
- 3rd trigger:
- channels converted are 9, 10, 11 (an
Event::EndOfConversionis generated at each conversion) and anEvent::EndOfSequenceevent is generated after the conversion of channel 11.
- channels converted are 9, 10, 11 (an
- 4th trigger:
- channels converted are 1, 2, 3 (an
Event::EndOfConversionis generated at each conversion).
- channels converted are 1, 2, 3 (an
- …
§Continuous
Channels to be converted = 1, 2, 3, 6, 7, 8, 9, 10,11
- 1st trigger:
- The complete sequence is converted: channel 1, then 2, 3, 6, 7, 9, 10
and 11. Each conversion generates an
Event::EndOfConversionevent and the last one also generates anEvent::EndOfSequenceevent. – All the next trigger events will relaunch the complete sequence
- The complete sequence is converted: channel 1, then 2, 3, 6, 7, 9, 10
and 11. Each conversion generates an
§Note
When a regular group is converted in ConversionMode::Discontinuous, no rollover occurs
(the last subgroup of the sequence can have less than n conversions).
When all subgroups are converted, the next trigger starts the conversion of the first subgroup.
In the example above, the 4th trigger reconverts the channels 1, 2 and 3 in the 1st subgroup.
Trait Implementations§
Source§impl Clone for ConversionMode
impl Clone for ConversionMode
Source§fn clone(&self) -> ConversionMode
fn clone(&self) -> ConversionMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more