Skip to content

Class hal::cortex_m::dwt_counter

ClassList > hal > cortex_m > dwt_counter

A counter with a frequency fixed to the CPU clock rate. More...

  • #include <dwt_counter.hpp>

Inherits the following classes: hal::steady_clock

Public Functions

Type Name
dwt_counter (hertz p_cpu_frequency)
Construct a new dwt counter object.
void register_cpu_frequency (hertz p_cpu_frequency)
Inform the driver of the operating frequency of the CPU in order to generate the correct uptime.

Public Functions inherited from hal::steady_clock

See hal::steady_clock

Type Name
frequency_t frequency ()
Get the operating frequency of the steady clock.
uptime_t uptime ()
Get the current value of the steady clock.
virtual ~steady_clock () = default

Detailed Description

This driver is supported for Cortex M3 devices and above.

Public Functions Documentation

function dwt_counter

Construct a new dwt counter object.

hal::cortex_m::dwt_counter::dwt_counter (
    hertz p_cpu_frequency
) 

Parameters:

  • p_cpu_frequency - the operating frequency of the CPU

function register_cpu_frequency

Inform the driver of the operating frequency of the CPU in order to generate the correct uptime.

void hal::cortex_m::dwt_counter::register_cpu_frequency (
    hertz p_cpu_frequency
) 

Use this when the CPU's operating frequency has changed and no longer matches the frequency supplied to the constructor. Care should be taken when expecting this function when there is the potentially other parts of the system that depend on this counter's uptime to operate.

Parameters:

  • p_cpu_frequency - the operating frequency of the CPU

The documentation for this class was generated from the following file libraries/include/libhal-armcortex/dwt_counter.hpp