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:
Ulf Lilleengen
2021-10-18 15:24:31 +02:00
committed by Ulf Lilleengen
parent 729b17bc25
commit 2ef4a45fa0
11 changed files with 134 additions and 0 deletions

View 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;
}
}