Skip to content

Commit 52ff95e

Browse files
committed
Deprecate get_cycle_count in favor of cycle_count
This follows the rust C-GETTER API guidelines.
1 parent 33a6b16 commit 52ff95e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/peripheral/dwt.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,18 @@ impl DWT {
144144
/// Returns the current clock cycle count
145145
#[cfg(not(armv6m))]
146146
#[inline]
147+
#[deprecated(
148+
since = "0.7.4",
149+
note = "Use `cycle_count` which follows the C-GETTER convention"
150+
)]
147151
pub fn get_cycle_count() -> u32 {
152+
Self::cycle_count()
153+
}
154+
155+
/// Returns the current clock cycle count
156+
#[cfg(not(armv6m))]
157+
#[inline]
158+
pub fn cycle_count() -> u32 {
148159
// NOTE(unsafe) atomic read with no side effects
149160
unsafe { (*Self::ptr()).cyccnt.read() }
150161
}

src/peripheral/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//! ```
2424
//! A part of the peripheral API doesn't require access to a peripheral instance. This part of the
2525
//! API is provided as static methods on the peripheral types. One example is the
26-
//! [`DWT::get_cycle_count`](struct.DWT.html#method.get_cycle_count) method.
26+
//! [`DWT::cycle_count`](struct.DWT.html#method.cycle_count) method.
2727
//!
2828
//! ``` no_run
2929
//! # use cortex_m::peripheral::{DWT, Peripherals};
@@ -33,7 +33,7 @@
3333
//! } // all the peripheral singletons are destroyed here
3434
//!
3535
//! // but this method can be called without a DWT instance
36-
//! let cyccnt = DWT::get_cycle_count();
36+
//! let cyccnt = DWT::cycle_count();
3737
//! ```
3838
//!
3939
//! The singleton property can be *unsafely* bypassed using the `ptr` static method which is

0 commit comments

Comments
 (0)