fixed properly
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
source [find interface/stlink.cfg]
|
||||
transport select hla_swd
|
||||
source [find target/stm32u5x.cfg]
|
||||
reset_config srst_only srst_nogate connect_assert_srst
|
||||
5
hal_adc/rust-toolchain.toml
Normal file
5
hal_adc/rust-toolchain.toml
Normal file
@@ -0,0 +1,5 @@
|
||||
# rust-toolchain.toml
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
components = ["rust-src", "rustfmt", "clippy"]
|
||||
targets = ["thumbv8m.main-none-eabihf"]
|
||||
@@ -23,6 +23,15 @@ async fn main(_spawner: embassy_executor::Spawner) {
|
||||
adc1.set_sample_time(adc::SampleTime::CYCLES160_5);
|
||||
let max1 = adc::resolution_to_max_count(adc::Resolution::BITS14);
|
||||
|
||||
// **** ADC2 init ****
|
||||
let mut adc2 = adc::Adc::new(p.ADC2);
|
||||
let mut adc2_pin1 = p.PC3; // A2
|
||||
let mut adc2_pin2 = p.PB0; // A3
|
||||
adc2.set_resolution(adc::Resolution::BITS14);
|
||||
adc2.set_averaging(adc::Averaging::Samples1024);
|
||||
adc2.set_sample_time(adc::SampleTime::CYCLES160_5);
|
||||
let max2 = adc::resolution_to_max_count(adc::Resolution::BITS14);
|
||||
|
||||
// **** ADC4 init ****
|
||||
let mut adc4 = adc4::Adc4::new(p.ADC4);
|
||||
let mut adc4_pin1 = p.PC1; // A4
|
||||
@@ -41,6 +50,15 @@ async fn main(_spawner: embassy_executor::Spawner) {
|
||||
let volt: f32 = 3.3 * raw as f32 / max1 as f32;
|
||||
info!("Read adc1 pin 2 {}", volt);
|
||||
|
||||
// **** ADC2 blocking read ****
|
||||
let raw: u16 = adc2.blocking_read(&mut adc2_pin1);
|
||||
let volt: f32 = 3.3 * raw as f32 / max2 as f32;
|
||||
info!("Read adc2 pin 1 {}", volt);
|
||||
|
||||
let raw: u16 = adc2.blocking_read(&mut adc2_pin2);
|
||||
let volt: f32 = 3.3 * raw as f32 / max2 as f32;
|
||||
info!("Read adc2 pin 2 {}", volt);
|
||||
|
||||
// **** ADC4 blocking read ****
|
||||
let raw: u16 = adc4.blocking_read(&mut adc4_pin1);
|
||||
let volt: f32 = 3.3 * raw as f32 / max4 as f32;
|
||||
|
||||
Reference in New Issue
Block a user