embassy/examples/nrf/src/bin/temp.rs

23 lines
579 B
Rust
Raw Normal View History

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt::info;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
2022-06-12 22:15:44 +02:00
use embassy_nrf::temp::Temp;
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
let irq = interrupt::take!(TEMP);
let mut temp = Temp::new(p.TEMP, irq);
loop {
let value = temp.read().await;
2021-10-19 15:32:16 +02:00
info!("temperature: {}℃", value.to_num::<u16>());
Timer::after(Duration::from_secs(1)).await;
}
}