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 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 CANCore::Baudrate | DEFAULT_CAN_BAUDRATE = CANCore::BR_500K |
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.
◆ addOutputDefinition() [1/2]
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
-
| def | Pointer to the output definition to add |
- Returns
- CANTramCoreError Error code indicating success or failure
◆ 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
-
| def | Pointer to the output definition to add |
| index | Index at which to add the output definition |
| overwrite | Flag indicating whether to overwrite an existing definition |
- Returns
- CANTramCoreError Error code indicating success or failure
◆ addOutputDefinitionPointers()
| CANTramCoreError CANTramCore::addOutputDefinitionPointers |
( |
OutputDefinition * | def[], |
|
|
uint8_t | size ) |
|
static |
Call this function to add multiple output definitions to the core.
- Parameters
-
| def | Pointer to the array of output definition pointers |
| size | Number of output definitions to add |
- Returns
- CANTramCoreError Error code indicating success or failure
◆ 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
-
| def | Pointer to the array of output definitions |
| size | Number of output definitions to add |
- Returns
- CANTramCoreError Error code indicating success or failure
◆ attachHardwareResource()
Call this function to attach a hardware resource to the core. E.g., I2C, SPI, UART, PWM.
- Parameters
-
| resource | Pointer to the hardware resource to attach |
- Returns
- true if the resource was attached successfully, false otherwise
◆ attachModule() [1/2]
Call this function to attach a module to next available slot of the core.
- Parameters
-
| module | Pointer to the module to be attached |
- Returns
- true if the module was successfully attached, false otherwise
◆ 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
-
| module | Pointer 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
◆ getOutputDefinition()
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
-
| nr | Index of the output definition to retrieve |
- Returns
- Pointer to the requested output definition, or nullptr if not found
◆ 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
◆ 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()
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
-
| nr | Index of the output definition to retrieve |
- Returns
- Pointer to the requested output definition, or nullptr if not found
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