Skip to content

Commit 92c15ed

Browse files
committed
dwt, itm, tpiu: derive common traits for structs/enums
As per Rust API guidelines: <https://rust-lang.github.io/api-guidelines/interoperability.html#c-common-traits>.
1 parent 5a92298 commit 92c15ed

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/peripheral/dwt.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl DWT {
304304
}
305305

306306
/// Whether the comparator should match on read, write or read/write operations.
307-
#[derive(Debug, PartialEq)]
307+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
308308
pub enum AccessType {
309309
/// Generate packet only when matched adress is read from.
310310
ReadOnly,
@@ -315,7 +315,7 @@ pub enum AccessType {
315315
}
316316

317317
/// The sequence of packet(s) that should be emitted on comparator match.
318-
#[derive(Debug, PartialEq)]
318+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
319319
pub enum EmitOption {
320320
/// Emit only trace data value packet.
321321
Data,
@@ -332,7 +332,7 @@ pub enum EmitOption {
332332
}
333333

334334
/// Settings for address matching
335-
#[derive(Debug)]
335+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
336336
pub struct ComparatorAddressSettings {
337337
/// The address to match against.
338338
pub address: u32,
@@ -345,15 +345,15 @@ pub struct ComparatorAddressSettings {
345345
}
346346

347347
/// The available functions of a DWT comparator.
348-
#[derive(Debug)]
348+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
349349
#[non_exhaustive]
350350
pub enum ComparatorFunction {
351351
/// Compare accessed memory addresses.
352352
Address(ComparatorAddressSettings),
353353
}
354354

355355
/// Possible error values returned on [Comparator::configure].
356-
#[derive(Debug)]
356+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
357357
#[non_exhaustive]
358358
pub enum DwtError {
359359
/// Invalid combination of [AccessType] and [EmitOption].

src/peripheral/itm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Stim {
9090
}
9191

9292
/// The possible local timestamp options.
93-
#[derive(Debug, PartialEq)]
93+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
9494
pub enum LocalTimestampOptions {
9595
/// Disable local timestamps.
9696
Disabled,
@@ -108,7 +108,7 @@ pub enum LocalTimestampOptions {
108108
}
109109

110110
/// The possible global timestamp options.
111-
#[derive(Debug)]
111+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
112112
pub enum GlobalTimestampOptions {
113113
/// Disable global timestamps.
114114
Disabled,
@@ -121,7 +121,7 @@ pub enum GlobalTimestampOptions {
121121
}
122122

123123
/// The possible clock sources for timestamp counters.
124-
#[derive(Debug)]
124+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
125125
pub enum TimestampClkSrc {
126126
/// Clock timestamp counters using the system processor clock.
127127
SystemClock,
@@ -134,7 +134,7 @@ pub enum TimestampClkSrc {
134134
}
135135

136136
/// Available settings for the ITM peripheral.
137-
#[derive(Debug)]
137+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
138138
pub struct ITMSettings {
139139
/// Whether to enable ITM.
140140
pub enable: bool,

src/peripheral/tpiu.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ bitfield! {
6262

6363
/// The available protocols for the trace output.
6464
#[repr(u8)]
65+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
6566
pub enum TraceProtocol {
6667
/// Parallel trace port mode
6768
Parallel = 0b00,
@@ -87,7 +88,7 @@ impl core::convert::TryFrom<u8> for TraceProtocol {
8788
}
8889

8990
/// The SWO options supported by the TPIU.
90-
#[allow(dead_code)]
91+
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
9192
pub struct SWOSupports {
9293
/// Whether UART/NRZ encoding is supported for SWO.
9394
nrz_encoding: bool,

0 commit comments

Comments
 (0)