nrf/gpiote: add support for nrf51.
This commit is contained in:
parent
711dd120d1
commit
d5d86b866f
5 changed files with 95 additions and 14 deletions
tests/nrf51422
|
@ -7,10 +7,11 @@ license = "MIT OR Apache-2.0"
|
|||
[dependencies]
|
||||
teleprobe-meta = "1"
|
||||
|
||||
embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
|
||||
embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] }
|
||||
embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] }
|
||||
embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "gpiote"] }
|
||||
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
|
||||
embedded-hal-async = { version = "1.0" }
|
||||
|
||||
|
|
47
tests/nrf51422/src/bin/gpiote.rs
Normal file
47
tests/nrf51422/src/bin/gpiote.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
teleprobe_meta::target!(b"nrf51-dk");
|
||||
|
||||
use defmt::{assert, info};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_futures::join::join;
|
||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||
use embassy_time::{Duration, Instant, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_nrf::init(Default::default());
|
||||
|
||||
let mut input = Input::new(p.P0_13, Pull::Up);
|
||||
let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard);
|
||||
|
||||
let fut1 = async {
|
||||
Timer::after_millis(100).await;
|
||||
output.set_high();
|
||||
};
|
||||
let fut2 = async {
|
||||
let start = Instant::now();
|
||||
input.wait_for_high().await;
|
||||
let dur = Instant::now() - start;
|
||||
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
||||
};
|
||||
|
||||
join(fut1, fut2).await;
|
||||
|
||||
let fut1 = async {
|
||||
Timer::after_millis(100).await;
|
||||
output.set_low();
|
||||
};
|
||||
let fut2 = async {
|
||||
let start = Instant::now();
|
||||
input.wait_for_low().await;
|
||||
let dur = Instant::now() - start;
|
||||
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
||||
};
|
||||
|
||||
join(fut1, fut2).await;
|
||||
|
||||
info!("Test OK");
|
||||
cortex_m::asm::bkpt();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue