aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-10-19 18:50:37 +0000
committerGitHub <[email protected]>2021-10-19 18:50:37 +0000
commit675172f9816a41792d53ba9dcd33ad3592e94eb8 (patch)
tree1b22cf95d15a280917f7bb999dabd15d138f8075 /examples
parent729b17bc25fed42b4348cae0fb3d781590572c3f (diff)
parent69953a78f10905330fb5d682dd5bda01f13a4e0c (diff)
Merge #436
436: Add support for temperature sensor peripheral r=lulf a=lulf * Add TEMP peripheral to all nRF52 chips * Add async HAL for reading temperature values * Add example application reading temperature values Co-authored-by: Ulf Lilleengen <[email protected]> Co-authored-by: Ulf Lilleengen <[email protected]>
Diffstat (limited to 'examples')
-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..af9775f5a
--- /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}