diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:15:44 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:22:31 +0200 |
| commit | a8703b75988e1e700af701116464025679d2feb8 (patch) | |
| tree | f4ec5de70ec05e793a774049e010935ac45853ed /examples/stm32wl/src | |
| parent | 6199bdea710cde33e5d5381b6d6abfc8af46df19 (diff) | |
Run rustfmt.
Diffstat (limited to 'examples/stm32wl/src')
| -rw-r--r-- | examples/stm32wl/src/bin/blinky.rs | 3 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/button.rs | 6 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/button_exti.rs | 3 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/flash.rs | 4 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/lorawan.rs | 23 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/subghz.rs | 20 |
6 files changed, 19 insertions, 40 deletions
diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index 78079bfd3..9393af1c6 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs | |||
| @@ -3,12 +3,11 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 11 | use panic_probe as _; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy::main] | 12 | #[embassy::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs index f80b9ab4f..982a7a112 100644 --- a/examples/stm32wl/src/bin/button.rs +++ b/examples/stm32wl/src/bin/button.rs | |||
| @@ -2,12 +2,10 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use cortex_m_rt::entry; | ||
| 5 | use defmt::*; | 6 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 8 | use panic_probe as _; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | |||
| 10 | use cortex_m_rt::entry; | ||
| 11 | 9 | ||
| 12 | #[entry] | 10 | #[entry] |
| 13 | fn main() -> ! { | 11 | fn main() -> ! { |
diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 9a427c2d3..7d5c1b3cb 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs | |||
| @@ -3,12 +3,11 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 11 | use panic_probe as _; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy::main] | 12 | #[embassy::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index f84818224..6531feae9 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs | |||
| @@ -7,9 +7,7 @@ use embassy::executor::Spawner; | |||
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_stm32::Peripherals; | 8 | use embassy_stm32::Peripherals; |
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | 10 | use {defmt_rtt as _, panic_probe as _}; | |
| 11 | use defmt_rtt as _; // global logger | ||
| 12 | use panic_probe as _; | ||
| 13 | 11 | ||
| 14 | #[embassy::main] | 12 | #[embassy::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 393828c85..4f0dc7dfc 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs | |||
| @@ -5,20 +5,16 @@ | |||
| 5 | #![feature(generic_associated_types)] | 5 | #![feature(generic_associated_types)] |
| 6 | #![feature(type_alias_impl_trait)] | 6 | #![feature(type_alias_impl_trait)] |
| 7 | 7 | ||
| 8 | use defmt_rtt as _; // global logger | 8 | use embassy_lora::stm32wl::*; |
| 9 | use panic_probe as _; | 9 | use embassy_lora::LoraTimer; |
| 10 | 10 | use embassy_stm32::dma::NoDma; | |
| 11 | use embassy_lora::{stm32wl::*, LoraTimer}; | 11 | use embassy_stm32::gpio::{Level, Output, Pin, Speed}; |
| 12 | use embassy_stm32::{ | 12 | use embassy_stm32::rng::Rng; |
| 13 | dma::NoDma, | 13 | use embassy_stm32::subghz::*; |
| 14 | gpio::{Level, Output, Pin, Speed}, | 14 | use embassy_stm32::{interrupt, pac, Peripherals}; |
| 15 | interrupt, pac, | ||
| 16 | rng::Rng, | ||
| 17 | subghz::*, | ||
| 18 | Peripherals, | ||
| 19 | }; | ||
| 20 | use lorawan::default_crypto::DefaultFactory as Crypto; | 15 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 21 | use lorawan_device::async_device::{region, Device, JoinMode}; | 16 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | ||
| 22 | 18 | ||
| 23 | fn config() -> embassy_stm32::Config { | 19 | fn config() -> embassy_stm32::Config { |
| 24 | let mut config = embassy_stm32::Config::default(); | 20 | let mut config = embassy_stm32::Config::default(); |
| @@ -43,8 +39,7 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { | |||
| 43 | let radio = unsafe { SubGhzRadio::new(&mut RADIO_STATE, radio, rfs, irq) }; | 39 | let radio = unsafe { SubGhzRadio::new(&mut RADIO_STATE, radio, rfs, irq) }; |
| 44 | 40 | ||
| 45 | let region = region::EU868::default().into(); | 41 | let region = region::EU868::default().into(); |
| 46 | let mut device: Device<_, Crypto, _, _> = | 42 | let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer, Rng::new(p.RNG)); |
| 47 | Device::new(region, radio, LoraTimer, Rng::new(p.RNG)); | ||
| 48 | 43 | ||
| 49 | defmt::info!("Joining LoRaWAN network"); | 44 | defmt::info!("Joining LoRaWAN network"); |
| 50 | 45 | ||
diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index f5f9b6a32..c5f6e502a 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs | |||
| @@ -5,18 +5,15 @@ | |||
| 5 | #![feature(generic_associated_types)] | 5 | #![feature(generic_associated_types)] |
| 6 | #![feature(type_alias_impl_trait)] | 6 | #![feature(type_alias_impl_trait)] |
| 7 | 7 | ||
| 8 | use defmt_rtt as _; // global logger | ||
| 9 | use panic_probe as _; | ||
| 10 | |||
| 11 | use defmt::*; | 8 | use defmt::*; |
| 12 | use embassy::channel::signal::Signal; | 9 | use embassy::channel::signal::Signal; |
| 13 | use embassy_stm32::dma::NoDma; | 10 | use embassy_stm32::dma::NoDma; |
| 14 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
| 15 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 16 | use embassy_stm32::interrupt; | ||
| 17 | use embassy_stm32::interrupt::{Interrupt, InterruptExt}; | 13 | use embassy_stm32::interrupt::{Interrupt, InterruptExt}; |
| 18 | use embassy_stm32::subghz::*; | 14 | use embassy_stm32::subghz::*; |
| 19 | use embassy_stm32::Peripherals; | 15 | use embassy_stm32::{interrupt, Peripherals}; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | ||
| 20 | 17 | ||
| 21 | const PING_DATA: &str = "PING"; | 18 | const PING_DATA: &str = "PING"; |
| 22 | const DATA_LEN: u8 = PING_DATA.len() as u8; | 19 | const DATA_LEN: u8 = PING_DATA.len() as u8; |
| @@ -46,20 +43,13 @@ const LORA_MOD_PARAMS: LoRaModParams = LoRaModParams::new() | |||
| 46 | 43 | ||
| 47 | // configuration for +10 dBm output power | 44 | // configuration for +10 dBm output power |
| 48 | // see table 35 "PA optimal setting and operating modes" | 45 | // see table 35 "PA optimal setting and operating modes" |
| 49 | const PA_CONFIG: PaConfig = PaConfig::new() | 46 | const PA_CONFIG: PaConfig = PaConfig::new().set_pa_duty_cycle(0x1).set_hp_max(0x0).set_pa(PaSel::Lp); |
| 50 | .set_pa_duty_cycle(0x1) | ||
| 51 | .set_hp_max(0x0) | ||
| 52 | .set_pa(PaSel::Lp); | ||
| 53 | 47 | ||
| 54 | const TCXO_MODE: TcxoMode = TcxoMode::new() | 48 | const TCXO_MODE: TcxoMode = TcxoMode::new() |
| 55 | .set_txco_trim(TcxoTrim::Volts1pt7) | 49 | .set_txco_trim(TcxoTrim::Volts1pt7) |
| 56 | .set_timeout(Timeout::from_duration_sat( | 50 | .set_timeout(Timeout::from_duration_sat(core::time::Duration::from_millis(10))); |
| 57 | core::time::Duration::from_millis(10), | ||
| 58 | )); | ||
| 59 | 51 | ||
| 60 | const TX_PARAMS: TxParams = TxParams::new() | 52 | const TX_PARAMS: TxParams = TxParams::new().set_power(0x0D).set_ramp_time(RampTime::Micros40); |
| 61 | .set_power(0x0D) | ||
| 62 | .set_ramp_time(RampTime::Micros40); | ||
| 63 | 53 | ||
| 64 | fn config() -> embassy_stm32::Config { | 54 | fn config() -> embassy_stm32::Config { |
| 65 | let mut config = embassy_stm32::Config::default(); | 55 | let mut config = embassy_stm32::Config::default(); |
