Skip to main content

init_dwt

Function init_dwt 

Source
pub fn init_dwt()
Expand description

Enable the Cortex-M DWT cycle counter.

On ARM targets: sets DEMCR.TRCENA, enables the cycle counter, and resets CYCCNT to 0. Uses Peripherals::steal so user code does not need to give up the singleton. Idempotent — safe to call multiple times.

On non-ARM targets (e.g. x86_64 host-pty-server): no-op. The atomic counters still accumulate but cycles_now() always returns 0, so cycle fields in the snapshot will be 0. Host-side Instant timing in telepath-client remains meaningful for bench-pty.

§Safety

On ARM: uses cortex_m::peripheral::Peripherals::steal(). Only sound on single-core Cortex-M targets with profile intentionally enabled.