aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT/examples
diff options
context:
space:
mode:
Diffstat (limited to 'docs/modules/ROOT/examples')
-rw-r--r--docs/modules/ROOT/examples/basic/src/main.rs13
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs12
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs4
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs13
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs30
5 files changed, 21 insertions, 51 deletions
diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs
index 8394f73b7..461741fd7 100644
--- a/docs/modules/ROOT/examples/basic/src/main.rs
+++ b/docs/modules/ROOT/examples/basic/src/main.rs
@@ -2,18 +2,13 @@
2#![no_main] 2#![no_main]
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use defmt_rtt as _; // global logger
6use panic_probe as _;
7
8use defmt::*; 5use defmt::*;
9
10use embassy::executor::Spawner; 6use embassy::executor::Spawner;
11use embassy::time::{Duration, Timer}; 7use embassy::time::{Duration, Timer};
12use embassy_nrf::{ 8use embassy_nrf::gpio::{Level, Output, OutputDrive};
13 gpio::{Level, Output, OutputDrive}, 9use embassy_nrf::peripherals::P0_13;
14 peripherals::P0_13, 10use embassy_nrf::Peripherals;
15 Peripherals, 11use {defmt_rtt as _, panic_probe as _}; // global logger
16};
17 12
18#[embassy::task] 13#[embassy::task]
19async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { 14async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) {
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
index 35726be64..56bc698da 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
@@ -2,15 +2,11 @@
2#![no_main] 2#![no_main]
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use defmt_rtt as _;
6use panic_probe as _;
7
8use embassy::executor::Spawner; 5use embassy::executor::Spawner;
9use embassy_stm32::{ 6use embassy_stm32::exti::ExtiInput;
10 exti::ExtiInput, 7use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
11 gpio::{Input, Level, Output, Pull, Speed}, 8use embassy_stm32::Peripherals;
12 Peripherals, 9use {defmt_rtt as _, panic_probe as _};
13};
14 10
15#[embassy::main] 11#[embassy::main]
16async fn main(_s: Spawner, p: Peripherals) { 12async fn main(_s: Spawner, p: Peripherals) {
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs
index 2064ea616..d0c9f4907 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs
@@ -2,10 +2,8 @@
2#![no_main] 2#![no_main]
3 3
4use cortex_m_rt::entry; 4use cortex_m_rt::entry;
5use defmt_rtt as _;
6use panic_probe as _;
7
8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 5use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
6use {defmt_rtt as _, panic_probe as _};
9 7
10#[entry] 8#[entry]
11fn main() -> ! { 9fn main() -> ! {
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs
index 6a75384c4..743d0c342 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs
@@ -1,18 +1,15 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use defmt_rtt as _;
5use panic_probe as _;
6
7use core::cell::RefCell; 4use core::cell::RefCell;
5
8use cortex_m::interrupt::Mutex; 6use cortex_m::interrupt::Mutex;
9use cortex_m::peripheral::NVIC; 7use cortex_m::peripheral::NVIC;
10use cortex_m_rt::entry; 8use cortex_m_rt::entry;
11use embassy_stm32::{ 9use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed};
12 gpio::{Input, Level, Output, Pin, Pull, Speed}, 10use embassy_stm32::peripherals::{PB14, PC13};
13 interrupt, pac, 11use embassy_stm32::{interrupt, pac};
14 peripherals::{PB14, PC13}, 12use {defmt_rtt as _, panic_probe as _};
15};
16 13
17static BUTTON: Mutex<RefCell<Option<Input<'static, PC13>>>> = Mutex::new(RefCell::new(None)); 14static BUTTON: Mutex<RefCell<Option<Input<'static, PC13>>>> = Mutex::new(RefCell::new(None));
18static LED: Mutex<RefCell<Option<Output<'static, PB14>>>> = Mutex::new(RefCell::new(None)); 15static LED: Mutex<RefCell<Option<Output<'static, PB14>>>> = Mutex::new(RefCell::new(None));
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs
index 239eac188..990d46cb6 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs
@@ -1,12 +1,8 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use defmt_rtt as _;
5use panic_probe as _;
6
7use stm32_metapac as pac;
8
9use pac::gpio::vals; 4use pac::gpio::vals;
5use {defmt_rtt as _, panic_probe as _, stm32_metapac as pac};
10 6
11#[cortex_m_rt::entry] 7#[cortex_m_rt::entry]
12fn main() -> ! { 8fn main() -> ! {
@@ -30,30 +26,18 @@ fn main() -> ! {
30 let gpioc = pac::GPIOC; 26 let gpioc = pac::GPIOC;
31 const BUTTON_PIN: usize = 13; 27 const BUTTON_PIN: usize = 13;
32 unsafe { 28 unsafe {
33 gpioc 29 gpioc.pupdr().modify(|w| w.set_pupdr(BUTTON_PIN, vals::Pupdr::PULLUP));
34 .pupdr() 30 gpioc.otyper().modify(|w| w.set_ot(BUTTON_PIN, vals::Ot::PUSHPULL));
35 .modify(|w| w.set_pupdr(BUTTON_PIN, vals::Pupdr::PULLUP)); 31 gpioc.moder().modify(|w| w.set_moder(BUTTON_PIN, vals::Moder::INPUT));
36 gpioc
37 .otyper()
38 .modify(|w| w.set_ot(BUTTON_PIN, vals::Ot::PUSHPULL));
39 gpioc
40 .moder()
41 .modify(|w| w.set_moder(BUTTON_PIN, vals::Moder::INPUT));
42 } 32 }
43 33
44 // Setup LED 34 // Setup LED
45 let gpiob = pac::GPIOB; 35 let gpiob = pac::GPIOB;
46 const LED_PIN: usize = 14; 36 const LED_PIN: usize = 14;
47 unsafe { 37 unsafe {
48 gpiob 38 gpiob.pupdr().modify(|w| w.set_pupdr(LED_PIN, vals::Pupdr::FLOATING));
49 .pupdr() 39 gpiob.otyper().modify(|w| w.set_ot(LED_PIN, vals::Ot::PUSHPULL));
50 .modify(|w| w.set_pupdr(LED_PIN, vals::Pupdr::FLOATING)); 40 gpiob.moder().modify(|w| w.set_moder(LED_PIN, vals::Moder::OUTPUT));
51 gpiob
52 .otyper()
53 .modify(|w| w.set_ot(LED_PIN, vals::Ot::PUSHPULL));
54 gpiob
55 .moder()
56 .modify(|w| w.set_moder(LED_PIN, vals::Moder::OUTPUT));
57 } 41 }
58 42
59 // Main loop 43 // Main loop