@@ -127,29 +127,33 @@ impl DWT {
127
127
///
128
128
/// A value of zero indicates no comparator support.
129
129
#[ inline]
130
- pub fn num_comp ( & self ) -> u8 {
131
- self . ctrl . read ( ) . numcomp ( )
130
+ pub fn num_comp ( ) -> u8 {
131
+ // NOTE(unsafe) atomic read with no side effects
132
+ unsafe { ( * DWT :: PTR ) . ctrl . read ( ) . numcomp ( ) }
132
133
}
133
134
134
135
/// Returns `true` if the the implementation supports sampling and exception tracing
135
136
#[ cfg( not( armv6m) ) ]
136
137
#[ inline]
137
- pub fn has_exception_trace ( & self ) -> bool {
138
- !self . ctrl . read ( ) . notrcpkt ( )
138
+ pub fn has_exception_trace ( ) -> bool {
139
+ // NOTE(unsafe) atomic read with no side effects
140
+ unsafe { !( * DWT :: PTR ) . ctrl . read ( ) . notrcpkt ( ) }
139
141
}
140
142
141
143
/// Returns `true` if the implementation includes external match signals
142
144
#[ cfg( not( armv6m) ) ]
143
145
#[ inline]
144
- pub fn has_external_match ( & self ) -> bool {
145
- !self . ctrl . read ( ) . noexttrig ( )
146
+ pub fn has_external_match ( ) -> bool {
147
+ // NOTE(unsafe) atomic read with no side effects
148
+ unsafe { !( * DWT :: PTR ) . ctrl . read ( ) . noexttrig ( ) }
146
149
}
147
150
148
151
/// Returns `true` if the implementation supports a cycle counter
149
152
#[ inline]
150
- pub fn has_cycle_counter ( & self ) -> bool {
153
+ pub fn has_cycle_counter ( ) -> bool {
151
154
#[ cfg( not( armv6m) ) ]
152
- return !self . ctrl . read ( ) . nocyccnt ( ) ;
155
+ // NOTE(unsafe) atomic read with no side effects
156
+ return !unsafe { ( * DWT :: PTR ) . ctrl . read ( ) . nocyccnt ( ) } ;
153
157
154
158
#[ cfg( armv6m) ]
155
159
return false ;
@@ -158,8 +162,9 @@ impl DWT {
158
162
/// Returns `true` if the implementation the profiling counters
159
163
#[ cfg( not( armv6m) ) ]
160
164
#[ inline]
161
- pub fn has_profiling_counter ( & self ) -> bool {
162
- !self . ctrl . read ( ) . noprfcnt ( )
165
+ pub fn has_profiling_counter ( ) -> bool {
166
+ // NOTE(unsafe) atomic read with no side effects
167
+ !unsafe { ( * DWT :: PTR ) . ctrl . read ( ) . noprfcnt ( ) }
163
168
}
164
169
165
170
/// Enables the cycle counter
0 commit comments