diff options
Diffstat (limited to 'docs')
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 | ||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use defmt::*; | 5 | use defmt::*; |
| 9 | |||
| 10 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 11 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 12 | use embassy_nrf::{ | 8 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 13 | gpio::{Level, Output, OutputDrive}, | 9 | use embassy_nrf::peripherals::P0_13; |
| 14 | peripherals::P0_13, | 10 | use embassy_nrf::Peripherals; |
| 15 | Peripherals, | 11 | use {defmt_rtt as _, panic_probe as _}; // global logger |
| 16 | }; | ||
| 17 | 12 | ||
| 18 | #[embassy::task] | 13 | #[embassy::task] |
| 19 | async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { | 14 | async 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 | ||
| 5 | use defmt_rtt as _; | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use embassy::executor::Spawner; | 5 | use embassy::executor::Spawner; |
| 9 | use embassy_stm32::{ | 6 | use embassy_stm32::exti::ExtiInput; |
| 10 | exti::ExtiInput, | 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 11 | gpio::{Input, Level, Output, Pull, Speed}, | 8 | use embassy_stm32::Peripherals; |
| 12 | Peripherals, | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | }; | ||
| 14 | 10 | ||
| 15 | #[embassy::main] | 11 | #[embassy::main] |
| 16 | async fn main(_s: Spawner, p: Peripherals) { | 12 | async 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 | ||
| 4 | use cortex_m_rt::entry; | 4 | use cortex_m_rt::entry; |
| 5 | use defmt_rtt as _; | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 5 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 6 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | 7 | ||
| 10 | #[entry] | 8 | #[entry] |
| 11 | fn main() -> ! { | 9 | fn 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 | ||
| 4 | use defmt_rtt as _; | ||
| 5 | use panic_probe as _; | ||
| 6 | |||
| 7 | use core::cell::RefCell; | 4 | use core::cell::RefCell; |
| 5 | |||
| 8 | use cortex_m::interrupt::Mutex; | 6 | use cortex_m::interrupt::Mutex; |
| 9 | use cortex_m::peripheral::NVIC; | 7 | use cortex_m::peripheral::NVIC; |
| 10 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 11 | use embassy_stm32::{ | 9 | use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; |
| 12 | gpio::{Input, Level, Output, Pin, Pull, Speed}, | 10 | use embassy_stm32::peripherals::{PB14, PC13}; |
| 13 | interrupt, pac, | 11 | use embassy_stm32::{interrupt, pac}; |
| 14 | peripherals::{PB14, PC13}, | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | }; | ||
| 16 | 13 | ||
| 17 | static BUTTON: Mutex<RefCell<Option<Input<'static, PC13>>>> = Mutex::new(RefCell::new(None)); | 14 | static BUTTON: Mutex<RefCell<Option<Input<'static, PC13>>>> = Mutex::new(RefCell::new(None)); |
| 18 | static LED: Mutex<RefCell<Option<Output<'static, PB14>>>> = Mutex::new(RefCell::new(None)); | 15 | static 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 | ||
| 4 | use defmt_rtt as _; | ||
| 5 | use panic_probe as _; | ||
| 6 | |||
| 7 | use stm32_metapac as pac; | ||
| 8 | |||
| 9 | use pac::gpio::vals; | 4 | use pac::gpio::vals; |
| 5 | use {defmt_rtt as _, panic_probe as _, stm32_metapac as pac}; | ||
| 10 | 6 | ||
| 11 | #[cortex_m_rt::entry] | 7 | #[cortex_m_rt::entry] |
| 12 | fn main() -> ! { | 8 | fn 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 |
