Merge pull request #227 from embassy-rs/fmt2

fmt: make all macros `macro_rules` so scoping is consistent.
This commit is contained in:
Dario Nieuwenhuis 2021-06-07 03:29:09 +02:00 committed by GitHub
commit 2685dbfcf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 1015 additions and 380 deletions

View File

@ -3,8 +3,8 @@
"editor.formatOnSave": true, "editor.formatOnSave": true,
"rust-analyzer.checkOnSave.allFeatures": false, "rust-analyzer.checkOnSave.allFeatures": false,
"rust-analyzer.checkOnSave.allTargets": false, "rust-analyzer.checkOnSave.allTargets": false,
//"rust-analyzer.cargo.target": "thumbv7em-none-eabi", "rust-analyzer.cargo.target": "thumbv7em-none-eabi",
//"rust-analyzer.checkOnSave.target": "thumbv7em-none-eabi", "rust-analyzer.checkOnSave.target": "thumbv7em-none-eabi",
"rust-analyzer.procMacro.enable": true, "rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.loadOutDirsFromCheck": true, "rust-analyzer.cargo.loadOutDirsFromCheck": true,
"files.watcherExclude": { "files.watcherExclude": {

View File

@ -1,67 +1,178 @@
#![macro_use] #![macro_use]
#![allow(clippy::module_inception)] #![allow(unused_macros)]
#![allow(unused)]
#[cfg(all(feature = "defmt", feature = "log"))] #[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features."); 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")] #[cfg(feature = "defmt")]
mod fmt { ::defmt::assert!($($x)*);
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,
}; };
} }
#[cfg(feature = "log")] macro_rules! assert_eq {
mod fmt { ($($x:tt)*) => {
pub use core::{ {
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(not(feature = "defmt"))]
unreachable, ::core::assert_eq!($($x)*);
#[cfg(feature = "defmt")]
::defmt::assert_eq!($($x)*);
}
}; };
pub use log::{debug, error, info, trace, warn};
} }
#[cfg(not(any(feature = "defmt", feature = "log")))] macro_rules! assert_ne {
mod fmt { ($($x:tt)*) => {
#![macro_use] {
#[cfg(not(feature = "defmt"))]
pub use core::{ ::core::assert_ne!($($x)*);
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(feature = "defmt")]
unreachable, ::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 { macro_rules! trace {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::trace!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::trace!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! debug { macro_rules! debug {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::debug!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::debug!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! info { macro_rules! info {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::info!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::info!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! warn { macro_rules! warn {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::warn!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::warn!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! error { macro_rules! error {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::error!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::error!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
#[cfg(feature = "defmt")]
macro_rules! unwrap {
($($x:tt)*) => {
::defmt::unwrap!($($x)*)
};
} }
#[cfg(not(feature = "defmt"))] #[cfg(not(feature = "defmt"))]

View File

@ -1,5 +1,3 @@
use crate::fmt::assert;
pub struct RingBuffer<'a> { pub struct RingBuffer<'a> {
buf: &'a mut [u8], buf: &'a mut [u8],
start: usize, start: usize,

View File

@ -4,7 +4,6 @@ use smoltcp::time::Instant;
use super::*; use super::*;
use crate::device::LinkState; use crate::device::LinkState;
use crate::fmt::*;
use crate::{Interface, SocketSet}; use crate::{Interface, SocketSet};
pub struct DhcpConfigurator { pub struct DhcpConfigurator {

View File

@ -2,7 +2,6 @@ use heapless::Vec;
use smoltcp::time::Instant; use smoltcp::time::Instant;
use smoltcp::wire::{Ipv4Address, Ipv4Cidr}; use smoltcp::wire::{Ipv4Address, Ipv4Cidr};
use crate::fmt::*;
use crate::{Interface, SocketSet}; use crate::{Interface, SocketSet};
mod statik; mod statik;

View File

@ -1,7 +1,6 @@
use smoltcp::time::Instant; use smoltcp::time::Instant;
use super::*; use super::*;
use crate::fmt::*;
use crate::{Interface, SocketSet}; use crate::{Interface, SocketSet};
pub struct StaticConfigurator { pub struct StaticConfigurator {

View File

@ -3,7 +3,6 @@ use smoltcp::phy::Device as SmolDevice;
use smoltcp::phy::DeviceCapabilities; use smoltcp::phy::DeviceCapabilities;
use smoltcp::time::Instant as SmolInstant; use smoltcp::time::Instant as SmolInstant;
use crate::fmt::*;
use crate::packet_pool::PacketBoxExt; use crate::packet_pool::PacketBoxExt;
use crate::Result; use crate::Result;
use crate::{Packet, PacketBox, PacketBuf}; use crate::{Packet, PacketBox, PacketBuf};

View File

@ -1,74 +1,181 @@
#![macro_use] #![macro_use]
#![allow(unused_macros)]
#[cfg(all(feature = "defmt", feature = "log"))] #[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features."); 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 {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::trace!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::trace!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! debug {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::debug!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::debug!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! info {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::info!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::info!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! warn {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::warn!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::warn!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! error {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::error!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::error!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
#[cfg(feature = "defmt")] #[cfg(feature = "defmt")]
mod fmt { macro_rules! unwrap {
pub use defmt::{ ($($x:tt)*) => {
assert, assert_eq, assert_ne, debug, debug_assert, debug_assert_eq, debug_assert_ne, error, ::defmt::unwrap!($($x)*)
info, panic, todo, trace, unreachable, unwrap, warn,
}; };
} }
#[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_export]
macro_rules! trace {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! debug {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! info {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! warn {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! error {
($($msg:expr),+ $(,)?) => {
()
};
}
}
#[cfg(not(feature = "defmt"))] #[cfg(not(feature = "defmt"))]
#[macro_export]
macro_rules! unwrap { macro_rules! unwrap {
($arg:expr) => { ($arg:expr) => {
match $crate::fmt::Try::into_result($arg) { match $crate::fmt::Try::into_result($arg) {

View File

@ -20,7 +20,6 @@ use smoltcp::wire::{IpAddress, IpCidr, Ipv4Address, Ipv4Cidr};
use crate::config::Configurator; use crate::config::Configurator;
use crate::config::Event; use crate::config::Event;
use crate::device::{Device, DeviceAdapter, LinkState}; use crate::device::{Device, DeviceAdapter, LinkState};
use crate::fmt::*;
use crate::{Interface, SocketSet}; use crate::{Interface, SocketSet};
const ADDRESSES_LEN: usize = 1; const ADDRESSES_LEN: usize = 1;

View File

@ -11,7 +11,6 @@ use smoltcp::time::Duration;
use smoltcp::wire::IpEndpoint; use smoltcp::wire::IpEndpoint;
use super::stack::Stack; use super::stack::Stack;
use crate::fmt::*;
use crate::{Error, Result}; use crate::{Error, Result};
pub struct TcpSocket<'a> { pub struct TcpSocket<'a> {

View File

@ -11,7 +11,6 @@ use embassy_extras::peripheral::{PeripheralMutex, PeripheralState};
use embassy_extras::ring_buffer::RingBuffer; use embassy_extras::ring_buffer::RingBuffer;
use embassy_extras::{low_power_wait_until, unborrow}; use embassy_extras::{low_power_wait_until, unborrow};
use crate::fmt::{panic, *};
use crate::gpio::sealed::Pin as _; use crate::gpio::sealed::Pin as _;
use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin}; use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin};
use crate::pac; use crate::pac;

View File

@ -1,67 +1,178 @@
#![macro_use] #![macro_use]
#![allow(clippy::module_inception)] #![allow(unused_macros)]
#![allow(unused)]
#[cfg(all(feature = "defmt", feature = "log"))] #[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features."); 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")] #[cfg(feature = "defmt")]
mod fmt { ::defmt::assert!($($x)*);
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,
}; };
} }
#[cfg(feature = "log")] macro_rules! assert_eq {
mod fmt { ($($x:tt)*) => {
pub use core::{ {
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(not(feature = "defmt"))]
unreachable, ::core::assert_eq!($($x)*);
#[cfg(feature = "defmt")]
::defmt::assert_eq!($($x)*);
}
}; };
pub use log::{debug, error, info, trace, warn};
} }
#[cfg(not(any(feature = "defmt", feature = "log")))] macro_rules! assert_ne {
mod fmt { ($($x:tt)*) => {
#![macro_use] {
#[cfg(not(feature = "defmt"))]
pub use core::{ ::core::assert_ne!($($x)*);
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(feature = "defmt")]
unreachable, ::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 { macro_rules! trace {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::trace!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::trace!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! debug { macro_rules! debug {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::debug!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::debug!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! info { macro_rules! info {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::info!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::info!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! warn { macro_rules! warn {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::warn!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::warn!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! error { macro_rules! error {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::error!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::error!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
#[cfg(feature = "defmt")]
macro_rules! unwrap {
($($x:tt)*) => {
::defmt::unwrap!($($x)*)
};
} }
#[cfg(not(feature = "defmt"))] #[cfg(not(feature = "defmt"))]

View File

@ -6,7 +6,6 @@ use core::sync::atomic::{compiler_fence, Ordering};
use embassy::util::Unborrow; use embassy::util::Unborrow;
use embassy_extras::unborrow; use embassy_extras::unborrow;
use crate::fmt::{unreachable, *};
use crate::gpio::sealed::Pin as _; use crate::gpio::sealed::Pin as _;
use crate::gpio::OptionalPin as GpioOptionalPin; use crate::gpio::OptionalPin as GpioOptionalPin;
use crate::interrupt::Interrupt; use crate::interrupt::Interrupt;

View File

@ -10,7 +10,6 @@ use embassy::util::{AtomicWaker, DropBomb, Unborrow};
use embassy_extras::unborrow; use embassy_extras::unborrow;
use futures::future::poll_fn; use futures::future::poll_fn;
use crate::fmt::{assert, assert_eq, *};
use crate::gpio::sealed::Pin as _; use crate::gpio::sealed::Pin as _;
use crate::gpio::{self, Pin as GpioPin}; use crate::gpio::{self, Pin as GpioPin};
use crate::pac; use crate::pac;

View File

@ -11,10 +11,10 @@ use embassy_extras::unborrow;
use futures::future::poll_fn; use futures::future::poll_fn;
use traits::spi::FullDuplex; use traits::spi::FullDuplex;
use crate::gpio;
use crate::gpio::sealed::Pin as _; use crate::gpio::sealed::Pin as _;
use crate::gpio::{OptionalPin, Pin as GpioPin}; use crate::gpio::{OptionalPin, Pin as GpioPin};
use crate::interrupt::Interrupt; use crate::interrupt::Interrupt;
use crate::{fmt::*, gpio};
use crate::{pac, util::slice_in_ram_or}; use crate::{pac, util::slice_in_ram_or};
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};

View File

@ -18,10 +18,10 @@ use futures::future::poll_fn;
use traits::i2c::I2c; use traits::i2c::I2c;
use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE};
use crate::gpio;
use crate::gpio::Pin as GpioPin; use crate::gpio::Pin as GpioPin;
use crate::pac; use crate::pac;
use crate::util::{slice_in_ram, slice_in_ram_or}; use crate::util::{slice_in_ram, slice_in_ram_or};
use crate::{fmt::*, gpio};
pub enum Frequency { pub enum Frequency {
#[doc = "26738688: 100 kbps"] #[doc = "26738688: 100 kbps"]

View File

@ -13,7 +13,6 @@ use embassy_extras::unborrow;
use futures::future::poll_fn; use futures::future::poll_fn;
use crate::chip::EASY_DMA_SIZE; use crate::chip::EASY_DMA_SIZE;
use crate::fmt::{assert, panic, *};
use crate::gpio::sealed::Pin as _; use crate::gpio::sealed::Pin as _;
use crate::gpio::{self, OptionalPin as GpioOptionalPin, Pin as GpioPin}; use crate::gpio::{self, OptionalPin as GpioOptionalPin, Pin as GpioPin};
use crate::interrupt::Interrupt; use crate::interrupt::Interrupt;

View File

@ -1,6 +1,5 @@
use core::sync::atomic::{compiler_fence, Ordering}; use core::sync::atomic::{compiler_fence, Ordering};
use crate::fmt::assert;
use crate::pac::dma::vals; use crate::pac::dma::vals;
use crate::{pac, peripherals}; use crate::{pac, peripherals};

View File

@ -1,74 +1,181 @@
#![macro_use] #![macro_use]
#![allow(unused_macros)]
#[cfg(all(feature = "defmt", feature = "log"))] #[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features."); 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 {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::trace!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::trace!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! debug {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::debug!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::debug!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! info {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::info!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::info!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! warn {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::warn!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::warn!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
macro_rules! error {
($s:literal $(, $x:expr)* $(,)?) => {
{
#[cfg(feature = "log")]
::log::error!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::error!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
};
}
#[cfg(feature = "defmt")] #[cfg(feature = "defmt")]
mod fmt { macro_rules! unwrap {
pub use defmt::{ ($($x:tt)*) => {
assert, assert_eq, assert_ne, debug, debug_assert, debug_assert_eq, debug_assert_ne, error, ::defmt::unwrap!($($x)*)
info, panic, todo, trace, unreachable, unwrap, warn,
}; };
} }
#[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_export]
macro_rules! trace {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! debug {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! info {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! warn {
($($msg:expr),+ $(,)?) => {
()
};
}
#[macro_export]
macro_rules! error {
($($msg:expr),+ $(,)?) => {
()
};
}
}
#[cfg(not(feature = "defmt"))] #[cfg(not(feature = "defmt"))]
#[macro_export]
macro_rules! unwrap { macro_rules! unwrap {
($arg:expr) => { ($arg:expr) => {
match $crate::fmt::Try::into_result($arg) { match $crate::fmt::Try::into_result($arg) {

View File

@ -1,4 +1,3 @@
use crate::fmt::assert;
use crate::pac; use crate::pac;
const XOSC_MHZ: u32 = 12; const XOSC_MHZ: u32 = 12;

View File

@ -1,5 +1,4 @@
use crate::dac::{DacPin, Instance}; use crate::dac::{DacPin, Instance};
use crate::fmt::*;
use crate::gpio::AnyPin; use crate::gpio::AnyPin;
use crate::pac::dac; use crate::pac::dac;
use core::marker::PhantomData; use core::marker::PhantomData;

View File

@ -5,7 +5,6 @@ use embassy::util::AtomicWaker;
use futures::future::poll_fn; use futures::future::poll_fn;
use super::*; use super::*;
use crate::fmt::assert;
use crate::interrupt; use crate::interrupt;
use crate::pac; use crate::pac;
use crate::pac::dma::{regs, vals}; use crate::pac::dma::{regs, vals};

View File

@ -1,67 +1,178 @@
#![macro_use] #![macro_use]
#![allow(clippy::module_inception)] #![allow(unused_macros)]
#![allow(unused)]
#[cfg(all(feature = "defmt", feature = "log"))] #[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features."); 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")] #[cfg(feature = "defmt")]
mod fmt { ::defmt::assert!($($x)*);
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,
}; };
} }
#[cfg(feature = "log")] macro_rules! assert_eq {
mod fmt { ($($x:tt)*) => {
pub use core::{ {
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(not(feature = "defmt"))]
unreachable, ::core::assert_eq!($($x)*);
#[cfg(feature = "defmt")]
::defmt::assert_eq!($($x)*);
}
}; };
pub use log::{debug, error, info, trace, warn};
} }
#[cfg(not(any(feature = "defmt", feature = "log")))] macro_rules! assert_ne {
mod fmt { ($($x:tt)*) => {
#![macro_use] {
#[cfg(not(feature = "defmt"))]
pub use core::{ ::core::assert_ne!($($x)*);
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(feature = "defmt")]
unreachable, ::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 { macro_rules! trace {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::trace!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::trace!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! debug { macro_rules! debug {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::debug!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::debug!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! info { macro_rules! info {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::info!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::info!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! warn { macro_rules! warn {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::warn!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::warn!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! error { macro_rules! error {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::error!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::error!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
#[cfg(feature = "defmt")]
macro_rules! unwrap {
($($x:tt)*) => {
::defmt::unwrap!($($x)*)
};
} }
#[cfg(not(feature = "defmt"))] #[cfg(not(feature = "defmt"))]

View File

@ -2,7 +2,6 @@ use core::marker::PhantomData;
use embassy::util::Unborrow; use embassy::util::Unborrow;
use crate::fmt::{assert, panic};
use crate::pac::rcc::vals::Timpre; use crate::pac::rcc::vals::Timpre;
use crate::pac::{DBGMCU, RCC, SYSCFG}; use crate::pac::{DBGMCU, RCC, SYSCFG};
use crate::peripherals; use crate::peripherals;

View File

@ -1,5 +1,4 @@
use super::{Hertz, RCC}; use super::{Hertz, RCC};
use crate::fmt::assert;
const VCO_MIN: u32 = 150_000_000; const VCO_MIN: u32 = 150_000_000;
const VCO_MAX: u32 = 420_000_000; const VCO_MAX: u32 = 420_000_000;

View File

@ -10,7 +10,6 @@ use embassy_extras::unborrow;
use futures::future::poll_fn; use futures::future::poll_fn;
use sdio_host::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CID, CSD, OCR, SCR}; use sdio_host::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CID, CSD, OCR, SCR};
use crate::fmt::*;
use crate::interrupt::Interrupt; use crate::interrupt::Interrupt;
use crate::pac; use crate::pac;
use crate::pac::gpio::Gpio; use crate::pac::gpio::Gpio;
@ -434,7 +433,7 @@ impl SdmmcInner {
BusWidth::One => 0, BusWidth::One => 0,
BusWidth::Four => 1, BusWidth::Four => 1,
BusWidth::Eight => 2, BusWidth::Eight => 2,
_ => self::panic!("Invalid Bus Width"), _ => panic!("Invalid Bus Width"),
}) })
}); });
@ -637,7 +636,7 @@ impl SdmmcInner {
direction: Dir, direction: Dir,
data_transfer_timeout: u32, 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 regs = self.0;
let dtdir = match direction { let dtdir = match direction {
@ -678,7 +677,7 @@ impl SdmmcInner {
// Enforce AHB and SDMMC_CK clock relation. See RM0433 Rev 7 // Enforce AHB and SDMMC_CK clock relation. See RM0433 Rev 7
// Section 55.5.8 // Section 55.5.8
let sdmmc_bus_bandwidth = new_clock.0 * (width as u32); 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; *clock = new_clock;
// NOTE(unsafe) We have exclusive access to the regblock // NOTE(unsafe) We have exclusive access to the regblock

View File

@ -9,7 +9,6 @@ mod timer_queue;
mod util; mod util;
mod waker; mod waker;
use crate::fmt::panic;
use crate::interrupt::{Interrupt, InterruptExt}; use crate::interrupt::{Interrupt, InterruptExt};
use crate::time::Alarm; use crate::time::Alarm;

View File

@ -24,7 +24,9 @@ pub(crate) unsafe fn from_task(p: NonNull<TaskHeader>) -> Waker {
pub unsafe fn task_from_waker(waker: &Waker) -> NonNull<TaskHeader> { pub unsafe fn task_from_waker(waker: &Waker) -> NonNull<TaskHeader> {
let hack: &WakerHack = mem::transmute(waker); let hack: &WakerHack = mem::transmute(waker);
assert_eq!(hack.vtable, &VTABLE); if hack.vtable != &VTABLE {
panic!("Found waker not created by the embassy executor. Consider enabling the `executor-agnostic` feature on the `embassy` crate.")
}
NonNull::new_unchecked(hack.data as *mut TaskHeader) NonNull::new_unchecked(hack.data as *mut TaskHeader)
} }

View File

@ -1,67 +1,178 @@
#![macro_use] #![macro_use]
#![allow(clippy::module_inception)] #![allow(unused_macros)]
#![allow(unused)]
#[cfg(all(feature = "defmt", feature = "log"))] #[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features."); 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")] #[cfg(feature = "defmt")]
mod fmt { ::defmt::assert!($($x)*);
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,
}; };
} }
#[cfg(feature = "log")] macro_rules! assert_eq {
mod fmt { ($($x:tt)*) => {
pub use core::{ {
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(not(feature = "defmt"))]
unreachable, ::core::assert_eq!($($x)*);
#[cfg(feature = "defmt")]
::defmt::assert_eq!($($x)*);
}
}; };
pub use log::{debug, error, info, trace, warn};
} }
#[cfg(not(any(feature = "defmt", feature = "log")))] macro_rules! assert_ne {
mod fmt { ($($x:tt)*) => {
#![macro_use] {
#[cfg(not(feature = "defmt"))]
pub use core::{ ::core::assert_ne!($($x)*);
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo, #[cfg(feature = "defmt")]
unreachable, ::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 { macro_rules! trace {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::trace!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::trace!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! debug { macro_rules! debug {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::debug!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::debug!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! info { macro_rules! info {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::info!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::info!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! warn { macro_rules! warn {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::warn!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::warn!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
macro_rules! error { macro_rules! error {
($($msg:expr),+ $(,)?) => { ($s:literal $(, $x:expr)* $(,)?) => {
() {
#[cfg(feature = "log")]
::log::error!($s $(, $x)*);
#[cfg(feature = "defmt")]
::defmt::error!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
}
}; };
} }
#[cfg(feature = "defmt")]
macro_rules! unwrap {
($($x:tt)*) => {
::defmt::unwrap!($($x)*)
};
} }
#[cfg(not(feature = "defmt"))] #[cfg(not(feature = "defmt"))]

View File

@ -10,8 +10,6 @@ pub use duration::Duration;
pub use instant::Instant; pub use instant::Instant;
pub use traits::*; pub use traits::*;
use crate::fmt::*;
// TODO allow customizing, probably via Cargo features `tick-hz-32768` or something. // TODO allow customizing, probably via Cargo features `tick-hz-32768` or something.
pub const TICKS_PER_SECOND: u64 = 32768; pub const TICKS_PER_SECOND: u64 = 32768;

View File

@ -1,4 +1,3 @@
use crate::fmt::panic;
use core::mem; use core::mem;
/// An explosive ordinance that panics if it is improperly disposed of. /// An explosive ordinance that panics if it is improperly disposed of.

View File

@ -1,8 +1,6 @@
use core::cell::UnsafeCell; use core::cell::UnsafeCell;
use critical_section::CriticalSection; use critical_section::CriticalSection;
use crate::fmt::assert;
/// A "mutex" based on critical sections /// A "mutex" based on critical sections
/// ///
/// # Safety /// # Safety

View File

@ -1,4 +1,3 @@
use crate::fmt::panic;
use core::cell::UnsafeCell; use core::cell::UnsafeCell;
use core::mem; use core::mem;
use core::mem::MaybeUninit; use core::mem::MaybeUninit;

View File

@ -9,7 +9,6 @@ use executor::raw::TaskHeader;
use ptr::NonNull; use ptr::NonNull;
use crate::executor; use crate::executor;
use crate::fmt::panic;
use crate::interrupt::{Interrupt, InterruptExt}; use crate::interrupt::{Interrupt, InterruptExt};
/// Synchronization primitive. Allows creating awaitable signals that may be passed between tasks. /// Synchronization primitive. Allows creating awaitable signals that may be passed between tasks.

View File

@ -9,16 +9,18 @@ resolver = "2"
cortex-m = "0.7.2" cortex-m = "0.7.2"
cortex-m-rt = { version = "0.6.8", optional = true } cortex-m-rt = { version = "0.6.8", optional = true }
# BEGIN BUILD DEPENDENCIES
# These are removed when generating the pre-generated crate using the tool at gen/.
[build-dependencies] [build-dependencies]
regex = "1.4.6" regex = "1.4.6"
chiptool = { git = "https://github.com/embassy-rs/chiptool", rev = "86b77165078065058098e981d49d2dd213b2feba" } chiptool = { git = "https://github.com/embassy-rs/chiptool", rev = "86b77165078065058098e981d49d2dd213b2feba" }
serde = { version = "1.0.123", features = [ "derive" ]} serde = { version = "1.0.123", features = [ "derive" ]}
serde_yaml = "0.8.15" serde_yaml = "0.8.15"
# END BUILD DEPENDENCIES
[features] [features]
rt = ["cortex-m-rt/device"] rt = ["cortex-m-rt/device"]
# BEGIN GENERATED FEATURES # BEGIN GENERATED FEATURES
# Generated by gen_features.py. DO NOT EDIT. # Generated by gen_features.py. DO NOT EDIT.
stm32f030c6 = [] stm32f030c6 = []