aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/mspm0g3507/src/bin/adc.rs9
-rw-r--r--examples/mspm0l1306/src/bin/adc.rs9
2 files changed, 6 insertions, 12 deletions
diff --git a/examples/mspm0g3507/src/bin/adc.rs b/examples/mspm0g3507/src/bin/adc.rs
index 73711c75c..ceccc7c02 100644
--- a/examples/mspm0g3507/src/bin/adc.rs
+++ b/examples/mspm0g3507/src/bin/adc.rs
@@ -3,7 +3,7 @@
3 3
4use defmt::*; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_mspm0::adc::{self, Adc, AdcChannel, Vrsel}; 6use embassy_mspm0::adc::{self, Adc, Vrsel};
7use embassy_mspm0::{bind_interrupts, peripherals, Config}; 7use embassy_mspm0::{bind_interrupts, peripherals, Config};
8use embassy_time::Timer; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_halt as _}; 9use {defmt_rtt as _, panic_halt as _};
@@ -19,14 +19,11 @@ async fn main(_spawner: Spawner) -> ! {
19 19
20 // Configure adc with sequence 0 to 1 20 // Configure adc with sequence 0 to 1
21 let mut adc = Adc::new_async(p.ADC0, Default::default(), Irqs); 21 let mut adc = Adc::new_async(p.ADC0, Default::default(), Irqs);
22 let pin1 = p.PA22.degrade_adc(); 22 let sequence = [(&p.PA22.into(), Vrsel::VddaVssa), (&p.PB20.into(), Vrsel::VddaVssa)];
23 let pin2 = p.PB20.degrade_adc();
24 let sequence = [(&pin1, Vrsel::VddaVssa), (&pin2, Vrsel::VddaVssa)];
25 let mut readings = [0u16; 2]; 23 let mut readings = [0u16; 2];
26 let mut pin3 = p.PA27;
27 24
28 loop { 25 loop {
29 let r = adc.read_channel(&mut pin3).await; 26 let r = adc.read_channel(&p.PA27).await;
30 info!("Raw adc PA27: {}", r); 27 info!("Raw adc PA27: {}", r);
31 // With a voltage range of 0-3.3V and a resolution of 12 bits, the raw value can be 28 // With a voltage range of 0-3.3V and a resolution of 12 bits, the raw value can be
32 // approximated to voltage (~0.0008 per step). 29 // approximated to voltage (~0.0008 per step).
diff --git a/examples/mspm0l1306/src/bin/adc.rs b/examples/mspm0l1306/src/bin/adc.rs
index a0c2c0cff..2806b98cc 100644
--- a/examples/mspm0l1306/src/bin/adc.rs
+++ b/examples/mspm0l1306/src/bin/adc.rs
@@ -3,7 +3,7 @@
3 3
4use defmt::*; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_mspm0::adc::{self, Adc, AdcChannel, Vrsel}; 6use embassy_mspm0::adc::{self, Adc, Vrsel};
7use embassy_mspm0::{bind_interrupts, peripherals, Config}; 7use embassy_mspm0::{bind_interrupts, peripherals, Config};
8use embassy_time::Timer; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_halt as _}; 9use {defmt_rtt as _, panic_halt as _};
@@ -19,14 +19,11 @@ async fn main(_spawner: Spawner) -> ! {
19 19
20 // Configure adc with sequence 0 to 1 20 // Configure adc with sequence 0 to 1
21 let mut adc = Adc::new_async(p.ADC0, Default::default(), Irqs); 21 let mut adc = Adc::new_async(p.ADC0, Default::default(), Irqs);
22 let pin1 = p.PA22.degrade_adc(); 22 let sequence = [(&p.PA22.into(), Vrsel::VddaVssa), (&p.PA20.into(), Vrsel::VddaVssa)];
23 let pin2 = p.PA20.degrade_adc();
24 let sequence = [(&pin1, Vrsel::VddaVssa), (&pin2, Vrsel::VddaVssa)];
25 let mut readings = [0u16; 2]; 23 let mut readings = [0u16; 2];
26 let mut pin3 = p.PA27;
27 24
28 loop { 25 loop {
29 let r = adc.read_channel(&mut pin3).await; 26 let r = adc.read_channel(&p.PA27).await;
30 info!("Raw adc PA27: {}", r); 27 info!("Raw adc PA27: {}", r);
31 // With a voltage range of 0-3.3V and a resolution of 12 bits, the raw value can be 28 // With a voltage range of 0-3.3V and a resolution of 12 bits, the raw value can be
32 // approximated to voltage (~0.0008 per step). 29 // approximated to voltage (~0.0008 per step).