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 7fdc27ff..a704eb3b 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 98b65600..810b4bd6 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 0fc004ed..4828b08f 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 a2602ea6..2cd163a9 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 397bb16f..7a356d14 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 f29dae02..339f779f 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 3ea9a6e6..dc6bd301 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 d50736d8..0cb18275 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 85e12690..e69f87d8 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 f3689563..7a57399f 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 99246eed..3c9a8148 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 68402ce2..7939e79e 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 85938f32..6fc42921 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 f4295814..3b2919ba 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 66717c59..1f3662c6 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 e5af7b46..8bfe1d50 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 c2ab0e7d..40863bf3 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 b2e6bfc1..ba60716c 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 4e264ef2..a8184cd6 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 d0bd6867..1d9d3ed5 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 a35a9fa8..4b4b3a19 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 bc6b2b52..5835be31 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 bdf552fb..5e357f79 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 cda3baa2..f2a4ab38 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 4b30b6ea..aa807910 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 f27081b7..ff8ee9a8 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 1ac3a394..08c61415 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 4a059643..45b347ea 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 5dc89df6..91f7f4fd 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 88dc185a..89336faa 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 19d438c4..909429b1 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 c345df9e..d283dccd 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 8fc61526..ef262984 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 cc199be9..431ccca8 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 54d63383..00000000 --- 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 830e5417..2cce0af3 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 96e45f69..6f199d07 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 6492367e..2418ad01 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 3348dc99..b3842436 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 b2854afc..bc93e061 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 8354f9f8..bc941dd8 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 f7c4ef57..00000000 --- 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 0f76dabf..c973c1f7 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 9f745f9a..975e94f3 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 54d63383..00000000 --- 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 79be4b51..5e5faf1f 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 d24f3f5c..af403423 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 0d953745..657bcdd1 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 efcb9a24..8054a899 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 54d63383..00000000 --- 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 ee1d7ce2..4eef3a6f 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 637c2f4f..395f4df5 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 e1451703..00000000 --- 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 3ce2bc8a..37f99fea 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 e8b8dc23..b3643a26 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 131d4af4..207381bd 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 0bd7b342..99aab302 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 b11f38ea..68d16636 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 9a67419f..a79d6838 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 9d975483..1c940154 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 bd66b120..6d80c408 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 0e67bb1f..859749eb 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 e1451703..00000000 --- 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 c53f04e1..1bc40649 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 0a6ddbbc..f0b1ad23 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 00d67dac..8b85ca96 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 24eef75b..4f9af7fb 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 852fbe3c..78f2e6ee 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 b36e4180..0f41d686 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 56eb67bf..92d87ced 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 9d975483..1c940154 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 2ef36739..eab0fad4 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 6b04f1fe..69be8143 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 9171f751..1bf9b856 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 b5ea98cc..a302667e 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 862a91ea..cf45b71c 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 63059d51..251ed1eb 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 a5550272..f6c37360 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 54d63383..00000000 --- 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 3f685834..3703f551 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" resolver = "2" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index 00d67dac..8b85ca96 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/src/bin/button.rs b/examples/stm32f7/src/bin/button.rs index 24eef75b..4f9af7fb 100644 --- a/examples/stm32f7/src/bin/button.rs +++ b/examples/stm32f7/src/bin/button.rs @@ -2,11 +2,11 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use cortex_m_rt::entry; +use defmt::*; +use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use example_common::*; +use panic_probe as _; #[entry] fn main() -> ! { diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 852fbe3c..78f2e6ee 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 15169d2d..446756c2 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -2,14 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; -use embassy_stm32::peripherals::ETH; -use example_common::config; - use cortex_m_rt::entry; -use defmt::{info, unwrap}; -use defmt_rtt as _; // global logger +use defmt::*; use embassy::executor::{Executor, Spawner}; use embassy::io::AsyncWriteExt; use embassy::time::{Duration, Timer}; @@ -19,12 +13,16 @@ use embassy_net::{ }; use embassy_stm32::eth::lan8742a::LAN8742A; use embassy_stm32::eth::{Ethernet, State}; +use embassy_stm32::interrupt; +use embassy_stm32::peripherals::ETH; +use embassy_stm32::peripherals::RNG; use embassy_stm32::rng::Rng; -use embassy_stm32::{interrupt, peripherals}; +use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; use heapless::Vec; -use panic_probe as _; -use peripherals::RNG; +use defmt_rtt as _; // global logger +use panic_probe as _; #[embassy::task] async fn main_task( @@ -88,6 +86,12 @@ static ETH: Forever> = 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 56eb67bf..92d87ced 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -9,8 +9,8 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Config; use embassy_stm32::Peripherals; -#[path = "../example_common.rs"] -mod example_common; +use defmt_rtt as _; // global logger +use panic_probe as _; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 57b913db..dae07c30 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; +use defmt_rtt as _; // global logger +use panic_probe as _; +use defmt::*; use embassy::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::U32Ext; use embassy_stm32::{interrupt, Config, Peripherals}; -use example_common::*; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 00deae8b..69fa21a0 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -#[path = "../example_common.rs"] -mod example_common; use core::fmt::Write; +use defmt::*; +use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; -use example_common::*; +use panic_probe as _; use heapless::String; diff --git a/examples/stm32f7/src/example_common.rs b/examples/stm32f7/src/example_common.rs deleted file mode 100644 index a786cb11..00000000 --- a/examples/stm32f7/src/example_common.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![macro_use] - -use defmt_rtt as _; -use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; -// global logger -use panic_probe as _; - -pub use defmt::*; - -use core::sync::atomic::{AtomicUsize, Ordering}; - -defmt::timestamp! {"{=u64}", { - static COUNT: AtomicUsize = AtomicUsize::new(0); - // NOTE(no-CAS) `timestamps` runs with interrupts disabled - let n = COUNT.load(Ordering::Relaxed); - COUNT.store(n + 1, Ordering::Relaxed); - n as u64 - } -} - -#[allow(unused)] -pub fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(200.mhz().into()); - config -} diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index a72ba534..9facbc5c 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 00d67dac..8b85ca96 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 e901c575..78d7ba1f 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 848818bf..4b1cadcb 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 54d63383..00000000 --- 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 433a3673..7a1f5a9f 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 1dc67f99..92ec2b57 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 8c0d7d4f..f6c98130 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 852fbe3c..78f2e6ee 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 fb71c8b7..3770f6f3 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 54d63383..00000000 --- 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 2e761df8..5c8861af 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 7e593423..2329125a 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 852fbe3c..78f2e6ee 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 f87b27f4..3311ba85 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 8353405a..86c874a6 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 47d8c5c5..4eb5421a 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 b9ac1318..ba8215d6 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 3a47dc22..9ddfd8b2 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 f27bd8ef..a6735036 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 b3edbde6..c33ba066 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 932cfcb8..b914fa70 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 19c4deed..c3b2ebcd 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 17e64da7..a0acb03d 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 15ae0997..8f77b1d0 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 211e57cd..0982a6ac 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 a9221e1b..74de8b2a 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 b112290f..ee1763aa 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 b8acc279..00000000 --- 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 ce4efa52..8063e6c7 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 46e29a89..72f13f06 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 046c43ca..dfa91259 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 3edea397..b1892e2c 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 df08ba18..22304f8e 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 9bb087c9..4601d85d 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 8d6e89d9..5ed783b1 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 543e66f6..b3fdcacb 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 58807390..abb27fa4 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 54d63383..00000000 --- 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 0cdf5916..a7a6c228 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 07c804e9..e8145552 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 e97e3ebb..bced0c54 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 54d63383..00000000 --- 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 4b1f9a91..0709a8f5 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 83c54222..58ef6eba 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 03028375..e24a5bd3 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 6073c137..ff270b51 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 848818bf..4b1cadcb 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 201ba473..c26e7e70 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 615012a0..46776564 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 07077f9f..136aea84 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 d77bee8c..886a0e09 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 37db9e05..5f75c1ff 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 8567d306..44fdf81a 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 89925d30..0398965d 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 a9327f8f..88d02c7e 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 00875c89..b38f5545 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 dae673a5..7efccace 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 b3a1e389..40e2c367 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 54d63383..00000000 --- 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 87e69c68..e518195b 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 23cfc306..e0402134 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 54d63383..00000000 --- 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 bd066ef0..8997d411 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 e1dbb30d..59324161 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 4592fa30..a30a4a21 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 54d63383..00000000 --- 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 4901ea69..97b38aea 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 9ec208c3..78079bfd 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 be8f60e2..f80b9ab4 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 8d66c725..9a427c2d 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 5d26dead..db472563 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 42d4eb64..562e25ac 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 54d63383..00000000 --- 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 - } -}