aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-02-04 21:36:19 +0100
committerDario Nieuwenhuis <[email protected]>2024-02-04 21:36:19 +0100
commitd5d86b866fd5ceb8081cbfcce832be4c68b82691 (patch)
tree8884048c369632e1d96370010ec96b4caf1eab90 /tests
parent711dd120d1802dd43b003b2536a290a1c53cfeba (diff)
nrf/gpiote: add support for nrf51.
Diffstat (limited to 'tests')
-rw-r--r--tests/nrf51422/Cargo.toml3
-rw-r--r--tests/nrf51422/src/bin/gpiote.rs47
2 files changed, 49 insertions, 1 deletions
diff --git a/tests/nrf51422/Cargo.toml b/tests/nrf51422/Cargo.toml
index 2cab20ac0..07236987b 100644
--- a/tests/nrf51422/Cargo.toml
+++ b/tests/nrf51422/Cargo.toml
@@ -7,10 +7,11 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8teleprobe-meta = "1" 8teleprobe-meta = "1"
9 9
10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
10embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] } 11embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] }
11embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] } 12embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] }
12embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 13embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
13embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time"] } 14embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "gpiote"] }
14embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } 15embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
15embedded-hal-async = { version = "1.0" } 16embedded-hal-async = { version = "1.0" }
16 17
diff --git a/tests/nrf51422/src/bin/gpiote.rs b/tests/nrf51422/src/bin/gpiote.rs
new file mode 100644
index 000000000..330fe993e
--- /dev/null
+++ b/tests/nrf51422/src/bin/gpiote.rs
@@ -0,0 +1,47 @@
1#![no_std]
2#![no_main]
3teleprobe_meta::target!(b"nrf51-dk");
4
5use defmt::{assert, info};
6use embassy_executor::Spawner;
7use embassy_futures::join::join;
8use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
9use embassy_time::{Duration, Instant, Timer};
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 let p = embassy_nrf::init(Default::default());
15
16 let mut input = Input::new(p.P0_13, Pull::Up);
17 let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard);
18
19 let fut1 = async {
20 Timer::after_millis(100).await;
21 output.set_high();
22 };
23 let fut2 = async {
24 let start = Instant::now();
25 input.wait_for_high().await;
26 let dur = Instant::now() - start;
27 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
28 };
29
30 join(fut1, fut2).await;
31
32 let fut1 = async {
33 Timer::after_millis(100).await;
34 output.set_low();
35 };
36 let fut2 = async {
37 let start = Instant::now();
38 input.wait_for_low().await;
39 let dur = Instant::now() - start;
40 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
41 };
42
43 join(fut1, fut2).await;
44
45 info!("Test OK");
46 cortex_m::asm::bkpt();
47}