aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-07-27 12:41:03 +0000
committerGitHub <[email protected]>2022-07-27 12:41:03 +0000
commit9af68e005b91a35d1c741bc1d6e90f9c43be18b9 (patch)
treeb97ffb2faca69b532a3743d505ef65df49ce7716 /examples
parentc0496f8bbe60f7badf17389c13804be8b8d8de8a (diff)
parent42434c75bc3472173cb71df14cc22899fb140ece (diff)
Merge #879
879: Improve ADC configuration options r=Dirbaio a=chemicstry This smooths out a few rough edges with ADC: - Make `Resolution::to_max_count()` pub for all ADC versions. Useful if performing conversion manually. - `VREF` and `VREFINT` were convoluted. `VREF` is an external voltage reference used for all ADC conversions and it is exposed as a separate pin on large chips, while on smaller ones it is connected to `VDDA` internally. `VREFINT` is an internal voltage reference connected to one of the ADC channels and can be used to calculate unknown `VREF` voltage. - Add a separate `VREF_DEFAULT_MV`, equal to 3.3V, which is the usual supply voltage and should work for most simple cases. - For an external voltage reference `set_vref()` can be used to set a known precise voltage. - If no voltage reference is present, `VREFINT` calibration can be used to calculate unknown `VREF` voltage. If I understand correctly, this is only implemented for `adc_v3` (L4?), but is not currently exposed (private). If someone is interested, this can be fixed in separate PR. Co-authored-by: chemicstry <[email protected]>
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32h7/src/bin/adc.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs
index ce73364c0..d8a5d23d7 100644
--- a/examples/stm32h7/src/bin/adc.rs
+++ b/examples/stm32h7/src/bin/adc.rs
@@ -28,11 +28,11 @@ async fn main(_spawner: Spawner, mut p: Peripherals) {
28 28
29 adc.set_sample_time(SampleTime::Cycles32_5); 29 adc.set_sample_time(SampleTime::Cycles32_5);
30 30
31 let mut vref_channel = adc.enable_vref(); 31 let mut vrefint_channel = adc.enable_vrefint();
32 32
33 loop { 33 loop {
34 let vref = adc.read_internal(&mut vref_channel); 34 let vrefint = adc.read_internal(&mut vrefint_channel);
35 info!("vref: {}", vref); 35 info!("vrefint: {}", vrefint);
36 let measured = adc.read(&mut p.PC0); 36 let measured = adc.read(&mut p.PC0);
37 info!("measured: {}", measured); 37 info!("measured: {}", measured);
38 Timer::after(Duration::from_millis(500)).await; 38 Timer::after(Duration::from_millis(500)).await;