aboutsummaryrefslogtreecommitdiff
path: root/tests/nrf/src/bin/gpio.rs
blob: 4995d244c2e375b6bbb6afe37f867f051ed9374d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![no_std]
#![no_main]

#[path = "../common.rs"]
mod common;

use defmt::{assert, info};
use embassy_executor::Spawner;
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
use embassy_time::Timer;

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
    let p = embassy_nrf::init(Default::default());

    let input = Input::new(peri!(p, PIN_A), Pull::Up);
    let mut output = Output::new(peri!(p, PIN_B), Level::Low, OutputDrive::Standard);

    output.set_low();
    assert!(output.is_set_low());
    Timer::after_millis(10).await;
    assert!(input.is_low());

    output.set_high();
    assert!(output.is_set_high());
    Timer::after_millis(10).await;
    assert!(input.is_high());

    info!("Test OK");
    cortex_m::asm::bkpt();
}