CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
DigitalModuleV1_0 Class Reference
Inheritance diagram for DigitalModuleV1_0:
Collaboration diagram for DigitalModuleV1_0:

Public Types

enum  ERROR_CODES { STATUS_OK = 0 , DEACTIVATED_CHANNEL = 11 }

Public Member Functions

String getHWType () const override
 Get the hardware type string.
String getHWVersion () const override
 Get the hardware version string.
String getFWVersion () const override
 Get the firmware version string.
uint8_t getGPIODemand () const override
 Get the GPIO demand of the module.
uint8_t getGPIOSupply () const override
 Get the GPIO supply capacity of the module.
 DigitalModuleV1_0 (uint8_t outputMask=0xF0)
 Construct a DigitalModuleV1_0 instance.
bool attachModule (uint8_t slot, uint8_t gpioStart) override
 Attach the module to a slot and assign GPIO range.
bool provideGPIOs () override
 Provide GPIO definitions to the core.
bool requestGPIOs () override
 Request and configure GPIOs from the core.
bool provideHardwareResources () override
 Provide hardware resources to the core.
bool requestHardwareResources () override
 Request hardware resources required by this module.
bool addInterfaces () override
 Add and validate interfaces provided by the module.
bool initialize () override
 Initialize the module and its IC drivers.
void cycle (uint8_t *response) override
 Periodic cycle callback.
void setWireBreakMask (uint8_t mask=0)
 Configure wire-break detection mask.
Interface ** getInterfaces () override
 Get pointer to the module's interface array.
size_t getInterfaceCount () override
 Get number of interfaces provided by this module.
uint8_t setOutputs (uint8_t outputs)
 Set all digital outputs at once.
uint8_t setOutput (uint8_t output, bool state)
 Set a single digital output.
uint8_t getInputs () const
 Get current input states.
uint8_t getWireBreaks () const
 Get current wire-break status.
Public Member Functions inherited from CANTramModule
 CANTramModule ()=default
 Default constructor.
virtual ~CANTramModule ()=default
 Destructor.
virtual bool reset ()
 Reset the module to a known default state.
uint8_t getSlot () const
 Get assigned slot index.
uint8_t getGPIOStart () const
 Get starting GPIO index assigned to the module.
virtual bool preInitialize ()
 Pre-initialize the module after attachment and provisioning.

Static Public Attributes

static const String HW_TYPE = "DigitalModuleV1.0"
static const String HW_VERSION = "1.0"
static const String FW_VERSION = "1.0"
static constexpr uint8_t GPIO_DEMAND = 2
static constexpr uint8_t GPIO_SUPPLY = 0

Additional Inherited Members

Protected Attributes inherited from CANTramModule
uint8_t SLOT = 0
uint8_t GPIO_START = 0

Constructor & Destructor Documentation

◆ DigitalModuleV1_0()

DigitalModuleV1_0::DigitalModuleV1_0 ( uint8_t outputMask = 0xF0)

Construct a DigitalModuleV1_0 instance.

Construct a new DigitalModuleV1_0 object.

Create the digital module and configure which channels act as outputs using the outputMask.

Parameters
outputMaskBitmask where a set bit configures the corresponding channel as an output.
Returns
void

Initializes internal state, output mask and constructs input/output IC driver and interface objects.

Parameters
outputMaskBitmask selecting which channels are configured as outputs.
Returns
void

Member Function Documentation

◆ addInterfaces()

bool DigitalModuleV1_0::addInterfaces ( )
overridevirtual

Add and validate interfaces provided by the module.

Add and configure interfaces exposed by the module.

Populate the internal Interface* array with DigitalInput/DigitalOutput instances and validate them.

Returns
bool true if interfaces were added and validated successfully, false otherwise.

Populates the module's internal interface array with DigitalInput and DigitalOutput instances, sets interface names and validates them based on availability of CS pins and output mask.

Returns
true if interfaces were added and validated successfully, false otherwise.

Implements CANTramModule.

◆ attachModule()

bool DigitalModuleV1_0::attachModule ( uint8_t slot,
uint8_t gpioStart )
overridevirtual

Attach the module to a slot and assign GPIO range.

Attach module to a slot and assign GPIO start index.

Performs CANTramModule base attach logic and any module specific attach-time configuration.

Parameters
slotSlot index to attach the module to.
gpioStartStarting GPIO index assigned to this module.
Returns
bool true if attach and provisioning succeeded, false otherwise.

Calls the base CANTramModule attach implementation and performs any DigitalModule-specific attach logic.

Parameters
slotSlot index to attach the module to.
gpioStartStarting GPIO index assigned to this module.
Returns
true if attach succeeded, false otherwise.

Reimplemented from CANTramModule.

Here is the call graph for this function:

◆ cycle()

void DigitalModuleV1_0::cycle ( uint8_t * response)
overridevirtual

Periodic cycle callback.

Periodic cycle handler called by the core.

Called by the core to perform cyclic tasks: update outputs, read inputs and update interface values.

Parameters
responseOptional pointer to a response buffer where response bytes may be written (may be nullptr).
Returns
void

Updates outputs based on interface values, writes outputs to the output IC, reads inputs from the input IC (with repeated fetches for stability), and updates input interface values.

Parameters
responseOptional pointer to a response buffer; may be nullptr if not used.
Returns
void

Reimplemented from CANTramModule.

◆ getFWVersion()

String DigitalModuleV1_0::getFWVersion ( ) const
inlineoverridevirtual

Get the firmware version string.

Returns the firmware version string implemented by the module.

Returns
String Firmware version (e.g. "1.0").

Implements CANTramModule.

◆ getGPIODemand()

uint8_t DigitalModuleV1_0::getGPIODemand ( ) const
inlineoverridevirtual

Get the GPIO demand of the module.

Returns how many GPIOs this module requires from the core.

Returns
uint8_t Number of GPIOs demanded by the module.

Implements CANTramModule.

◆ getGPIOSupply()

uint8_t DigitalModuleV1_0::getGPIOSupply ( ) const
inlineoverridevirtual

Get the GPIO supply capacity of the module.

Returns how many GPIOs this module provides/supplies to the system.

Returns
uint8_t Number of GPIOs supplied by the module.

Implements CANTramModule.

◆ getHWType()

String DigitalModuleV1_0::getHWType ( ) const
inlineoverridevirtual

Get the hardware type string.

Returns a human readable hardware type identifier for the concrete module implementation.

Returns
String Hardware type identifier (e.g. "MainModuleV1.0").

Implements CANTramModule.

◆ getHWVersion()

String DigitalModuleV1_0::getHWVersion ( ) const
inlineoverridevirtual

Get the hardware version string.

Returns the hardware revision/version string for the module.

Returns
String Hardware version (e.g. "1.0").

Implements CANTramModule.

◆ getInputs()

uint8_t DigitalModuleV1_0::getInputs ( ) const
inline

Get current input states.

Returns the cached input state byte where each bit represents an input channel state.

Returns
uint8_t Byte with input states.

◆ getInterfaceCount()

size_t DigitalModuleV1_0::getInterfaceCount ( )
inlineoverridevirtual

Get number of interfaces provided by this module.

Returns the compile-time count of interface slots for this module.

Returns
size_t Number of interface pointers in the module.

Implements CANTramModule.

◆ getInterfaces()

Interface ** DigitalModuleV1_0::getInterfaces ( )
inlineoverridevirtual

Get pointer to the module's interface array.

Returns a pointer to the internal array of Interface pointers for enumeration by the core.

Returns
Interface** Pointer to the first element of the interfaces array.

Implements CANTramModule.

◆ getWireBreaks()

uint8_t DigitalModuleV1_0::getWireBreaks ( ) const
inline

Get current wire-break status.

Returns the cached wire-break status byte where each bit represents a wire-break flag for a channel.

Returns
uint8_t Byte with wire-break flags.

◆ initialize()

bool DigitalModuleV1_0::initialize ( )
overridevirtual

Initialize the module and its IC drivers.

Initialize the digital module hardware and ICs.

Configure and start the input/output driver ICs, set up external CS handling and prepare for operation.

Returns
bool true if initialization completed successfully, false otherwise.

Initializes output and input ICs, configures external chip-select handling using the configured CS output providers, and starts IC drivers. Logs configuration state for debugging.

Returns
true if initialization succeeded, false otherwise.

Implements CANTramModule.

◆ provideGPIOs()

bool DigitalModuleV1_0::provideGPIOs ( )
overridevirtual

Provide GPIO definitions to the core.

Declare any GPIOs this module provides to CANTramCore. Called during attachment.

Returns
bool true if GPIO definitions were provided successfully, false otherwise.

Placeholder: the digital module does not add additional GPIO definitions beyond core expectations.

Returns
true on success.

Implements CANTramModule.

◆ provideHardwareResources()

bool DigitalModuleV1_0::provideHardwareResources ( )
overridevirtual

Provide hardware resources to the core.

Provide hardware resources to CANTramCore.

Attach any HardwareResource instances offered by this module so other modules can request them.

Returns
bool true if hardware resources were provided successfully, false otherwise.

Currently no additional hardware resources are attached by this module.

Returns
true on success.

Implements CANTramModule.

◆ requestGPIOs()

bool DigitalModuleV1_0::requestGPIOs ( )
overridevirtual

Request and configure GPIOs from the core.

Request and configure GPIOs used by the module.

Obtain OutputDefinition pointers for CS pins and configure their initialValue and mode. This method must keep the configuration and initialValue assignment for correct operation.

Returns
bool true if required GPIO definitions were obtained and configured, false otherwise.

Obtains CS output definitions from CANTramCore for outputs and inputs, configures them as outputs, and sets their initial state to HIGH (deselected). Logs errors when definitions are missing.

Returns
true if required GPIO definitions were obtained and configured, false otherwise.

Implements CANTramModule.

Here is the call graph for this function:

◆ requestHardwareResources()

bool DigitalModuleV1_0::requestHardwareResources ( )
overridevirtual

Request hardware resources required by this module.

Request hardware resources required by the module.

Acquire shared hardware resources (if any) from CANTramCore for module operation.

Returns
bool true if required resources were granted, false otherwise.

Placeholder for requesting shared hardware resources. Returns true by default.

Returns
true if requested resources were acquired, false otherwise.

Implements CANTramModule.

◆ setOutput()

uint8_t DigitalModuleV1_0::setOutput ( uint8_t output,
bool state )

Set a single digital output.

Set or clear a single output bit in the module's cached output state if the channel is configured as output.

Parameters
outputIndex of the output channel (0..7).
stateDesired logical state for the channel (true = HIGH, false = LOW).
Returns
uint8_t STATUS_OK if operation succeeded, DEACTIVATED_CHANNEL if channel is not configured as output.

Sets or clears the specified output bit in the module's cached output state if that channel is configured as an output.

Parameters
outputIndex of the output channel (0..7).
stateDesired logical state for the channel (true = HIGH, false = LOW).
Returns
uint8_t STATUS_OK if operation succeeded, DEACTIVATED_CHANNEL if the channel is not configured as an output.

◆ setOutputs()

uint8_t DigitalModuleV1_0::setOutputs ( uint8_t outputs)

Set all digital outputs at once.

Update the module's outputs cache and corresponding output interfaces, respecting the output mask.

Parameters
outputsByte containing 8 output bits (bit0..bit7).
Returns
uint8_t STATUS_OK on success.

Updates the module's cached output state respecting the output mask and writes the values into the output interfaces.

Parameters
outputsByte containing 8 output bits (bit0..bit7).
Returns
uint8_t STATUS_OK on success.

◆ setWireBreakMask()

void DigitalModuleV1_0::setWireBreakMask ( uint8_t mask = 0)

Configure wire-break detection mask.

Configure wire-break mask for input detection.

Apply the provided mask to enable/disable wire-break detection per channel on the input IC.

Parameters
maskBitmask indicating channels for which wire-break detection should be active.
Returns
void

Iterates through channels and sets the wire-break detection mask on the input IC. Logs errors for any failure to apply the mask on individual channels.

Parameters
maskBitmask specifying which channels should have wire-break detection enabled.
Returns
void

The documentation for this class was generated from the following files:
  • C:/Users/leowa/Documents/PlatformIO/Projects/CANTramFrameworkUsage/lib/CANTramFramework/include/DigitalModuleV1_0.h
  • C:/Users/leowa/Documents/PlatformIO/Projects/CANTramFrameworkUsage/lib/CANTramFramework/src/modules/DigitalModuleV1_0.cpp