fmt: make all macros macro_rules
so scoping is consistent.
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
use crate::dac::{DacPin, Instance};
|
||||
use crate::fmt::*;
|
||||
use crate::gpio::AnyPin;
|
||||
use crate::pac::dac;
|
||||
use core::marker::PhantomData;
|
||||
|
@ -5,7 +5,6 @@ use embassy::util::AtomicWaker;
|
||||
use futures::future::poll_fn;
|
||||
|
||||
use super::*;
|
||||
use crate::fmt::assert;
|
||||
use crate::interrupt;
|
||||
use crate::pac;
|
||||
use crate::pac::dma::{regs, vals};
|
||||
|
@ -1,69 +1,170 @@
|
||||
#![macro_use]
|
||||
#![allow(clippy::module_inception)]
|
||||
#![allow(unused)]
|
||||
#![allow(unused_macros)]
|
||||
|
||||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
pub use fmt::*;
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::assert!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::assert!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::assert_eq!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::assert_eq!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::assert_ne!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::assert_ne!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::debug_assert!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug_assert!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::debug_assert_eq!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug_assert_eq!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::debug_assert_ne!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug_assert_ne!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::todo!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::todo!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::panic!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::panic!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! trace {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::trace!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::trace!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(fevature = "log")]
|
||||
log::debug!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! info {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::info!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::info!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! warn {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::warn!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::warn!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! error {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::error!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::error!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
mod fmt {
|
||||
pub use defmt::{
|
||||
assert, assert_eq, assert_ne, debug, debug_assert, debug_assert_eq, debug_assert_ne, error,
|
||||
info, panic, todo, trace, unreachable, unwrap, warn,
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
defmt::unwrap!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "log")]
|
||||
mod fmt {
|
||||
pub use core::{
|
||||
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo,
|
||||
unreachable,
|
||||
};
|
||||
pub use log::{debug, error, info, trace, warn};
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "defmt", feature = "log")))]
|
||||
mod fmt {
|
||||
#![macro_use]
|
||||
|
||||
pub use core::{
|
||||
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo,
|
||||
unreachable,
|
||||
};
|
||||
|
||||
macro_rules! trace {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! info {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! warn {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! error {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
|
@ -2,7 +2,6 @@ use core::marker::PhantomData;
|
||||
|
||||
use embassy::util::Unborrow;
|
||||
|
||||
use crate::fmt::{assert, panic};
|
||||
use crate::pac::rcc::vals::Timpre;
|
||||
use crate::pac::{DBGMCU, RCC, SYSCFG};
|
||||
use crate::peripherals;
|
||||
|
@ -1,5 +1,4 @@
|
||||
use super::{Hertz, RCC};
|
||||
use crate::fmt::assert;
|
||||
|
||||
const VCO_MIN: u32 = 150_000_000;
|
||||
const VCO_MAX: u32 = 420_000_000;
|
||||
|
@ -10,7 +10,6 @@ use embassy_extras::unborrow;
|
||||
use futures::future::poll_fn;
|
||||
use sdio_host::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CID, CSD, OCR, SCR};
|
||||
|
||||
use crate::fmt::*;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::pac;
|
||||
use crate::pac::gpio::Gpio;
|
||||
@ -434,7 +433,7 @@ impl SdmmcInner {
|
||||
BusWidth::One => 0,
|
||||
BusWidth::Four => 1,
|
||||
BusWidth::Eight => 2,
|
||||
_ => self::panic!("Invalid Bus Width"),
|
||||
_ => panic!("Invalid Bus Width"),
|
||||
})
|
||||
});
|
||||
|
||||
@ -637,7 +636,7 @@ impl SdmmcInner {
|
||||
direction: Dir,
|
||||
data_transfer_timeout: u32,
|
||||
) {
|
||||
self::assert!(block_size <= 14, "Block size up to 2^14 bytes");
|
||||
assert!(block_size <= 14, "Block size up to 2^14 bytes");
|
||||
let regs = self.0;
|
||||
|
||||
let dtdir = match direction {
|
||||
@ -678,7 +677,7 @@ impl SdmmcInner {
|
||||
// Enforce AHB and SDMMC_CK clock relation. See RM0433 Rev 7
|
||||
// Section 55.5.8
|
||||
let sdmmc_bus_bandwidth = new_clock.0 * (width as u32);
|
||||
self::assert!(hclk.0 > 3 * sdmmc_bus_bandwidth / 32);
|
||||
assert!(hclk.0 > 3 * sdmmc_bus_bandwidth / 32);
|
||||
*clock = new_clock;
|
||||
|
||||
// NOTE(unsafe) We have exclusive access to the regblock
|
||||
|
Reference in New Issue
Block a user