rp: Add multichannel ADC

This commit is contained in:
kalkyl
2024-06-05 09:42:08 +02:00
parent 5f9bc6def7
commit bf36bec9bb
3 changed files with 133 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_29, 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();