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

27 lines
655 B
Rust
Raw Normal View History

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt::info;
use embassy_executor::Spawner;
2022-06-12 22:15:44 +02:00
use embassy_nrf::temp::Temp;
use embassy_nrf::{bind_interrupts, temp};
use embassy_time::{Duration, Timer};
2022-06-12 22:15:44 +02:00
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
TEMP => temp::InterruptHandler;
});
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut temp = Temp::new(p.TEMP, Irqs);
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;
}
}