CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
CANTramCore Class Reference

This static class serves as the core manager for the CANTram modular system. It handles module attachment, GPIO management, hardware resource allocation and cyclic updates of the modules. More...

#include <CANTramCore.h>

Static Public Member Functions

static void setOutput (uint8_t nr, bool state)
static bool attachModule (CANTramModule *module, int8_t index, int8_t gpioStart)
 Call this function to attach a module to the core.
static bool attachModule (CANTramModule *module)
 Call this function to attach a module to next available slot of the core.
static CANTramModule * getModule (uint8_t index)
static CANTramCoreError addOutputDefinitionPointers (OutputDefinition *def[], uint8_t size)
 Call this function to add multiple output definitions to the core.
static CANTramCoreError addOutputDefinitions (OutputDefinition def[], uint8_t size)
 Call this function to add multiple output definitions by using their instances to the core.
static CANTramCoreError addOutputDefinition (OutputDefinition *def, uint8_t index, bool overwrite=true)
 Call this function to add a single output definition to the core.
static CANTramCoreError addOutputDefinition (OutputDefinition *def)
 Call this function to add a single output definition to the core.
static OutputDefinition * getOutputDefinition (uint8_t index)
 Call this function to retrieve a specific output definition without affecting the used count.
static OutputDefinition * useOutputDefinition (uint8_t index)
 Call this function to retrieve a specific output definition and raise the count of used output definitions.
static bool reset ()
 Call this function to reset the CANTram core and all attached modules.
static bool initialize ()
 Call this function to initialize the CANTram core and therefore the controller.
static bool attachHardwareResource (HardwareResource *resource)
 Call this function to attach a hardware resource to the core. E.g., I2C, SPI, UART, PWM.
static HardwareResource * useHardwareResource (HardwareResource::Type type)
static uint8_t getUsedGPIOs ()
static uint8_t getProvidedGPIOs ()
static bool addInterface (Interface *interface)
static bool addInterfaces (Interface *interfaceArray[], uint8_t size)
static uint8_t loop ()
 Call this function periodically to allow modules to perform cyclic tasks.
static void summaryReport ()

Static Public Attributes

static CANCore::Baudrate DEFAULT_CAN_BAUDRATE = CANCore::BR_500K

Detailed Description

This static class serves as the core manager for the CANTram modular system. It handles module attachment, GPIO management, hardware resource allocation and cyclic updates of the modules.

Member Function Documentation

◆ addOutputDefinition() [1/2]

CANTramCoreError CANTramCore::addOutputDefinition ( OutputDefinition * def)
static

Call this function to add a single output definition to the core.

This function searches for the first available slot in the output definition table and adds the provided definition there. If no slots are available, it returns an error.

Parameters
defPointer to the output definition to add
Returns
CANTramCoreError Error code indicating success or failure
Here is the call graph for this function:

◆ addOutputDefinition() [2/2]

CANTramCoreError CANTramCore::addOutputDefinition ( OutputDefinition * def,
uint8_t index,
bool overwrite = true )
static

Call this function to add a single output definition to the core.

Parameters
defPointer to the output definition to add
indexIndex at which to add the output definition
overwriteFlag indicating whether to overwrite an existing definition
Returns
CANTramCoreError Error code indicating success or failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOutputDefinitionPointers()

CANTramCoreError CANTramCore::addOutputDefinitionPointers ( OutputDefinition * def[],
uint8_t size )
static

Call this function to add multiple output definitions to the core.

Parameters
defPointer to the array of output definition pointers
sizeNumber of output definitions to add
Returns
CANTramCoreError Error code indicating success or failure
Here is the call graph for this function:

◆ addOutputDefinitions()

CANTramCoreError CANTramCore::addOutputDefinitions ( OutputDefinition def[],
uint8_t size )
static

Call this function to add multiple output definitions by using their instances to the core.

Parameters
defPointer to the array of output definitions
sizeNumber of output definitions to add
Returns
CANTramCoreError Error code indicating success or failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attachHardwareResource()

bool CANTramCore::attachHardwareResource ( HardwareResource * resource)
static

Call this function to attach a hardware resource to the core. E.g., I2C, SPI, UART, PWM.

Parameters
resourcePointer to the hardware resource to attach
Returns
true if the resource was attached successfully, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attachModule() [1/2]

bool CANTramCore::attachModule ( CANTramModule * module)
static

Call this function to attach a module to next available slot of the core.

Parameters
modulePointer to the module to be attached
Returns
true if the module was successfully attached, false otherwise
Here is the call graph for this function:

◆ attachModule() [2/2]

bool CANTramCore::attachModule ( CANTramModule * module,
int8_t index,
int8_t gpioStart )
static

Call this function to attach a module to the core.

This function registers the module, assigns it a slot and GPIO start index, and registers its interfaces and hardware resources with the core. It also checks for maximum module limits and GPIO usage.

Parameters
modulePointer to the module to be attached
index[Optional] Slot index for the module
gpioStart[Optional] GPIO start index for the module
Returns
true if the module was successfully attached, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOutputDefinition()

OutputDefinition * CANTramCore::getOutputDefinition ( uint8_t nr)
static

Call this function to retrieve a specific output definition without affecting the used count.

This function returns a pointer to the output definition at the specified index. If the index is out of bounds or if no definition exists at that index, it returns nullptr and logs an error. Use this command, if you just need information about this output definition but don't want to asign a function to it.

Parameters
nrIndex of the output definition to retrieve
Returns
Pointer to the requested output definition, or nullptr if not found
Here is the caller graph for this function:

◆ initialize()

bool CANTramCore::initialize ( )
static

Call this function to initialize the CANTram core and therefore the controller.

This function initializes all attached modules and sets initial GPIO values as defined in their output definitions. It should be called after all modules have been attached and configured.

Returns
true if initialization was successful, false otherwise
Here is the call graph for this function:

◆ loop()

uint8_t CANTramCore::loop ( )
static

Call this function periodically to allow modules to perform cyclic tasks.

This function iterates through all attached modules and calls their cycle method. It is typically called in the main loop of the program.

Returns
uint8_t Status code (0 for success)

◆ reset()

bool CANTramCore::reset ( )
static

Call this function to reset the CANTram core and all attached modules.

This function performs a complete reset of all CANTram related functions. It resets the internal state of the core, clears the module and hardware resource lists, and resets all attached modules and hardware resources. It should be called to reinitialize the core to a clean state. Normally this function should only be used during testing, but not in production code.

Returns
true if the reset was successful, false otherwise

◆ useOutputDefinition()

OutputDefinition * CANTramCore::useOutputDefinition ( uint8_t nr)
static

Call this function to retrieve a specific output definition and raise the count of used output definitions.

Use getOutputDefinition(...) instead, if you don't want to assign the output to any module.

Parameters
nrIndex of the output definition to retrieve
Returns
Pointer to the requested output definition, or nullptr if not found
Here is the call graph for this function:
Here is the caller graph for this function:

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