Pigweed
 
Loading...
Searching...
No Matches
pw::clock_tree::Element Class Referenceabstract

#include <clock_tree.h>

Inheritance diagram for pw::clock_tree::Element:
pw::clock_tree::ElementBlocking pw::clock_tree::ElementNonBlockingCannotFail pw::clock_tree::ElementNonBlockingMightFail pw::clock_tree::ClockSource< ElementNonBlockingCannotFail > pw::clock_tree::ClockMcuxpressoFro pw::clock_tree::ClockMcuxpressoLpOsc pw::clock_tree::ClockSourceNoOp

Public Member Functions

constexpr Element (bool may_block=false)
 
uint32_t ref_count () const
 Get reference count for this clock tree element.
 
bool may_block () const
 Check whether acquiring or releasing the element may block.
 
 Element (const Element &)=delete
 
 Element (const Element &&)=delete
 
Elementoperator= (const Element &)=delete
 
Elementoperator= (const Element &&)=delete
 

Protected Member Functions

virtual Status Acquire ()=0
 
virtual Status Release ()=0
 
uint32_t IncRef ()
 Increment reference count and return incremented value.
 
uint32_t DecRef ()
 Decrement reference count and return decremented value.
 
virtual Status DoEnable ()=0
 Function called when the clock tree element needs to get enabled.
 
virtual Status DoDisable ()
 

Friends

class ClockTree
 
template<typename ElementType >
class DependentElement
 
class ClockDivider
 

Detailed Description

Abstract base class for a clock tree element of a clock tree.

Class implementations of Element must implement Acquire and Release functions. For clock tree elements that only get enabled / configured, it is sufficient to only override the DoEnable function, otherwise it is required to override the DoDisable function to disable the respective clock tree element.

Note: Clock tree element classes shouldn't be directly derived from the Element class, but from the ElementBlocking, ElementNonBlockingCannotFail or ElementNonBlockingMightFail class.

Member Function Documentation

◆ Acquire()

virtual Status pw::clock_tree::Element::Acquire ( )
protectedpure virtual

Acquire a reference to the clock tree element.

Acquiring a reference to a clock tree element ensures that the clock tree element is configured and enabled.

If the clock tree element depends on another clock tree element, a reference to the dependent clock tree element will get acquired when the first reference to this clock tree element gets acquired. This ensures that all dependent clock tree elements have been enabled before this clock tree element gets configured and enabled.

Implemented in pw::clock_tree::ClockSource< ElementNonBlockingCannotFail >.

◆ DoDisable()

virtual Status pw::clock_tree::Element::DoDisable ( )
inlineprotectedvirtual

Function called when the clock tree element can get disabled.

Can be overridden by child class in case the clock tree element can be disabled to save power.

Reimplemented in pw::clock_tree::ClockSourceNoOp, pw::clock_tree::ClockMcuxpressoFro, and pw::clock_tree::ClockMcuxpressoLpOsc.

◆ DoEnable()

virtual Status pw::clock_tree::Element::DoEnable ( )
protectedpure virtual

Function called when the clock tree element needs to get enabled.

Implemented in pw::clock_tree::ClockSourceNoOp, pw::clock_tree::ClockMcuxpressoFro, and pw::clock_tree::ClockMcuxpressoLpOsc.

◆ Release()

virtual Status pw::clock_tree::Element::Release ( )
protectedpure virtual

Release a reference to the clock tree element.

Releasing the last reference to the clock tree element will disable the clock tree element.

When the last reference to the clock tree element gets released, the clock tree element gets disabled if the DoDisable function is overridden.

If the clock tree element depends on another clock tree element, a reference to the dependent clock tree element will get released once the last reference to this clock tree element has been released and the clock tree element has been disabled. This ensures that the clock tree element gets disabled before all dependent clock tree elements have been disabled.

Implemented in pw::clock_tree::ClockSource< ElementNonBlockingCannotFail >.


The documentation for this class was generated from the following file: