|
CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
|
Base class for hardware resources like UART, SPI, I2C, PWM, etc. More...
#include <HardwareResource.h>

Public Types | |
| enum | Type { UART , SPI , I2C , PWM , CAN } |
| Enumeration of hardware resource types. More... | |
Public Member Functions | |
| virtual Type | getType ()=0 |
| Get the hardware resource type. | |
| virtual bool | reset () |
| Reset the hardware resource to a known default state. | |
| bool | requestUsage () |
| Request a usage slot for this resource. | |
| uint8_t | getUsages () |
| Get the current number of usages of this resource. | |
| bool | isUsed () |
| Check if the resource is currently used. | |
| virtual uint8_t | getRemainingUsages () |
| Get remaining usage capacity for this resource. | |
Protected Member Functions | |
| HardwareResource ()=default | |
| Default constructor. | |
| virtual uint8_t | getMaxUsages () |
| Get the maximum simultaneous usages allowed for this resource. | |
Protected Attributes | |
| uint8_t | usages =0 |
| Current usage counter. | |
Base class for hardware resources like UART, SPI, I2C, PWM, etc.
HardwareResource provides a common interface for resources managed by CANTramCore. It implements usage counting and default reset/usage behaviour. Derived classes must implement getType() and may override getMaxUsages() and reset() as required.
|
protecteddefault |
Default constructor.
Protected to prevent direct instantiation of the abstract base class.
|
inlineprotectedvirtual |
Get the maximum simultaneous usages allowed for this resource.
Default implementation returns 1. Override in derived classes to permit multiple users.
Reimplemented in ESP32PWMCore, I2CCore, and PWMCore.

|
inlinevirtual |
Get remaining usage capacity for this resource.
Computes remaining usages as max usages minus current usages. Can be overridden by derived classes if needed.

|
pure virtual |
|
inline |
Get the current number of usages of this resource.
Returns the number of modules that have requested/are using this hardware resource.
|
inline |
Check if the resource is currently used.
Returns true when at least one usage has been requested.
|
inline |
Request a usage slot for this resource.
Increments the internal usage counter if the resource has remaining capacity. If the resource is already at its maximum usages, the request is rejected and an error is logged.


|
inlinevirtual |
Reset the hardware resource to a known default state.
Default implementation clears the usage counter and logs the reset. Derived classes should call the base implementation and perform any additional hardware-specific reset steps.
Reimplemented in CANCore, ESP32_CANCore, ESP32_I2CCore, ESP32_UART, ESP32PWMCore, I2CCore, and UARTCore.


|
protected |
Current usage counter.
Tracks how many clients/modules have requested this resource.