diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-04-02 04:35:06 +0200 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-04-02 04:35:06 +0200 |
commit | 82803bffdab0842bf6c3e4bce21131d437b06669 (patch) | |
tree | 588c65c93b31b897f53d389f7876dc2703eb0fa8 /examples/stm32f7 | |
parent | a9e63167e1ec230ca3d28da771378f5f4936a840 (diff) | |
download | embassy-82803bffdab0842bf6c3e4bce21131d437b06669.zip |
Use embassy/defmt-timestamp-uptime in all examples.
Diffstat (limited to 'examples/stm32f7')
-rw-r--r-- | examples/stm32f7/Cargo.toml | 2 | ||||
-rw-r--r-- | examples/stm32f7/src/bin/blinky.rs | 6 | ||||
-rw-r--r-- | examples/stm32f7/src/bin/button.rs | 6 | ||||
-rw-r--r-- | examples/stm32f7/src/bin/button_exti.rs | 6 | ||||
-rw-r--r-- | examples/stm32f7/src/bin/eth.rs | 24 | ||||
-rw-r--r-- | examples/stm32f7/src/bin/hello.rs | 4 | ||||
-rw-r--r-- | examples/stm32f7/src/bin/sdmmc.rs | 6 | ||||
-rw-r--r-- | examples/stm32f7/src/bin/usart_dma.rs | 6 | ||||
-rw-r--r-- | examples/stm32f7/src/example_common.rs | 27 |
9 files changed, 32 insertions, 55 deletions
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 3f685834..3703f551 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" resolver = "2" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index 00d67dac..8b85ca96 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/src/bin/button.rs b/examples/stm32f7/src/bin/button.rs index 24eef75b..4f9af7fb 100644 --- a/examples/stm32f7/src/bin/button.rs +++ b/examples/stm32f7/src/bin/button.rs @@ -2,11 +2,11 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use cortex_m_rt::entry; +use defmt::*; +use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use example_common::*; +use panic_probe as _; #[entry] fn main() -> ! { diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 852fbe3c..78f2e6ee 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 15169d2d..446756c2 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -2,14 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use embassy_stm32::peripherals::ETH; -use example_common::config; - use cortex_m_rt::entry; -use defmt::{info, unwrap}; -use defmt_rtt as _; // global logger +use defmt::*; use embassy::executor::{Executor, Spawner}; use embassy::io::AsyncWriteExt; use embassy::time::{Duration, Timer}; @@ -19,12 +13,16 @@ use embassy_net::{ }; use embassy_stm32::eth::lan8742a::LAN8742A; use embassy_stm32::eth::{Ethernet, State}; +use embassy_stm32::interrupt; +use embassy_stm32::peripherals::ETH; +use embassy_stm32::peripherals::RNG; use embassy_stm32::rng::Rng; -use embassy_stm32::{interrupt, peripherals}; +use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; use heapless::Vec; -use panic_probe as _; -use peripherals::RNG; +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::task] async fn main_task( @@ -88,6 +86,12 @@ static ETH: Forever<Ethernet<'static, ETH, LAN8742A, 4, 4>> = Forever::new(); static CONFIG: Forever<StaticConfigurator> = Forever::new(); static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new(); +fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(200.mhz().into()); + config +} + #[entry] fn main() -> ! { info!("Hello World!"); diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index 56eb67bf..92d87ced 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -9,8 +9,8 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Config; use embassy_stm32::Peripherals; -#[path = "../example_common.rs"] -mod example_common; +use defmt_rtt as _; // global logger +use panic_probe as _; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 57b913db..dae07c30 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt_rtt as _; // global logger +use panic_probe as _; +use defmt::*; use embassy::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::U32Ext; use embassy_stm32::{interrupt, Config, Peripherals}; -use example_common::*; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 00deae8b..69fa21a0 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use core::fmt::Write; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; use heapless::String; diff --git a/examples/stm32f7/src/example_common.rs b/examples/stm32f7/src/example_common.rs deleted file mode 100644 index a786cb11..00000000 --- a/examples/stm32f7/src/example_common.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; -use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; -// global logger -use panic_probe as _; - -pub use defmt::*; - -use core::sync::atomic::{AtomicUsize, Ordering}; - -defmt::timestamp! {"{=u64}", { - static COUNT: AtomicUsize = AtomicUsize::new(0); - // NOTE(no-CAS) `timestamps` runs with interrupts disabled - let n = COUNT.load(Ordering::Relaxed); - COUNT.store(n + 1, Ordering::Relaxed); - n as u64 - } -} - -#[allow(unused)] -pub fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(200.mhz().into()); - config -} |