aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src/bin/temp.rs
blob: af9775f5a1effdbbd0f9fe13398d3308dbaffb3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]

#[path = "../example_common.rs"]
mod example_common;
use example_common::*;

use defmt::panic;
use embassy::{
    executor::Spawner,
    time::{Duration, Timer},
};
use embassy_nrf::{interrupt, temp::Temp, Peripherals};

#[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;
        info!("temperature: {}℃", value.to_num::<u16>());
        Timer::after(Duration::from_secs(1)).await;
    }
}