Add support for temperature sensor peripheral
* Add TEMP peripheral to all nRF52 chips * Add async HAL for reading temperature values * Add example application reading temperature values
This commit is contained in:
committed by
Ulf Lilleengen
parent
729b17bc25
commit
2ef4a45fa0
26
examples/nrf/src/bin/temp.rs
Normal file
26
examples/nrf/src/bin/temp.rs
Normal file
@ -0,0 +1,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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user