From 82803bffdab0842bf6c3e4bce21131d437b06669 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sat, 2 Apr 2022 04:35:06 +0200 Subject: [PATCH] Use embassy/defmt-timestamp-uptime in all examples. --- examples/nrf/Cargo.toml | 2 +- examples/nrf/src/bin/awaitable_timer.rs | 8 +++--- examples/nrf/src/bin/blinky.rs | 6 ++-- examples/nrf/src/bin/buffered_uart.rs | 8 +++--- .../nrf/src/bin/executor_fairness_test.rs | 8 +++--- examples/nrf/src/bin/gpiote_channel.rs | 8 +++--- examples/nrf/src/bin/gpiote_port.rs | 8 +++--- examples/nrf/src/bin/mpsc.rs | 6 ++-- examples/nrf/src/bin/multiprio.rs | 8 +++--- examples/nrf/src/bin/nvmc.rs | 7 +++-- examples/nrf/src/bin/ppi.rs | 8 +++--- examples/nrf/src/bin/pwm.rs | 5 ++-- examples/nrf/src/bin/pwm_double_sequence.rs | 5 ++-- examples/nrf/src/bin/pwm_sequence.rs | 5 ++-- examples/nrf/src/bin/pwm_sequence_ppi.rs | 5 ++-- examples/nrf/src/bin/pwm_sequence_ws2812b.rs | 5 ++-- examples/nrf/src/bin/pwm_servo.rs | 5 ++-- examples/nrf/src/bin/qspi.rs | 9 +++--- examples/nrf/src/bin/qspi_lowpower.rs | 8 +++--- examples/nrf/src/bin/raw_spawn.rs | 9 +++--- examples/nrf/src/bin/rng.rs | 6 ++-- examples/nrf/src/bin/saadc.rs | 7 +++-- examples/nrf/src/bin/saadc_continuous.rs | 7 +++-- examples/nrf/src/bin/spim.rs | 8 +++--- examples/nrf/src/bin/temp.rs | 14 ++++------ examples/nrf/src/bin/timer.rs | 10 +++---- examples/nrf/src/bin/twim.rs | 6 ++-- examples/nrf/src/bin/twim_lowpower.rs | 7 ++--- examples/nrf/src/bin/uart.rs | 8 +++--- examples/nrf/src/bin/uart_idle.rs | 8 +++--- examples/nrf/src/bin/uart_split.rs | 8 +++--- examples/nrf/src/bin/usb_uart.rs | 13 ++++----- examples/nrf/src/bin/usb_uart_io.rs | 9 ++---- examples/nrf/src/bin/wdt.rs | 6 ++-- examples/nrf/src/example_common.rs | 17 ----------- examples/rp/Cargo.toml | 2 +- examples/rp/src/bin/blinky.rs | 6 ++-- examples/rp/src/bin/button.rs | 6 ++-- examples/rp/src/bin/spi.rs | 6 ++-- examples/rp/src/bin/spi_display.rs | 7 ++--- examples/rp/src/bin/uart.rs | 6 ++-- examples/rp/src/example_common.rs | 12 -------- examples/stm32f0/Cargo.toml | 4 +-- examples/stm32f0/src/bin/hello.rs | 5 ++-- examples/stm32f0/src/example_common.rs | 17 ----------- examples/stm32f1/Cargo.toml | 2 +- examples/stm32f1/src/bin/adc.rs | 8 +++--- examples/stm32f1/src/bin/blinky.rs | 7 +++-- examples/stm32f1/src/bin/hello.rs | 4 +-- examples/stm32f1/src/example_common.rs | 17 ----------- examples/stm32f2/Cargo.toml | 2 +- examples/stm32f2/src/bin/blinky.rs | 8 +++--- examples/stm32f2/src/example_common.rs | 19 ------------- examples/stm32f3/Cargo.toml | 2 +- examples/stm32f3/src/bin/blinky.rs | 8 +++--- examples/stm32f3/src/bin/button.rs | 6 ++-- examples/stm32f3/src/bin/button_events.rs | 7 +++-- examples/stm32f3/src/bin/button_exti.rs | 6 ++-- examples/stm32f3/src/bin/hello.rs | 4 +-- examples/stm32f3/src/bin/multiprio.rs | 6 ++-- examples/stm32f3/src/bin/spi_dma.rs | 6 ++-- examples/stm32f3/src/bin/usart_dma.rs | 6 ++-- examples/stm32f3/src/example_common.rs | 19 ------------- examples/stm32f4/Cargo.toml | 2 +- examples/stm32f4/src/bin/adc.rs | 6 ++-- examples/stm32f4/src/bin/blinky.rs | 6 ++-- examples/stm32f4/src/bin/button.rs | 6 ++-- examples/stm32f4/src/bin/button_exti.rs | 6 ++-- examples/stm32f4/src/bin/can.rs | 6 ++-- examples/stm32f4/src/bin/hello.rs | 4 +-- examples/stm32f4/src/bin/multiprio.rs | 6 ++-- examples/stm32f4/src/bin/sdmmc.rs | 6 ++-- examples/stm32f4/src/bin/spi.rs | 6 ++-- examples/stm32f4/src/bin/spi_dma.rs | 6 ++-- examples/stm32f4/src/bin/usart.rs | 6 ++-- examples/stm32f4/src/bin/usart_dma.rs | 6 ++-- examples/stm32f4/src/bin/usb_uart.rs | 4 +-- examples/stm32f4/src/bin/usb_uart_ulpi.rs | 4 +-- examples/stm32f4/src/example_common.rs | 17 ----------- examples/stm32f7/Cargo.toml | 2 +- examples/stm32f7/src/bin/blinky.rs | 6 ++-- examples/stm32f7/src/bin/button.rs | 6 ++-- examples/stm32f7/src/bin/button_exti.rs | 6 ++-- examples/stm32f7/src/bin/eth.rs | 24 +++++++++------- examples/stm32f7/src/bin/hello.rs | 4 +-- examples/stm32f7/src/bin/sdmmc.rs | 6 ++-- examples/stm32f7/src/bin/usart_dma.rs | 6 ++-- examples/stm32f7/src/example_common.rs | 27 ------------------ examples/stm32g0/Cargo.toml | 2 +- examples/stm32g0/src/bin/blinky.rs | 6 ++-- examples/stm32g0/src/bin/button.rs | 6 ++-- examples/stm32g0/src/bin/button_exti.rs | 6 ++-- examples/stm32g0/src/example_common.rs | 17 ----------- examples/stm32g4/Cargo.toml | 2 +- examples/stm32g4/src/bin/blinky.rs | 6 ++-- examples/stm32g4/src/bin/button.rs | 6 ++-- examples/stm32g4/src/bin/button_exti.rs | 6 ++-- examples/stm32g4/src/bin/pwm.rs | 6 ++-- examples/stm32g4/src/example_common.rs | 17 ----------- examples/stm32h7/Cargo.toml | 2 +- examples/stm32h7/src/bin/blinky.rs | 6 ++-- examples/stm32h7/src/bin/button_exti.rs | 6 ++-- examples/stm32h7/src/bin/camera.rs | 13 +-------- examples/stm32h7/src/bin/dac.rs | 17 ++++++++--- examples/stm32h7/src/bin/eth.rs | 26 +++++++++++------ examples/stm32h7/src/bin/fmc.rs | 16 +++++++++-- .../stm32h7/src/bin/low_level_timer_api.rs | 6 ++-- examples/stm32h7/src/bin/mco.rs | 6 ++-- examples/stm32h7/src/bin/pwm.rs | 6 ++-- examples/stm32h7/src/bin/rng.rs | 6 ++-- examples/stm32h7/src/bin/sdmmc.rs | 6 ++-- examples/stm32h7/src/bin/spi.rs | 22 ++++++++++----- examples/stm32h7/src/bin/spi_dma.rs | 22 ++++++++++----- examples/stm32h7/src/bin/usart.rs | 6 ++-- examples/stm32h7/src/bin/usart_dma.rs | 6 ++-- examples/stm32h7/src/bin/usart_split.rs | 6 ++-- examples/stm32h7/src/example_common.rs | 28 ------------------- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l0/src/bin/blinky.rs | 6 ++-- examples/stm32l0/src/bin/button.rs | 6 ++-- examples/stm32l0/src/bin/button_exti.rs | 6 ++-- examples/stm32l0/src/bin/lorawan.rs | 4 +-- examples/stm32l0/src/bin/raw_spawn.rs | 6 ++-- examples/stm32l0/src/bin/spi.rs | 6 ++-- examples/stm32l0/src/bin/usart_dma.rs | 6 ++-- examples/stm32l0/src/bin/usart_irq.rs | 6 ++-- examples/stm32l0/src/example_common.rs | 17 ----------- examples/stm32l1/Cargo.toml | 2 +- examples/stm32l1/src/bin/blinky.rs | 6 ++-- examples/stm32l1/src/bin/spi.rs | 6 ++-- examples/stm32l1/src/example_common.rs | 17 ----------- examples/stm32l4/Cargo.toml | 2 +- examples/stm32l4/src/bin/adc.rs | 6 ++-- examples/stm32l4/src/bin/blinky.rs | 6 ++-- examples/stm32l4/src/bin/button.rs | 6 ++-- examples/stm32l4/src/bin/button_exti.rs | 6 ++-- examples/stm32l4/src/bin/dac.rs | 6 ++-- examples/stm32l4/src/bin/i2c.rs | 6 ++-- .../stm32l4/src/bin/i2c_blocking_async.rs | 6 ++-- examples/stm32l4/src/bin/i2c_dma.rs | 6 ++-- examples/stm32l4/src/bin/rng.rs | 6 ++-- examples/stm32l4/src/bin/spi.rs | 6 ++-- .../stm32l4/src/bin/spi_blocking_async.rs | 6 ++-- examples/stm32l4/src/bin/spi_dma.rs | 6 ++-- examples/stm32l4/src/bin/usart.rs | 6 ++-- .../stm32l4/src/bin/usart_blocking_async.rs | 6 ++-- examples/stm32l4/src/bin/usart_dma.rs | 6 ++-- examples/stm32l4/src/example_common.rs | 17 ----------- examples/stm32u5/Cargo.toml | 4 +-- examples/stm32u5/src/bin/boot.rs | 6 ++-- examples/stm32u5/src/example_common.rs | 17 ----------- examples/stm32wb55/Cargo.toml | 2 +- examples/stm32wb55/src/bin/blinky.rs | 6 ++-- examples/stm32wb55/src/bin/button_exti.rs | 6 ++-- examples/stm32wb55/src/example_common.rs | 17 ----------- examples/stm32wl55/Cargo.toml | 2 +- examples/stm32wl55/src/bin/blinky.rs | 6 ++-- examples/stm32wl55/src/bin/button.rs | 6 ++-- examples/stm32wl55/src/bin/button_exti.rs | 6 ++-- examples/stm32wl55/src/bin/lorawan.rs | 4 +-- examples/stm32wl55/src/bin/subghz.rs | 6 ++-- examples/stm32wl55/src/example_common.rs | 17 ----------- 162 files changed, 490 insertions(+), 765 deletions(-) delete mode 100644 examples/nrf/src/example_common.rs delete mode 100644 examples/rp/src/example_common.rs delete mode 100644 examples/stm32f0/src/example_common.rs delete mode 100644 examples/stm32f1/src/example_common.rs delete mode 100644 examples/stm32f2/src/example_common.rs delete mode 100644 examples/stm32f3/src/example_common.rs delete mode 100644 examples/stm32f4/src/example_common.rs delete mode 100644 examples/stm32f7/src/example_common.rs delete mode 100644 examples/stm32g0/src/example_common.rs delete mode 100644 examples/stm32g4/src/example_common.rs delete mode 100644 examples/stm32h7/src/example_common.rs delete mode 100644 examples/stm32l0/src/example_common.rs delete mode 100644 examples/stm32l1/src/example_common.rs delete mode 100644 examples/stm32l4/src/example_common.rs delete mode 100644 examples/stm32u5/src/example_common.rs delete mode 100644 examples/stm32wb55/src/example_common.rs delete mode 100644 examples/stm32wl55/src/example_common.rs diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 7fdc27ffa..a704eb3bc 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -9,7 +9,7 @@ default = ["nightly"] nightly = ["embassy-nrf/nightly", "embassy-nrf/unstable-traits"] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } defmt = "0.3" diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index 98b656005..810b4bd6a 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::info; +use embassy::executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::timer::Timer; use embassy_nrf::Peripherals; -use example_common::info; -use embassy::executor::Spawner; +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 0fc004ed8..4828b08fb 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index a2602ea6c..2cd163a9f 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -2,16 +2,16 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - +use defmt::*; use embassy::executor::Spawner; use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; use embassy_nrf::buffered_uarte::State; use embassy_nrf::{buffered_uarte::BufferedUarte, interrupt, uarte, Peripherals}; -use example_common::*; use futures::pin_mut; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index 397bb16f6..7a356d14b 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -2,15 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - use core::task::Poll; +use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Instant, Timer}; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::task] async fn run1() { loop { diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index f29dae022..339f779f8 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs @@ -2,15 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - +use defmt::info; use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index 3ea9a6e67..dc6bd301f 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - +use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; use embassy_nrf::Peripherals; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::task(pool_size = 4)] async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { diff --git a/examples/nrf/src/bin/mpsc.rs b/examples/nrf/src/bin/mpsc.rs index d50736d82..0cb182755 100644 --- a/examples/nrf/src/bin/mpsc.rs +++ b/examples/nrf/src/bin/mpsc.rs @@ -2,9 +2,6 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use defmt::unwrap; use embassy::blocking_mutex::raw::NoopRawMutex; use embassy::channel::mpsc::{self, Channel, Sender, TryRecvError}; @@ -14,6 +11,9 @@ use embassy::util::Forever; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + enum LedState { On, Off, diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index 85e126908..e69f87d85 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs @@ -57,17 +57,17 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - use cortex_m_rt::entry; +use defmt::{info, unwrap}; use embassy::executor::{Executor, InterruptExecutor}; use embassy::interrupt::InterruptExt; use embassy::time::{Duration, Instant, Timer}; use embassy::util::Forever; use embassy_nrf::interrupt; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::task] async fn run_high() { loop { diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index f36895636..7a57399f8 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs @@ -2,14 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::nvmc::Nvmc; use embassy_nrf::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 99246eeda..3c9a8148a 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs @@ -2,11 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - use core::future::pending; +use defmt::info; use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; @@ -14,6 +11,9 @@ use embassy_nrf::ppi::Ppi; use embassy_nrf::Peripherals; use gpiote::{OutputChannel, OutputChannelPolarity}; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index 68402ce22..7939e79e4 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs @@ -2,14 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') static DUTY: [u16; 1024] = [ 8191, 8272, 8353, 8434, 8516, 8598, 8681, 8764, 8847, 8931, 9015, 9099, 9184, 9269, 9354, 9440, diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index 85938f32c..6fc429214 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs @@ -2,8 +2,6 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; @@ -13,6 +11,9 @@ use embassy_nrf::pwm::{ }; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words_0: [u16; 5] = [1000, 250, 100, 50, 0]; diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index f42958145..3b2919ba5 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -2,8 +2,6 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; @@ -12,6 +10,9 @@ use embassy_nrf::pwm::{ }; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index 66717c592..1f3662c60 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs @@ -3,8 +3,6 @@ #![feature(type_alias_impl_trait)] #![feature(array_from_fn)] -#[path = "../example_common.rs"] -mod example_common; use core::future::pending; use defmt::*; use embassy::executor::Spawner; @@ -16,6 +14,9 @@ use embassy_nrf::pwm::{ }; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index e5af7b462..8bfe1d50f 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs @@ -2,8 +2,6 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; @@ -13,6 +11,9 @@ use embassy_nrf::pwm::{ }; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + // WS2812B LED light demonstration. Drives just one light. // The following reference on WS2812B may be of use: // https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf. diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index c2ab0e7d1..40863bf3c 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs @@ -2,14 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05); diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index b2e6bfc15..ba60716c8 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -2,14 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - -use defmt::assert_eq; +use defmt::{assert_eq, info, unwrap}; use embassy::executor::Spawner; use embassy_nrf::Peripherals; use embassy_nrf::{interrupt, qspi}; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; const PAGE_SIZE: usize = 4096; diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index 4e264ef2f..a8184cd63 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -2,15 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use core::mem; +use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::Peripherals; use embassy_nrf::{interrupt, qspi}; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; // Workaround for alignment requirements. // Nicer API will probably come in the future. diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index d0bd68674..1d9d3ed51 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs @@ -1,18 +1,17 @@ #![no_std] #![no_main] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - use core::mem; use cortex_m_rt::entry; - +use defmt::{info, unwrap}; use embassy::executor::raw::TaskStorage; use embassy::executor::Executor; use embassy::time::{Duration, Timer}; use embassy::util::Forever; +use defmt_rtt as _; // global logger +use panic_probe as _; + async fn run1() { loop { info!("BIG INFREQUENT TICK"); diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index a35a9fa85..4b4b3a19b 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -2,15 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use embassy::executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::rng::Rng; use embassy_nrf::Peripherals; use rand::Rng as _; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut rng = Rng::new(p.RNG, interrupt::take!(RNG)); diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index bc6b2b52c..5835be31f 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -2,13 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::info; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; use embassy_nrf::{interrupt, Peripherals}; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, mut p: Peripherals) { diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index bdf552fba..5e357f79b 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -2,14 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::info; use embassy::executor::Spawner; use embassy::time::Duration; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; use embassy_nrf::timer::Frequency; use embassy_nrf::{interrupt, Peripherals}; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index cda3baa26..f2a4ab388 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - +use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; use embassy_nrf::{interrupt, spim}; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index 4b30b6ea3..aa807910f 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -2,16 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - -use embassy::{ - executor::Spawner, - time::{Duration, Timer}, -}; +use defmt::info; +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; use embassy_nrf::{interrupt, temp::Temp, Peripherals}; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let irq = interrupt::take!(TEMP); diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index f27081b74..ff8ee9a86 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use embassy_nrf::Peripherals; -use example_common::*; - +use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; +use embassy_nrf::Peripherals; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::task] async fn run1() { diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index 1ac3a3945..08c614157 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -6,14 +6,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use defmt::*; use embassy::executor::Spawner; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; +use defmt_rtt as _; // global logger +use panic_probe as _; + const ADDRESS: u8 = 0x50; #[embassy::main] diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index 4a0596437..45b347ea0 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -8,17 +8,16 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use core::mem; - use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; +use defmt_rtt as _; // global logger +use panic_probe as _; + const ADDRESS: u8 = 0x50; #[embassy::main] diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 5dc89df66..91f7f4fdd 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - +use defmt::*; use embassy::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 88dc185af..89336faaf 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - +use defmt::*; use embassy::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 19d438c40..909429b1a 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -2,10 +2,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; - +use defmt::*; use embassy::blocking_mutex::raw::NoopRawMutex; use embassy::channel::mpsc::{self, Channel, Sender}; use embassy::executor::Spawner; @@ -14,6 +11,9 @@ use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte, Peripherals}; +use defmt_rtt as _; // global logger +use panic_probe as _; + static CHANNEL: Forever> = Forever::new(); #[embassy::main] diff --git a/examples/nrf/src/bin/usb_uart.rs b/examples/nrf/src/bin/usb_uart.rs index c345df9e3..d283dccd1 100644 --- a/examples/nrf/src/bin/usb_uart.rs +++ b/examples/nrf/src/bin/usb_uart.rs @@ -2,21 +2,18 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use defmt::{info, unwrap}; -use defmt_rtt as _; // global logger -use embassy::interrupt::InterruptExt; -use futures::pin_mut; -use panic_probe as _; // print out panic messages - use embassy::executor::Spawner; +use embassy::interrupt::InterruptExt; use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; use embassy_nrf::usb::{State, Usb, UsbBus, UsbSerial}; use embassy_nrf::{interrupt, Peripherals}; +use futures::pin_mut; use usb_device::device::{UsbDeviceBuilder, UsbVidPid}; +use defmt_rtt as _; // global logger +use panic_probe as _; // print out panic messages + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut rx_buffer = [0u8; 64]; diff --git a/examples/nrf/src/bin/usb_uart_io.rs b/examples/nrf/src/bin/usb_uart_io.rs index 8fc615262..ef2629844 100644 --- a/examples/nrf/src/bin/usb_uart_io.rs +++ b/examples/nrf/src/bin/usb_uart_io.rs @@ -2,13 +2,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use defmt::{info, unwrap}; -use defmt_rtt as _; // global logger -use panic_probe as _; // print out panic messages - use embassy::executor::Spawner; use embassy::interrupt::InterruptExt; use embassy::io::{read_line, AsyncWriteExt}; @@ -17,6 +11,9 @@ use embassy_nrf::{interrupt, Peripherals}; use futures::pin_mut; use usb_device::device::{UsbDeviceBuilder, UsbVidPid}; +use defmt_rtt as _; // global logger +use panic_probe as _; // print out panic messages + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut rx_buffer = [0u8; 64]; diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index cc199be9d..431ccca8b 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs @@ -2,15 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use defmt::*; use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::wdt::{Config, Watchdog}; use embassy_nrf::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/nrf/src/example_common.rs b/examples/nrf/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/nrf/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 830e54174..2cce0af37 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } atomic-polyfill = "0.1.5" diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index 96e45f697..6f199d07e 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs @@ -2,15 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_rp::{gpio, Peripherals}; use gpio::{Level, Output}; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PIN_25, Level::Low); diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index 6492367e5..2418ad012 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use embassy::executor::Spawner; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::Peripherals; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let button = Input::new(p.PIN_28, Pull::Up); diff --git a/examples/rp/src/bin/spi.rs b/examples/rp/src/bin/spi.rs index 3348dc999..b38424363 100644 --- a/examples/rp/src/bin/spi.rs +++ b/examples/rp/src/bin/spi.rs @@ -2,9 +2,6 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use defmt::*; use embassy::executor::Spawner; use embassy_rp::spi; @@ -12,6 +9,9 @@ use embassy_rp::spi::Spi; use embassy_rp::{gpio, Peripherals}; use gpio::{Level, Output}; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index b2854afcb..bc93e0617 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -2,11 +2,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use core::cell::RefCell; - use defmt::*; use embassy::executor::Spawner; use embassy::time::Delay; @@ -27,6 +23,9 @@ use crate::my_display_interface::SPIDeviceInterface; use crate::shared_spi::SpiDeviceWithCs; use crate::touch::Touch; +use defmt_rtt as _; // global logger +use panic_probe as _; + //const DISPLAY_FREQ: u32 = 64_000_000; const TOUCH_FREQ: u32 = 200_000; diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index 8354f9f82..bc941dd8b 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs @@ -2,12 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - use embassy::executor::Spawner; use embassy_rp::{uart, Peripherals}; +use defmt_rtt as _; // global logger +use panic_probe as _; + #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let config = uart::Config::default(); diff --git a/examples/rp/src/example_common.rs b/examples/rp/src/example_common.rs deleted file mode 100644 index f7c4ef57a..000000000 --- a/examples/rp/src/example_common.rs +++ /dev/null @@ -1,12 +0,0 @@ -use core::sync::atomic::{AtomicUsize, Ordering}; -use defmt_rtt as _; -use panic_probe as _; - -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 -} -} diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 0f76dabf0..c973c1f7c 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -13,6 +13,6 @@ cortex-m-rt = "0.7.0" defmt = "0.3" defmt-rtt = "0.3" panic-probe = "0.3" -embassy = { path = "../../embassy", features = ["defmt"] } -embassy-stm32 = { path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] } diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index 9f745f9ae..975e94f34 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs @@ -3,13 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::info; - use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::Peripherals; -#[path = "../example_common.rs"] -mod example_common; +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32f0/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index 79be4b51c..5e5faf1f6 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/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", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] } defmt = "0.3" diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index d24f3f5cb..af403423d 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - +use defmt::*; use embassy::executor::Spawner; use embassy::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index 0d9537453..657bcdd1d 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs @@ -2,13 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index efcb9a244..8054a8993 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/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/stm32f1/src/example_common.rs b/examples/stm32f1/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32f1/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index ee1d7ce2b..4eef3a6fe 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/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", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } defmt = "0.3" diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 637c2f4fd..395f4df51 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - +use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f2/src/example_common.rs b/examples/stm32f2/src/example_common.rs deleted file mode 100644 index e14517033..000000000 --- a/examples/stm32f2/src/example_common.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index 3ce2bc8a2..37f99fea2 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/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", "stm32f303vc", "unstable-pac", "memory-x", "time-driver-any", "exti"] } defmt = "0.3" diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index e8b8dc23f..b3643a26f 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - +use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f3/src/bin/button.rs b/examples/stm32f3/src/bin/button.rs index 131d4af42..207381bdd 100644 --- a/examples/stm32f3/src/bin/button.rs +++ b/examples/stm32f3/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/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 0bd7b342f..99aab3027 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -10,8 +10,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; use embassy::blocking_mutex::raw::NoopRawMutex; use embassy::channel::mpsc::{self, Channel, Receiver, Sender}; use embassy::executor::Spawner; @@ -21,7 +20,9 @@ use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; use embassy_stm32::peripherals::PA0; use embassy_stm32::Peripherals; -use example_common::*; + +use defmt_rtt as _; // global logger +use panic_probe as _; struct Leds<'a> { leds: [Output<'a, AnyPin>; 8], diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index b11f38ea5..68d166367 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/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/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index 9a67419fb..a79d6838c 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/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/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index 9d9754833..1c9401549 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs @@ -57,9 +57,9 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; +use defmt::*; +use defmt_rtt as _; // global logger +use panic_probe as _; use cortex_m_rt::entry; use embassy::executor::{Executor, InterruptExecutor}; diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index bd66b1202..6d80c4087 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs @@ -2,16 +2,16 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use core::fmt::Write; use core::str::from_utf8; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; -use example_common::*; use heapless::String; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 0e67bb1f1..859749eb7 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs @@ -2,15 +2,15 @@ #![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 heapless::String; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f3/src/example_common.rs b/examples/stm32f3/src/example_common.rs deleted file mode 100644 index e14517033..000000000 --- a/examples/stm32f3/src/example_common.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index c53f04e1c..1bc406495 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -7,7 +7,7 @@ resolver = "2" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "unstable-traits"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "usb-otg"] } defmt = "0.3" diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 0a6ddbbca..f0b1ad232 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.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::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; -use example_common::*; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index 00d67dac0..8b85ca96d 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/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/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index 24eef75b2..4f9af7fbd 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/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/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 852fbe3c6..78f2e6ee2 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/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/stm32f4/src/bin/can.rs b/examples/stm32f4/src/bin/can.rs index b36e41805..0f41d6860 100644 --- a/examples/stm32f4/src/bin/can.rs +++ b/examples/stm32f4/src/bin/can.rs @@ -2,15 +2,15 @@ #![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 cortex_m_rt::entry; +use defmt::*; use embassy_stm32::can::bxcan::filter::Mask32; use embassy_stm32::can::bxcan::{Frame, StandardId}; use embassy_stm32::can::Can; use embassy_stm32::gpio::{Input, Pull}; -use example_common::*; #[entry] fn main() -> ! { diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 56eb67bf3..92d87cedf 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/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/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index 9d9754833..1c9401549 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs @@ -57,9 +57,9 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; +use defmt::*; +use defmt_rtt as _; // global logger +use panic_probe as _; use cortex_m_rt::entry; use embassy::executor::{Executor, InterruptExecutor}; diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 2ef367397..eab0fad4a 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/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/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs index 6b04f1fed..69be81432 100644 --- a/examples/stm32f4/src/bin/spi.rs +++ b/examples/stm32f4/src/bin/spi.rs @@ -2,15 +2,15 @@ #![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 cortex_m_rt::entry; +use defmt::*; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use example_common::*; #[entry] fn main() -> ! { diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index 9171f7516..1bf9b856d 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -2,16 +2,16 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use core::fmt::Write; use core::str::from_utf8; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; -use example_common::*; use heapless::String; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs index b5ea98cca..a302667e2 100644 --- a/examples/stm32f4/src/bin/usart.rs +++ b/examples/stm32f4/src/bin/usart.rs @@ -2,12 +2,12 @@ #![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::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use example_common::*; +use panic_probe as _; #[entry] fn main() -> ! { diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 862a91ea8..cf45b71c5 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs @@ -2,15 +2,15 @@ #![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 heapless::String; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f4/src/bin/usb_uart.rs b/examples/stm32f4/src/bin/usb_uart.rs index 63059d51f..251ed1eb0 100644 --- a/examples/stm32f4/src/bin/usb_uart.rs +++ b/examples/stm32f4/src/bin/usb_uart.rs @@ -2,8 +2,8 @@ #![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::{info, unwrap}; use defmt_rtt as _; // global logger diff --git a/examples/stm32f4/src/bin/usb_uart_ulpi.rs b/examples/stm32f4/src/bin/usb_uart_ulpi.rs index a55502728..f6c373602 100644 --- a/examples/stm32f4/src/bin/usb_uart_ulpi.rs +++ b/examples/stm32f4/src/bin/usb_uart_ulpi.rs @@ -2,8 +2,8 @@ #![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::{info, unwrap}; use defmt_rtt as _; // global logger diff --git a/examples/stm32f4/src/example_common.rs b/examples/stm32f4/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32f4/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 3f6858340..3703f551f 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 00d67dac0..8b85ca96d 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 24eef75b2..4f9af7fbd 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 852fbe3c6..78f2e6ee2 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 15169d2dc..446756c29 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> = Forever::new(); static CONFIG: Forever = Forever::new(); static NET_RESOURCES: Forever> = 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 56eb67bf3..92d87cedf 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 57b913db9..dae07c303 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 00deae8b3..69fa21a0d 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 a786cb114..000000000 --- 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 -} diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index a72ba5344..9facbc5c7 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/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", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } defmt = "0.3" diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index 00d67dac0..8b85ca96d 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/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/stm32g0/src/bin/button.rs b/examples/stm32g0/src/bin/button.rs index e901c5750..78d7ba1f2 100644 --- a/examples/stm32g0/src/bin/button.rs +++ b/examples/stm32g0/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, Pull}; -use example_common::*; +use panic_probe as _; #[entry] fn main() -> ! { diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 848818bf2..4b1cadcb5 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/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/stm32g0/src/example_common.rs b/examples/stm32g0/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32g0/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 433a3673b..7a1f5a9fa 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/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", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index 1dc67f99e..92ec2b579 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/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/stm32g4/src/bin/button.rs b/examples/stm32g4/src/bin/button.rs index 8c0d7d4fe..f6c981309 100644 --- a/examples/stm32g4/src/bin/button.rs +++ b/examples/stm32g4/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, Pull}; -use example_common::*; +use panic_probe as _; #[entry] fn main() -> ! { diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 852fbe3c6..78f2e6ee2 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/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/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index fb71c8b7d..3770f6f36 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs @@ -2,14 +2,14 @@ #![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::pwm::{simple_pwm::SimplePwm, Channel}; use embassy_stm32::time::U32Ext; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32g4/src/example_common.rs b/examples/stm32g4/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32g4/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 2e761df8f..5c8861af5 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -8,7 +8,7 @@ resolver = "2" [features] [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", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } embassy-hal-common = { path = "../../embassy-hal-common", default-features = false, features = ["defmt"] } diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 7e5934239..2329125a6 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/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/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 852fbe3c6..78f2e6ee2 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/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/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index f87b27f4f..3311ba858 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -10,23 +10,12 @@ use embassy_stm32::i2c::I2c; use embassy_stm32::interrupt; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; use embassy_stm32::Peripherals; use defmt_rtt as _; // global logger use panic_probe as _; -use core::sync::atomic::{AtomicUsize, Ordering}; -use embassy_stm32::Config; - -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(); diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index 8353405ad..86c874a6a 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs @@ -2,13 +2,22 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; - -use example_common::*; +use defmt_rtt as _; // global logger +use panic_probe as _; use cortex_m_rt::entry; +use defmt::*; use embassy_stm32::dac::{Channel, Dac, Value}; +use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; + +pub fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(400.mhz().into()); + config.rcc.hclk = Some(200.mhz().into()); + config.rcc.pll1.q_ck = Some(100.mhz().into()); + config +} #[entry] fn main() -> ! { diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 47d8c5c56..4eb5421a8 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -2,14 +2,11 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use embassy_stm32::peripherals::ETH; -use example_common::config; +use defmt_rtt as _; // global logger +use panic_probe as _; 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,11 +16,13 @@ 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; #[embassy::task] async fn main_task( @@ -87,6 +86,15 @@ static ETH: Forever> = Forever::new(); static CONFIG: Forever = Forever::new(); static NET_RESOURCES: Forever> = Forever::new(); +#[allow(unused)] +pub fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(400.mhz().into()); + config.rcc.hclk = Some(200.mhz().into()); + config.rcc.pll1.q_ck = Some(100.mhz().into()); + config +} + #[entry] fn main() -> ! { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index b9ac1318e..ba8215d6a 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs @@ -2,13 +2,23 @@ #![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::{Delay, Duration, Timer}; use embassy_stm32::fmc::Fmc; +use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; + +pub fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(400.mhz().into()); + config.rcc.hclk = Some(200.mhz().into()); + config.rcc.pll1.q_ck = Some(100.mhz().into()); + config +} #[embassy::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 3a47dc22b..9ddfd8b27 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -2,10 +2,11 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use core::marker::PhantomData; +use defmt_rtt as _; // global logger +use panic_probe as _; +use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy::util::Unborrow; @@ -15,7 +16,6 @@ use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; use embassy_stm32::time::{Hertz, U32Ext}; use embassy_stm32::{Config, Peripherals}; -use example_common::*; pub fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index f27bd8ef8..a6735036f 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs @@ -2,14 +2,14 @@ #![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::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index b3edbde68..c33ba066e 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -2,14 +2,14 @@ #![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::pwm::{simple_pwm::SimplePwm, Channel}; use embassy_stm32::time::U32Ext; use embassy_stm32::{Config, Peripherals}; -use example_common::*; +use panic_probe as _; pub fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index 932cfcb8b..b914fa709 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs @@ -2,12 +2,12 @@ #![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::rng::Rng; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 19c4deed1..c3b2ebcda 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/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/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 17e64da79..a0acb03db 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -2,22 +2,30 @@ #![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 core::fmt::Write; +use core::str::from_utf8; +use cortex_m_rt::entry; +use defmt::*; use embassy::executor::Executor; use embassy::util::Forever; use embassy_stm32::dma::NoDma; -use embassy_stm32::spi; -use example_common::*; - -use core::str::from_utf8; -use cortex_m_rt::entry; use embassy_stm32::peripherals::SPI3; +use embassy_stm32::spi; use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; use heapless::String; +pub fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(400.mhz().into()); + config.rcc.hclk = Some(200.mhz().into()); + config.rcc.pll1.q_ck = Some(100.mhz().into()); + config +} + #[embassy::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { for n in 0u32.. { diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 15ae09973..8f77b1d09 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -2,21 +2,29 @@ #![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 core::fmt::Write; -use embassy::executor::Executor; -use embassy::util::Forever; -use embassy_stm32::time::U32Ext; -use example_common::*; - use core::str::from_utf8; use cortex_m_rt::entry; +use defmt::*; +use embassy::executor::Executor; +use embassy::util::Forever; use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; use embassy_stm32::spi; +use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; use heapless::String; +pub fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(400.mhz().into()); + config.rcc.hclk = Some(200.mhz().into()); + config.rcc.pll1.q_ck = Some(100.mhz().into()); + config +} + #[embassy::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { for n in 0u32.. { diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 211e57cda..0982a6ac6 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.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::Executor; use embassy::util::Forever; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use example_common::*; +use panic_probe as _; use cortex_m_rt::entry; diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index a9221e1b6..74de8b2a3 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/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::Executor; use embassy::util::Forever; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use example_common::*; +use panic_probe as _; use cortex_m_rt::entry; use heapless::String; diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index b112290f9..ee1763aa4 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -2,8 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::blocking_mutex::raw::NoopRawMutex; use embassy::channel::mpsc::{self, Channel, Sender}; use embassy::executor::Spawner; @@ -14,7 +14,7 @@ use embassy_stm32::{ usart::{Config, Uart, UartRx}, Peripherals, }; -use example_common::*; +use panic_probe as _; #[embassy::task] async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { diff --git a/examples/stm32h7/src/example_common.rs b/examples/stm32h7/src/example_common.rs deleted file mode 100644 index b8acc2790..000000000 --- a/examples/stm32h7/src/example_common.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // global logger -use panic_probe as _; - -pub use defmt::*; - -use core::sync::atomic::{AtomicUsize, Ordering}; -use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; - -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(400.mhz().into()); - config.rcc.hclk = Some(200.mhz().into()); - config.rcc.pll1.q_ck = Some(100.mhz().into()); - config -} diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index ce4efa52c..8063e6c7e 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -10,7 +10,7 @@ default = ["nightly"] nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan-encoding"] [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 = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true} diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 46e29a897..72f13f06d 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.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::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use example_common::*; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index 046c43caf..dfa91259a 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -2,12 +2,12 @@ #![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::gpio::{Input, Level, Output, Pull, 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/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 3edea3976..b1892e2c6 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.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::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use example_common::*; fn config() -> embassy_stm32::Config { let mut config = embassy_stm32::Config::default(); diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index df08ba18c..22304f8e5 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -6,8 +6,8 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt_rtt as _; // global logger +use panic_probe as _; use embassy_lora::{sx127x::*, LoraTimer}; use embassy_stm32::{ diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index 9bb087c9e..4601d85df 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs @@ -1,9 +1,9 @@ #![no_std] #![no_main] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; +use defmt::*; +use defmt_rtt as _; // global logger +use panic_probe as _; use core::mem; use cortex_m_rt::entry; diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 8d6e89d91..5ed783b10 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -2,12 +2,12 @@ #![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::gpio::{Level, Output, Speed}; -use example_common::*; use embassy_stm32::dma::NoDma; use embassy_stm32::spi::{Config, Spi}; diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 543e66f62..b3fdcacbe 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs @@ -2,10 +2,10 @@ #![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 example_common::*; +use defmt::*; use embassy::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index 588073902..abb27fa4f 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -2,10 +2,10 @@ #![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 example_common::*; +use defmt::*; use embassy::executor::Spawner; use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; diff --git a/examples/stm32l0/src/example_common.rs b/examples/stm32l0/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32l0/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 0cdf59162..a7a6c228e 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/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", "stm32l151cb-a", "time-driver-any", "memory-x"] } defmt = "0.3" diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index 07c804e9f..e81455524 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.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::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use example_common::*; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index e97e3ebb4..bced0c54e 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs @@ -2,12 +2,12 @@ #![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::gpio::{Level, Output, Speed}; -use example_common::*; use embassy_stm32::dma::NoDma; use embassy_stm32::spi::{Config, Spi}; diff --git a/examples/stm32l1/src/example_common.rs b/examples/stm32l1/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32l1/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 4b1f9a912..0709a8f5b 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -8,7 +8,7 @@ resolver = "2" [features] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt" ] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } embassy-traits = { version = "0.1.0", path = "../../embassy-traits" } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index 83c54222d..58ef6ebaa 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs @@ -2,13 +2,13 @@ #![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::time::Delay; use embassy_stm32::adc::{Adc, Resolution}; use embassy_stm32::pac; -use example_common::*; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 030283756..e24a5bd37 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/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/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index 6073c137e..ff270b519 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs @@ -2,10 +2,10 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; +use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Pull}; -use example_common::*; +use panic_probe as _; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 848818bf2..4b1cadcb5 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/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/stm32l4/src/bin/dac.rs b/examples/stm32l4/src/bin/dac.rs index 201ba473b..c26e7e709 100644 --- a/examples/stm32l4/src/bin/dac.rs +++ b/examples/stm32l4/src/bin/dac.rs @@ -2,12 +2,12 @@ #![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_stm32::dac::{Channel, Dac, Value}; use embassy_stm32::pac; -use example_common::*; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index 615012a06..467765642 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs @@ -2,16 +2,16 @@ #![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::dma::NoDma; use embassy_stm32::i2c::I2c; use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; -use example_common::{info, unwrap}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index 07077f9fb..136aea849 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs @@ -2,9 +2,10 @@ #![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::dma::NoDma; use embassy_stm32::i2c::I2c; @@ -13,7 +14,6 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use embassy_traits::adapter::BlockingAsync; use embedded_hal_async::i2c::I2c as I2cTrait; -use example_common::{info, unwrap}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index d77bee8c1..886a0e09f 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs @@ -2,15 +2,15 @@ #![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::i2c::I2c; use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; -use example_common::{info, unwrap}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index 37db9e05a..5f75c1ff1 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.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::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; use embassy_stm32::{Config, Peripherals}; -use example_common::*; +use panic_probe as _; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32l4/src/bin/spi.rs b/examples/stm32l4/src/bin/spi.rs index 8567d3062..44fdf81a8 100644 --- a/examples/stm32l4/src/bin/spi.rs +++ b/examples/stm32l4/src/bin/spi.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_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use example_common::*; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index 89925d309..0398965d3 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -2,9 +2,10 @@ #![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::dma::NoDma; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; @@ -13,7 +14,6 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use embassy_traits::adapter::BlockingAsync; use embedded_hal_async::spi::SpiBus; -use example_common::*; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index a9327f8fe..88d02c7e1 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -2,15 +2,15 @@ #![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::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; -use example_common::*; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/usart.rs b/examples/stm32l4/src/bin/usart.rs index 00875c896..b38f55456 100644 --- a/examples/stm32l4/src/bin/usart.rs +++ b/examples/stm32l4/src/bin/usart.rs @@ -2,12 +2,12 @@ #![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_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use example_common::*; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/usart_blocking_async.rs b/examples/stm32l4/src/bin/usart_blocking_async.rs index dae673a5d..7efccace5 100644 --- a/examples/stm32l4/src/bin/usart_blocking_async.rs +++ b/examples/stm32l4/src/bin/usart_blocking_async.rs @@ -2,16 +2,16 @@ #![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::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use embassy_traits::adapter::BlockingAsync; use embedded_hal_async::serial::{Read, Write}; -use example_common::*; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index b3a1e3897..40e2c3671 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -2,15 +2,15 @@ #![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 heapless::String; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/example_common.rs b/examples/stm32l4/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32l4/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 87e69c68a..e518195bc 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml @@ -6,8 +6,8 @@ version = "0.1.0" resolver = "2" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "memory-x" ] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } defmt = "0.3" defmt-rtt = "0.3" diff --git a/examples/stm32u5/src/bin/boot.rs b/examples/stm32u5/src/bin/boot.rs index 23cfc3061..e04021349 100644 --- a/examples/stm32u5/src/bin/boot.rs +++ b/examples/stm32u5/src/bin/boot.rs @@ -2,9 +2,9 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use example_common::*; +use defmt::*; +use defmt_rtt as _; // global logger +use panic_probe as _; use embassy_stm32 as _; diff --git a/examples/stm32u5/src/example_common.rs b/examples/stm32u5/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32u5/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32wb55/Cargo.toml b/examples/stm32wb55/Cargo.toml index bd066ef05..8997d411d 100644 --- a/examples/stm32wb55/Cargo.toml +++ b/examples/stm32wb55/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", "stm32wb55cc", "time-driver-any", "exti"] } defmt = "0.3" diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs index e1dbb30de..59324161a 100644 --- a/examples/stm32wb55/src/bin/blinky.rs +++ b/examples/stm32wb55/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/stm32wb55/src/bin/button_exti.rs b/examples/stm32wb55/src/bin/button_exti.rs index 4592fa308..a30a4a216 100644 --- a/examples/stm32wb55/src/bin/button_exti.rs +++ b/examples/stm32wb55/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/stm32wb55/src/example_common.rs b/examples/stm32wb55/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32wb55/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -} diff --git a/examples/stm32wl55/Cargo.toml b/examples/stm32wl55/Cargo.toml index 4901ea693..97b38aeab 100644 --- a/examples/stm32wl55/Cargo.toml +++ b/examples/stm32wl55/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", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time"] } diff --git a/examples/stm32wl55/src/bin/blinky.rs b/examples/stm32wl55/src/bin/blinky.rs index 9ec208c3d..78079bfd3 100644 --- a/examples/stm32wl55/src/bin/blinky.rs +++ b/examples/stm32wl55/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/stm32wl55/src/bin/button.rs b/examples/stm32wl55/src/bin/button.rs index be8f60e26..f80b9ab4f 100644 --- a/examples/stm32wl55/src/bin/button.rs +++ b/examples/stm32wl55/src/bin/button.rs @@ -2,10 +2,10 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; +use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use example_common::*; +use panic_probe as _; use cortex_m_rt::entry; diff --git a/examples/stm32wl55/src/bin/button_exti.rs b/examples/stm32wl55/src/bin/button_exti.rs index 8d66c7258..9a427c2d3 100644 --- a/examples/stm32wl55/src/bin/button_exti.rs +++ b/examples/stm32wl55/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/stm32wl55/src/bin/lorawan.rs b/examples/stm32wl55/src/bin/lorawan.rs index 5d26dead2..db4725630 100644 --- a/examples/stm32wl55/src/bin/lorawan.rs +++ b/examples/stm32wl55/src/bin/lorawan.rs @@ -5,8 +5,8 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt_rtt as _; // global logger +use panic_probe as _; use embassy_lora::{stm32wl::*, LoraTimer}; use embassy_stm32::{ diff --git a/examples/stm32wl55/src/bin/subghz.rs b/examples/stm32wl55/src/bin/subghz.rs index 42d4eb64c..562e25ac0 100644 --- a/examples/stm32wl55/src/bin/subghz.rs +++ b/examples/stm32wl55/src/bin/subghz.rs @@ -5,9 +5,10 @@ #![feature(generic_associated_types)] #![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::channel::signal::Signal; use embassy::interrupt::{Interrupt, InterruptExt}; use embassy_stm32::dma::NoDma; @@ -16,7 +17,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::interrupt; use embassy_stm32::subghz::*; use embassy_stm32::Peripherals; -use example_common::unwrap; const PING_DATA: &str = "PING"; const DATA_LEN: u8 = PING_DATA.len() as u8; diff --git a/examples/stm32wl55/src/example_common.rs b/examples/stm32wl55/src/example_common.rs deleted file mode 100644 index 54d633837..000000000 --- a/examples/stm32wl55/src/example_common.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; // 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 - } -}