HF-Core Platform 0.1.0-dev
Hardware-Agnostic Handler Layer & RTOS Utilities for HardFOC
Loading...
Searching...
No Matches
Tmc9660AdcWrapper.h File Reference

Thin BaseAdc delegation wrapper for manager-layer ownership of TMC9660 ADC. More...

#include "base/BaseAdc.h"
Include dependency graph for Tmc9660AdcWrapper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Tmc9660AdcWrapper
 Delegation wrapper that adapts Tmc9660Handler::Adc for external ownership. More...
 

Detailed Description

Thin BaseAdc delegation wrapper for manager-layer ownership of TMC9660 ADC.

Purpose

The TMC9660's ADC functionality is implemented by Tmc9660Handler::Adc (an inner class of Tmc9660Handler that inherits from BaseAdc). The handler owns this inner class instance and exposes it via Tmc9660Handler::adc().

However, the AdcManager needs to own a std::unique_ptr<BaseAdc> that it can register, manage, and destroy independently. Since Tmc9660Handler::Adc is owned by the handler (and cannot be transferred), this wrapper class exists to bridge the ownership gap:

┌──────────────┐ ┌─────────────────────┐ ┌───────────────────────┐
│ AdcManager │ owns │ Tmc9660AdcWrapper │ refs │ Tmc9660Handler::Adc
│ │─────>│ (BaseAdc) │─────>│ (BaseAdc impl) │
│ unique_ptr │ │ delegates all calls│ │ reads TMC9660 driver │
└──────────────┘ └─────────────────────┘ └───────────────────────┘
Delegation wrapper that adapts Tmc9660Handler::Adc for external ownership.
Definition Tmc9660AdcWrapper.h:72
BaseAdc adapter for all TMC9660 ADC channels.
Definition Tmc9660Handler.h:729

Every BaseAdc virtual method in this class is a one-line delegation to handler_.adc().Method(). No additional logic, buffering, or transformation is performed.

Lifetime Requirements

The Tmc9660Handler referenced by this wrapper must remain alive for the entire lifetime of the wrapper. This is naturally satisfied when MotorController owns the handler and AdcManager creates the wrapper from that handler, since both managers are singletons with matched lifetimes.

Analogous Patterns

See also
Tmc9660Handler::Adc The actual ADC implementation this class delegates to.
AdcManager::CreateTmc9660AdcWrapper Factory that creates instances of this class.
Author
HardFOC Team
Date
2025