Skip to content

Commit 4a23c8d

Browse files
authored
rtic-sync: Remove unstable flag, and add defmt derives (#889)
1 parent 8b2465b commit 4a23c8d

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

rtic-sync/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ For each category, _Added_, _Changed_, _Fixed_ add new entries at the top!
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Unstable features are now stable, the feature flag `unstable` is removed.
13+
14+
### Added
15+
16+
- `defmt v0.3` derives added and forwarded to `embedded-hal(-x)` crates.
17+
1018
## v1.2.0 - 2024-01-10
1119

1220
### Changed

rtic-sync/Cargo.toml

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rtic-sync"
3-
version = "1.2.0"
3+
version = "1.3.0"
44

55
edition = "2021"
66
authors = [
@@ -17,23 +17,21 @@ repository = "https://github.com/rtic-rs/rtic"
1717

1818
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1919

20-
[package.metadata.docs.rs]
21-
features = ["unstable"]
22-
2320
[dependencies]
2421
heapless = "0.8"
2522
critical-section = "1"
2623
rtic-common = { version = "1.0.0", path = "../rtic-common" }
2724
portable-atomic = { version = "1", default-features = false }
28-
embedded-hal = { version = "1.0", optional = true }
29-
embedded-hal-async = { version = "1.0", optional = true }
30-
embedded-hal-bus = { version = "0.1.0", optional = true, features = ["async"] }
25+
embedded-hal = { version = "1.0.0" }
26+
embedded-hal-async = { version = "1.0.0" }
27+
embedded-hal-bus = { version = "0.1.0", features = ["async"] }
28+
29+
defmt-03 = { package = "defmt", version = "0.3", optional = true }
3130

3231
[dev-dependencies]
3332
tokio = { version = "1", features = ["rt", "macros", "time"] }
3433

35-
3634
[features]
3735
default = []
3836
testing = ["critical-section/std", "rtic-common/testing"]
39-
unstable = ["embedded-hal", "embedded-hal-async", "embedded-hal-bus"]
37+
defmt-03 = ["dep:defmt-03", "embedded-hal/defmt-03", "embedded-hal-async/defmt-03", "embedded-hal-bus/defmt-03"]

rtic-sync/src/arbiter.rs

-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ impl<'a, T> DerefMut for ExclusiveAccess<'a, T> {
191191
}
192192
}
193193

194-
#[cfg(feature = "unstable")]
195194
/// SPI bus sharing using [`Arbiter`]
196195
pub mod spi {
197196
use super::Arbiter;
@@ -274,7 +273,6 @@ pub mod spi {
274273
}
275274
}
276275

277-
#[cfg(feature = "unstable")]
278276
/// I2C bus sharing using [`Arbiter`]
279277
///
280278
/// An Example how to use it in RTIC application:

rtic-sync/src/channel.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ use rtic_common::{
1818
wait_queue::{Link, WaitQueue},
1919
};
2020

21+
#[cfg(feature = "defmt-03")]
22+
use crate::defmt;
23+
2124
/// An MPSC channel for use in no-alloc systems. `N` sets the size of the queue.
2225
///
2326
/// This channel uses critical sections, however there are extremely small and all `memcpy`
@@ -127,9 +130,11 @@ macro_rules! make_channel {
127130
// -------- Sender
128131

129132
/// Error state for when the receiver has been dropped.
133+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
130134
pub struct NoReceiver<T>(pub T);
131135

132136
/// Errors that 'try_send` can have.
137+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
133138
pub enum TrySendError<T> {
134139
/// Error state for when the receiver has been dropped.
135140
NoReceiver(T),
@@ -199,6 +204,13 @@ impl<'a, T, const N: usize> core::fmt::Debug for Sender<'a, T, N> {
199204
}
200205
}
201206

207+
#[cfg(feature = "defmt-03")]
208+
impl<'a, T, const N: usize> defmt::Format for Sender<'a, T, N> {
209+
fn format(&self, f: defmt::Formatter) {
210+
defmt::write!(f, "Sender",)
211+
}
212+
}
213+
202214
impl<'a, T, const N: usize> Sender<'a, T, N> {
203215
#[inline(always)]
204216
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> {
382394
}
383395
}
384396

397+
#[cfg(feature = "defmt-03")]
398+
impl<'a, T, const N: usize> defmt::Format for Receiver<'a, T, N> {
399+
fn format(&self, f: defmt::Formatter) {
400+
defmt::write!(f, "Receiver",)
401+
}
402+
}
403+
385404
/// Possible receive errors.
386-
#[derive(Debug, PartialEq, Eq)]
405+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
406+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
387407
pub enum ReceiveError {
388408
/// Error state for when all senders has been dropped.
389409
NoSender,

rtic-sync/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#![no_std]
44
#![deny(missing_docs)]
55

6+
#[cfg(feature = "defmt-03")]
7+
use defmt_03 as defmt;
8+
69
pub mod arbiter;
710
pub mod channel;
811
pub use portable_atomic;

xtask/src/argument_parsing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ impl Package {
9090
.chain(std::iter::once(None))
9191
.collect()
9292
}
93-
Package::RticSync => vec![Some("unstable".to_string()), None],
9493
_ => vec![None],
9594
}
9695
}

0 commit comments

Comments
 (0)