ethercrab/subdevice/dc.rs
1//! Distributed Clock configuration for a single SubDevice.
2
3use core::{fmt, time::Duration};
4
5/// DC sync configuration for a SubDevice.
6#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
7#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8pub enum DcSync {
9 /// DC sync is disabled for this SubDevice.
10 #[default]
11 Disabled,
12
13 /// This SubDevice synchronises on the SYNC0 pulse.
14 Sync0,
15
16 /// Both SYNC0 and SYNC1 are enabled.
17 ///
18 /// SubDevices with an `AssignActivate` value of `0x0700` in their ESI definition should set
19 /// this value as well as [`sync0_period`](crate::subdevice_group::DcConfiguration::sync0_period) in
20 /// the SubDevice group DC configuration.
21 Sync01 {
22 /// SYNC1 cycle time.
23 sync1_period: Duration,
24 },
25}
26
27impl fmt::Display for DcSync {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 match self {
30 DcSync::Disabled => f.write_str("disabled"),
31 DcSync::Sync0 => f.write_str("SYNC0"),
32 DcSync::Sync01 { sync1_period } => {
33 write!(f, "SYNC0 with SYNC1 period {} us", sync1_period.as_micros())
34 }
35 }
36 }
37}