Merge pull request #3044 from kalkyl/adc-multi

rp: Add multichannel ADC
This commit is contained in:
Henrik Alsér
2024-06-22 21:05:17 +00:00
committed by GitHub
3 changed files with 135 additions and 5 deletions

View File

@@ -130,6 +130,19 @@ async fn main(_spawner: Spawner) {
defmt::assert!(temp.iter().all(|t| *t > 0.0));
defmt::assert!(temp.iter().all(|t| *t < 60.0));
}
{
let mut multi = [0u16; 2];
let mut channels = [
Channel::new_pin(&mut p.PIN_26, Pull::Up),
Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR),
];
adc.read_many_multichannel(&mut channels, &mut multi, 1, &mut p.DMA_CH0)
.await
.unwrap();
defmt::assert!(multi[0] > 3_000);
let temp = convert_to_celsius(multi[1]);
defmt::assert!(temp > 0.0 && temp < 60.0);
}
info!("Test OK");
cortex_m::asm::bkpt();