Skip to content

Implement various interfaces for trace configuration #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Nov 27, 2021
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
720282f
tpiu: impl functions related to trace data output
tmplt Apr 28, 2021
f75f17f
dwt: impl functions related to trace generation
tmplt Apr 28, 2021
8c53e60
tpiu: fix always-zero field-comparison
tmplt Apr 29, 2021
be983a3
dwt: configure address comparison using struct
tmplt Apr 30, 2021
9305580
dwt: add missing #[inline]
tmplt Apr 30, 2021
9285dcc
dcb: add note about vendor-specific trace options
tmplt Apr 30, 2021
859f9d8
dwt: reimplement with bitfield
tmplt May 5, 2021
b533eb6
itm: impl functions related to trace generation
tmplt May 5, 2021
fb604a7
tpiu: fix flipped SWOSupports field, reimplement with bitfield
tmplt May 5, 2021
085e738
itm, dwt: limit some bitfields to u8
tmplt May 5, 2021
669c872
dwt: feature gate trace and PC samples out of armv6m
tmplt Sep 24, 2021
362ad2d
itm: fix field spelling
tmplt Sep 24, 2021
02853a4
itm: remove useless conversion
tmplt Sep 24, 2021
aa17958
allow clippy::upper_case_acronyms
tmplt Sep 24, 2021
880b947
Merge branch 'master' into feat/tracing
tmplt Oct 26, 2021
c470f8b
dwt, itm, tpiu: remove get_ prefix, as per Rust API guidelines
tmplt Nov 21, 2021
6ddc746
dwt: fix clippy::bool_comparison
tmplt Nov 21, 2021
35bb481
dwt: improve EmitOption docstring
tmplt Nov 21, 2021
021420b
dwt: don't inline Comparator::configure
tmplt Nov 21, 2021
0e64774
dwt: refactor out unnecessary explicit panic
tmplt Nov 21, 2021
d45bad7
tpiu: remove get_ prefix, as per Rust API guidelines
tmplt Nov 21, 2021
633a631
dwt: DWTError -> DwtError for in-crate consistency
tmplt Nov 21, 2021
09929b1
dwt: mark ComparatorFunction, DwtError as non-exhaustive
tmplt Nov 21, 2021
c37f80b
itm: properly document ITMSettings
tmplt Nov 21, 2021
1efe319
tpiu: use bitfield for SPPR
tmplt Nov 21, 2021
5a92298
tpiu: improve TYPE field documentation
tmplt Nov 21, 2021
92c15ed
dwt, itm, tpiu: derive common traits for structs/enums
tmplt Nov 21, 2021
360fb33
dwt: refactor enable_exception_tracing into enable/disable funs
tmplt Nov 27, 2021
c1d434a
bump MSRV
tmplt Nov 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tpiu: use bitfield for SPPR
  • Loading branch information
tmplt committed Nov 21, 2021
commit 1efe31942b701d23a9d214f537adbfb471d25b9c
43 changes: 41 additions & 2 deletions src/peripheral/tpiu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct RegisterBlock {
pub acpr: RW<u32>,
reserved1: [u32; 55],
/// Selected Pin Control
pub sppr: RW<u32>,
pub sppr: RW<Sppr>,
reserved2: [u32; 132],
/// Formatter and Flush Control
pub ffcr: RW<Ffcr>,
Expand Down Expand Up @@ -52,7 +52,16 @@ bitfield! {
nrzvalid, _: 11;
}

bitfield! {
/// Selected pin protocol register.
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Sppr(u32);
u8, txmode, set_txmode: 1, 0;
}

/// The available protocols for the trace output.
#[repr(u8)]
pub enum TraceProtocol {
/// Parallel trace port mode
Parallel = 0b00,
Expand All @@ -61,6 +70,21 @@ pub enum TraceProtocol {
/// Asynchronous SWO, using NRZ encoding
AsyncSWONRZ = 0b10,
}
impl core::convert::TryFrom<u8> for TraceProtocol {
type Error = ();

/// Tries to convert from a `TXMODE` field value. Fails if the set mode is
/// unknown (and thus unpredictable).
#[inline]
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
x if x == Self::Parallel as u8 => Ok(Self::Parallel),
x if x == Self::AsyncSWOManchester as u8 => Ok(Self::AsyncSWOManchester),
x if x == Self::AsyncSWONRZ as u8 => Ok(Self::AsyncSWONRZ),
_ => Err(()), // unknown and unpredictable mode
}
}
}

/// The SWO options supported by the TPIU.
#[allow(dead_code)]
Expand All @@ -86,10 +110,25 @@ impl TPIU {
}
}

/// The used protocol for the trace output. Return `None` if an
/// unknown (and thus unpredicable mode) is configured by means
/// other than
/// [`trace_output_protocol`](Self::set_trace_output_protocol).
#[inline]
pub fn trace_output_protocol(&self) -> Option<TraceProtocol> {
use core::convert::TryInto;
self.sppr.read().txmode().try_into().ok()
}

/// Sets the used protocol for the trace output.
#[inline]
pub fn set_trace_output_protocol(&mut self, proto: TraceProtocol) {
unsafe { self.sppr.write(proto as u32) }
unsafe {
self.sppr.modify(|mut r| {
r.set_txmode(proto as u8);
r
});
}
}

/// Whether to enable the formatter. If disabled, only ITM and DWT
Expand Down