Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared fmt crate #3133

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cyw43/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ repository = "https://github.com/embassy-rs/embassy"
documentation = "https://docs.embassy.dev/cyw43"

[features]
defmt = ["dep:defmt", "heapless/defmt-03", "embassy-time/defmt"]
log = ["dep:log"]
defmt = ["dep:defmt", "heapless/defmt-03", "embassy-time/defmt", "embassy-fmt/defmt", "embassy-futures/defmt", "embassy-sync/defmt", "embassy-net-driver-channel/defmt"]
log = ["dep:log", "embassy-fmt/log"]

# Fetch console logs from the WiFi firmware and forward them to `log` or `defmt`.
firmware-logs = []
Expand All @@ -33,6 +33,7 @@ embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
num_enum = { version = "0.5.7", default-features = false }

heapless = "0.8.0"
embassy-fmt = { version = "0.1.0", path = "../embassy-fmt" }

[package.metadata.embassy_docs]
src_base = "https://github.com/embassy-rs/embassy/blob/cyw43-v$VERSION/cyw43/src/"
Expand Down
2 changes: 1 addition & 1 deletion cyw43/src/control.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use core::cmp::{max, min};
use core::iter::zip;

use embassy_fmt::Bytes;
use embassy_net_driver_channel as ch;
use embassy_net_driver_channel::driver::{HardwareAddress, LinkState};
use embassy_time::{Duration, Timer};

use crate::consts::*;
use crate::events::{Event, EventSubscriber, Events};
use crate::fmt::Bytes;
use crate::ioctl::{IoctlState, IoctlType};
use crate::structs::*;
use crate::{countries, events, PowerManagementMode};
Expand Down
3 changes: 1 addition & 2 deletions cyw43/src/ioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use core::cell::{Cell, RefCell};
use core::future::poll_fn;
use core::task::{Poll, Waker};

use embassy_fmt::Bytes;
use embassy_sync::waitqueue::WakerRegistration;

use crate::fmt::Bytes;

#[derive(Clone, Copy)]
pub enum IoctlType {
Get = 0,
Expand Down
6 changes: 4 additions & 2 deletions cyw43/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]

// This mod MUST go first, so that the others see its macros.
pub(crate) mod fmt;
// This crate MUST go first, and use the old `extern crate` syntax, so that textual scope is used
// and these macros become globally available here.
#[macro_use]
extern crate embassy_fmt;

mod bus;
mod consts;
Expand Down
2 changes: 1 addition & 1 deletion cyw43/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use embassy_fmt::Bytes;
use embassy_futures::select::{select3, Either3};
use embassy_net_driver_channel as ch;
use embassy_time::{block_for, Duration, Timer};
Expand All @@ -7,7 +8,6 @@ use crate::bus::Bus;
pub use crate::bus::SpiBusCyw43;
use crate::consts::*;
use crate::events::{Event, Events, Status};
use crate::fmt::Bytes;
use crate::ioctl::{IoctlState, IoctlType, PendingIoctl};
use crate::nvram::NVRAM;
use crate::structs::*;
Expand Down
3 changes: 2 additions & 1 deletion cyw43/src/structs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use embassy_fmt::Bytes;

use crate::events::Event;
use crate::fmt::Bytes;

macro_rules! impl_bytes {
($t:ident) => {
Expand Down
2 changes: 2 additions & 0 deletions embassy-boot-nrf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ embedded-storage-async = { version = "0.4.1" }
cfg-if = "1.0.0"

nrf-softdevice-mbr = { version = "0.2.0", optional = true }
embassy-fmt = { version = "0.1.0", path = "../embassy-fmt" }

[features]
defmt = [
"dep:defmt",
"embassy-boot/defmt",
"embassy-nrf/defmt",
"embassy-fmt/defmt",
]
softdevice = [
"nrf-softdevice-mbr",
Expand Down
274 changes: 0 additions & 274 deletions embassy-boot-nrf/src/fmt.rs

This file was deleted.

6 changes: 5 additions & 1 deletion embassy-boot-nrf/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_std]
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
mod fmt;

pub use embassy_boot::{
AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootError, BootLoaderConfig, FirmwareState,
Expand All @@ -12,6 +11,11 @@ use embassy_nrf::peripherals::WDT;
use embassy_nrf::wdt;
use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};

// This crate MUST go first, and use the old `extern crate` syntax, so that textual scope is used
// and these macros become globally available here.
#[macro_use]
extern crate embassy_fmt;

/// A bootloader for nRF devices.
pub struct BootLoader<const BUFFER_SIZE: usize = PAGE_SIZE>;

Expand Down
Loading