diff options
Diffstat (limited to 'docs/modules/ROOT/examples')
| -rw-r--r-- | docs/modules/ROOT/examples/basic/.cargo/config.toml | 6 | ||||
| -rw-r--r-- | docs/modules/ROOT/examples/basic/Cargo.toml | 17 | ||||
| -rw-r--r-- | docs/modules/ROOT/examples/basic/src/main.rs | 33 | ||||
| l--------- | docs/modules/ROOT/examples/examples | 1 |
4 files changed, 57 insertions, 0 deletions
diff --git a/docs/modules/ROOT/examples/basic/.cargo/config.toml b/docs/modules/ROOT/examples/basic/.cargo/config.toml new file mode 100644 index 000000000..c75b5c539 --- /dev/null +++ b/docs/modules/ROOT/examples/basic/.cargo/config.toml | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | ||
| 2 | # replace nRF82840_xxAA with your chip as listed in `probe-run --list-chips` | ||
| 3 | runner = "probe-run --chip nRF52840_xxAA" | ||
| 4 | |||
| 5 | [build] | ||
| 6 | target = "thumbv7em-none-eabi" | ||
diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml new file mode 100644 index 000000000..0f1c30da3 --- /dev/null +++ b/docs/modules/ROOT/examples/basic/Cargo.toml | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | [package] | ||
| 2 | authors = ["Dario Nieuwenhuis <[email protected]>"] | ||
| 3 | edition = "2018" | ||
| 4 | name = "embassy-basic-example" | ||
| 5 | version = "0.1.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | embassy = { version = "0.1.0", path = "../../../../../embassy", features = ["defmt"] } | ||
| 9 | embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } | ||
| 10 | |||
| 11 | defmt = "0.3" | ||
| 12 | defmt-rtt = "0.3" | ||
| 13 | |||
| 14 | cortex-m = "0.7.3" | ||
| 15 | cortex-m-rt = "0.7.0" | ||
| 16 | embedded-hal = "0.2.6" | ||
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs new file mode 100644 index 000000000..2a9b1facc --- /dev/null +++ b/docs/modules/ROOT/examples/basic/src/main.rs | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | |||
| 10 | use embassy::executor::Spawner; | ||
| 11 | use embassy::time::{Duration, Timer}; | ||
| 12 | use embassy_nrf::{ | ||
| 13 | gpio::{Level, Output, OutputDrive}, | ||
| 14 | peripherals::P0_13, | ||
| 15 | Peripherals, | ||
| 16 | }; | ||
| 17 | use embedded_hal::digital::v2::OutputPin; | ||
| 18 | |||
| 19 | #[embassy::task] | ||
| 20 | async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { | ||
| 21 | loop { | ||
| 22 | unwrap!(led.set_high()); | ||
| 23 | Timer::after(interval).await; | ||
| 24 | unwrap!(led.set_low()); | ||
| 25 | Timer::after(interval).await; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | #[embassy::main] | ||
| 30 | async fn main(spawner: Spawner, p: Peripherals) { | ||
| 31 | let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | ||
| 32 | unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); | ||
| 33 | } | ||
diff --git a/docs/modules/ROOT/examples/examples b/docs/modules/ROOT/examples/examples new file mode 120000 index 000000000..1929330b0 --- /dev/null +++ b/docs/modules/ROOT/examples/examples | |||
| @@ -0,0 +1 @@ | |||
| ../../../../examples \ No newline at end of file | |||
