2021-09-01 23:55:20 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::info;
|
2022-08-17 23:40:16 +02:00
|
|
|
use embassy_executor::Spawner;
|
2021-10-12 02:24:26 +02:00
|
|
|
use embassy_nrf::saadc::{ChannelConfig, Config, Saadc};
|
2023-03-05 21:56:22 +01:00
|
|
|
use embassy_nrf::{bind_interrupts, saadc};
|
2022-08-17 23:40:16 +02:00
|
|
|
use embassy_time::{Duration, Timer};
|
2022-06-12 22:15:44 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
2021-09-01 23:55:20 +02:00
|
|
|
|
2023-03-05 21:56:22 +01:00
|
|
|
bind_interrupts!(struct Irqs {
|
|
|
|
SAADC => saadc::InterruptHandler;
|
|
|
|
});
|
|
|
|
|
2022-07-29 21:58:35 +02:00
|
|
|
#[embassy_executor::main]
|
2022-08-17 18:49:55 +02:00
|
|
|
async fn main(_p: Spawner) {
|
|
|
|
let mut p = embassy_nrf::init(Default::default());
|
2021-09-01 23:55:20 +02:00
|
|
|
let config = Config::default();
|
2021-10-07 09:00:03 +02:00
|
|
|
let channel_config = ChannelConfig::single_ended(&mut p.P0_02);
|
2023-03-05 21:56:22 +01:00
|
|
|
let mut saadc = Saadc::new(p.SAADC, Irqs, config, [channel_config]);
|
2021-09-01 23:55:20 +02:00
|
|
|
|
|
|
|
loop {
|
2021-10-07 09:00:03 +02:00
|
|
|
let mut buf = [0; 1];
|
|
|
|
saadc.sample(&mut buf).await;
|
|
|
|
info!("sample: {=i16}", &buf[0]);
|
2021-09-01 23:55:20 +02:00
|
|
|
Timer::after(Duration::from_millis(100)).await;
|
|
|
|
}
|
|
|
|
}
|