aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-11-10 12:49:23 -0600
committerxoviat <[email protected]>2025-11-10 12:49:23 -0600
commitff1fb2dd6b9ebc0dd3c7b642f70fbb80a1fd030d (patch)
tree96db68cbfd7c17c019795763e186c982547d2faf /examples
parentc90e4b3135283070bddc6a8e64df3139909ac8ce (diff)
adc: exact cal
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32f334/src/bin/adc.rs4
-rw-r--r--examples/stm32f334/src/bin/opamp.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/examples/stm32f334/src/bin/adc.rs b/examples/stm32f334/src/bin/adc.rs
index a420c8876..486f160ec 100644
--- a/examples/stm32f334/src/bin/adc.rs
+++ b/examples/stm32f334/src/bin/adc.rs
@@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) -> ! {
47 47
48 loop { 48 loop {
49 let vref = adc.read(&mut vrefint, SampleTime::CYCLES601_5).await; 49 let vref = adc.read(&mut vrefint, SampleTime::CYCLES601_5).await;
50 info!("read vref: {} (should be {})", vref, vrefint.value()); 50 info!("read vref: {} (should be {})", vref, vrefint.calibrated_value());
51 51
52 let temp = adc.read(&mut temperature, SampleTime::CYCLES601_5).await; 52 let temp = adc.read(&mut temperature, SampleTime::CYCLES601_5).await;
53 info!("read temperature: {}", temp); 53 info!("read temperature: {}", temp);
@@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) -> ! {
55 let pin = adc.read(&mut p.PA0, SampleTime::CYCLES601_5).await; 55 let pin = adc.read(&mut p.PA0, SampleTime::CYCLES601_5).await;
56 info!("read pin: {}", pin); 56 info!("read pin: {}", pin);
57 57
58 let pin_mv = (pin as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095; 58 let pin_mv = (pin as u32 * vrefint.calibrated_value() as u32 / vref as u32) * 3300 / 4095;
59 info!("computed pin mv: {}", pin_mv); 59 info!("computed pin mv: {}", pin_mv);
60 60
61 Timer::after_millis(500).await; 61 Timer::after_millis(500).await;
diff --git a/examples/stm32f334/src/bin/opamp.rs b/examples/stm32f334/src/bin/opamp.rs
index ddefdd03d..9555fd35d 100644
--- a/examples/stm32f334/src/bin/opamp.rs
+++ b/examples/stm32f334/src/bin/opamp.rs
@@ -50,7 +50,7 @@ async fn main(_spawner: Spawner) -> ! {
50 50
51 loop { 51 loop {
52 let vref = adc.read(&mut vrefint, SampleTime::CYCLES601_5).await; 52 let vref = adc.read(&mut vrefint, SampleTime::CYCLES601_5).await;
53 info!("read vref: {} (should be {})", vref, vrefint.value()); 53 info!("read vref: {} (should be {})", vref, vrefint.calibrated_value());
54 54
55 let temp = adc.read(&mut temperature, SampleTime::CYCLES601_5).await; 55 let temp = adc.read(&mut temperature, SampleTime::CYCLES601_5).await;
56 info!("read temperature: {}", temp); 56 info!("read temperature: {}", temp);
@@ -58,7 +58,7 @@ async fn main(_spawner: Spawner) -> ! {
58 let buffer = adc.read(&mut buffer, SampleTime::CYCLES601_5).await; 58 let buffer = adc.read(&mut buffer, SampleTime::CYCLES601_5).await;
59 info!("read buffer: {}", buffer); 59 info!("read buffer: {}", buffer);
60 60
61 let pin_mv = (buffer as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095; 61 let pin_mv = (buffer as u32 * vrefint.calibrated_value() as u32 / vref as u32) * 3300 / 4095;
62 info!("computed pin mv: {}", pin_mv); 62 info!("computed pin mv: {}", pin_mv);
63 63
64 Timer::after_millis(500).await; 64 Timer::after_millis(500).await;