2021-09-01 23:55:20 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
#[path = "../example_common.rs"]
|
|
|
|
mod example_common;
|
|
|
|
use defmt::panic;
|
|
|
|
use embassy::executor::Spawner;
|
|
|
|
use embassy::time::{Duration, Timer};
|
2021-10-07 02:10:22 +02:00
|
|
|
use embassy_nrf::saadc::{Config, OneShot};
|
2021-09-01 23:55:20 +02:00
|
|
|
use embassy_nrf::{interrupt, Peripherals};
|
|
|
|
use example_common::*;
|
|
|
|
|
|
|
|
#[embassy::main]
|
|
|
|
async fn main(_spawner: Spawner, mut p: Peripherals) {
|
|
|
|
let config = Config::default();
|
|
|
|
let mut saadc = OneShot::new(p.SAADC, interrupt::take!(SAADC), config);
|
|
|
|
|
|
|
|
loop {
|
|
|
|
let sample = saadc.sample(&mut p.P0_02).await;
|
|
|
|
info!("sample: {=i16}", sample);
|
|
|
|
Timer::after(Duration::from_millis(100)).await;
|
|
|
|
}
|
|
|
|
}
|