aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2021-10-18 15:24:31 +0200
committerUlf Lilleengen <[email protected]>2021-10-19 07:18:56 +0200
commit2ef4a45fa0e153cb6435c4dc52f19108ca808cc7 (patch)
tree8681889a127109a49d592b2857232c18e64645a6 /examples/nrf
parent729b17bc25fed42b4348cae0fb3d781590572c3f (diff)
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
Diffstat (limited to 'examples/nrf')
-rw-r--r--examples/nrf/src/bin/temp.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs
new file mode 100644
index 000000000..04d1d58fe
--- /dev/null
+++ b/examples/nrf/src/bin/temp.rs
@@ -0,0 +1,26 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5#[path = "../example_common.rs"]
6mod example_common;
7use example_common::*;
8
9use defmt::panic;
10use embassy::{
11 executor::Spawner,
12 time::{Duration, Timer},
13};
14use embassy_nrf::{interrupt, temp::Temp, Peripherals};
15
16#[embassy::main]
17async fn main(_spawner: Spawner, p: Peripherals) {
18 let irq = interrupt::take!(TEMP);
19 let mut temp = Temp::new(p.TEMP, irq);
20
21 loop {
22 let value = temp.read().await;
23 info!("temperature: {}", value.to_num::<u16>());
24 Timer::after(Duration::from_secs(1)).await;
25 }
26}