diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2024-02-23 08:38:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-23 07:38:10 +0000 |
| commit | 4a23c8d6da918b2ddd5a6b694b584fd2737833bb (patch) | |
| tree | f089989910580ea186ce2fe97d40d1eb367d139e /rtic-sync/src | |
| parent | 8b2465ba37a2781704e302f403069282a5562930 (diff) | |
rtic-sync: Remove unstable flag, and add defmt derives (#889)
Diffstat (limited to 'rtic-sync/src')
| -rw-r--r-- | rtic-sync/src/arbiter.rs | 2 | ||||
| -rw-r--r-- | rtic-sync/src/channel.rs | 22 | ||||
| -rw-r--r-- | rtic-sync/src/lib.rs | 3 |
3 files changed, 24 insertions, 3 deletions
diff --git a/rtic-sync/src/arbiter.rs b/rtic-sync/src/arbiter.rs index f0dbc4c..b17fa00 100644 --- a/rtic-sync/src/arbiter.rs +++ b/rtic-sync/src/arbiter.rs @@ -191,7 +191,6 @@ impl<'a, T> DerefMut for ExclusiveAccess<'a, T> { } } -#[cfg(feature = "unstable")] /// SPI bus sharing using [`Arbiter`] pub mod spi { use super::Arbiter; @@ -274,7 +273,6 @@ pub mod spi { } } -#[cfg(feature = "unstable")] /// I2C bus sharing using [`Arbiter`] /// /// An Example how to use it in RTIC application: diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index 4f4f0c2..64d09d1 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -18,6 +18,9 @@ use rtic_common::{ wait_queue::{Link, WaitQueue}, }; +#[cfg(feature = "defmt-03")] +use crate::defmt; + /// An MPSC channel for use in no-alloc systems. `N` sets the size of the queue. /// /// This channel uses critical sections, however there are extremely small and all `memcpy` @@ -127,9 +130,11 @@ macro_rules! make_channel { // -------- Sender /// Error state for when the receiver has been dropped. +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub struct NoReceiver<T>(pub T); /// Errors that 'try_send` can have. +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub enum TrySendError<T> { /// Error state for when the receiver has been dropped. NoReceiver(T), @@ -199,6 +204,13 @@ impl<'a, T, const N: usize> core::fmt::Debug for Sender<'a, T, N> { } } +#[cfg(feature = "defmt-03")] +impl<'a, T, const N: usize> defmt::Format for Sender<'a, T, N> { + fn format(&self, f: defmt::Formatter) { + defmt::write!(f, "Sender",) + } +} + impl<'a, T, const N: usize> Sender<'a, T, N> { #[inline(always)] fn send_footer(&mut self, idx: u8, val: T) { @@ -382,8 +394,16 @@ impl<'a, T, const N: usize> core::fmt::Debug for Receiver<'a, T, N> { } } +#[cfg(feature = "defmt-03")] +impl<'a, T, const N: usize> defmt::Format for Receiver<'a, T, N> { + fn format(&self, f: defmt::Formatter) { + defmt::write!(f, "Receiver",) + } +} + /// Possible receive errors. -#[derive(Debug, PartialEq, Eq)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum ReceiveError { /// Error state for when all senders has been dropped. NoSender, diff --git a/rtic-sync/src/lib.rs b/rtic-sync/src/lib.rs index ecd3247..90afff6 100644 --- a/rtic-sync/src/lib.rs +++ b/rtic-sync/src/lib.rs @@ -3,6 +3,9 @@ #![no_std] #![deny(missing_docs)] +#[cfg(feature = "defmt-03")] +use defmt_03 as defmt; + pub mod arbiter; pub mod channel; pub use portable_atomic; |
