CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
BusModule.h
1#ifndef BUSModuleV1_0_H
2#define BUSModuleV1_0_H
3#include "CANTramCore.h"
4#include "CANTramModule.h"
5#include <SPI.h>
6#include <Arduino.h>
7#include "SPIChip.h"
8#include "Debug.h"
9#include "Interface.h"
10#include "UARTCore.h"
11#include "UARTInterface.h"
12#include "I2CCore.h"
13#include "I2CInterface.h"
14
16 public:
17 static const String HW_TYPE;
18 String getHWType() const override { return HW_TYPE; }
19 static const String HW_VERSION;
20 String getHWVersion() const override { return HW_VERSION; }
21 static const String FW_VERSION;
22 String getFWVersion() const override { return FW_VERSION; }
23 static constexpr uint8_t GPIO_DEMAND = 3;
24 uint8_t getGPIODemand() const override { return GPIO_DEMAND; }
25 static constexpr uint8_t GPIO_SUPPLY = 0;
26 uint8_t getGPIOSupply() const override { return GPIO_SUPPLY; }
27
28 bool attachModule(uint8_t slot,uint8_t gpioStart) override;
29 bool provideGPIOs() override;
30 bool requestGPIOs() override;
31 bool provideHardwareResources() override;
32 bool requestHardwareResources() override;
33 bool addInterfaces() override;
34 bool addSPIDevice(SPIChip* spiDevice, bool allowOverride = false);
35
36 bool setLoopFunction(std::function<void(uint8_t* response)> loopFunction){_loopFunction = loopFunction; return true; };
37
38 bool initialize() override;
39 bool preInitialize() override;
40
41 void cycle(uint8_t* response) override;
42
43 bool reset() override;
44
45 Interface** getInterfaces() override { return _interfaces; }
46 size_t getInterfaceCount() override { return INTERFACE_COUNT; }
47
48 bool addUARTInterface();
49 bool addI2CInterface(); //Implement later
50
51 private:
52 OutputDefinition* UART_RX_PIN;
53 OutputDefinition* UART_TX_PIN;
54 OutputDefinition* SPI_CS_PIN;
55 SPIChip* _SPIBus = nullptr;
56 static constexpr size_t INTERFACE_COUNT = 2; // Number of interfaces in the array
57 Interface* _interfaces[INTERFACE_COUNT]; // representation of the physical interfaces clamps
58 UARTInterface _uartInterface;
59 I2CInterface _i2cInterface;
60 std::function<void(uint8_t* response)> _loopFunction = nullptr;
61 //I2nterface* _i2cUnterface = nullptr; //Implement later
62 //SPIInterface* _spi = nullptr;
63};
64#endif
This class serves as the core manager for the CANTram modular system. It handles module attachment,...
Base class for CANTram hardware modules.
Logging and debug macro definitions for CANTramCore.
Abstract base for UART hardware cores and provider interface.
Definition BusModule.h:15
bool attachModule(uint8_t slot, uint8_t gpioStart) override
Attach this module to a slot and GPIO start index.
Definition BusModule.cpp:16
void cycle(uint8_t *response) override
Periodic cycle callback for the BusModule.
Definition BusModule.cpp:194
bool requestGPIOs() override
Request GPIO definitions from CANTramCore and validate pins for module interfaces.
Definition BusModule.cpp:41
bool provideHardwareResources() override
Provide hardware resources to CANTramCore.
Definition BusModule.cpp:117
String getHWVersion() const override
Get the hardware version string.
Definition BusModule.h:20
bool addI2CInterface()
Add and configure the I2C interface for this module.
Definition BusModule.cpp:243
bool requestHardwareResources() override
Request hardware resources required by the BusModule.
Definition BusModule.cpp:128
uint8_t getGPIODemand() const override
Get the GPIO demand of the module.
Definition BusModule.h:24
size_t getInterfaceCount() override
Get number of interfaces provided by the module.
Definition BusModule.h:46
uint8_t getGPIOSupply() const override
Get the GPIO supply capacity of the module.
Definition BusModule.h:26
String getFWVersion() const override
Get the firmware version string.
Definition BusModule.h:22
String getHWType() const override
Get the hardware type string.
Definition BusModule.h:18
bool addInterfaces() override
Add interfaces provided by the BusModule to the module interface list.
Definition BusModule.cpp:207
bool reset() override
Reset the module to a known default state.
Definition BusModule.cpp:315
bool preInitialize() override
Pre-initialize the module after attachment and provisioning.
Definition BusModule.cpp:277
bool provideGPIOs() override
Provide GPIO definitions to the core.
Definition BusModule.cpp:30
bool addUARTInterface()
Add and configure the UART interface for this module.
Definition BusModule.cpp:225
bool initialize() override
Initialize the module after attachment and provisioning.
Definition BusModule.cpp:271
Interface ** getInterfaces() override
Get pointer to module's interface array.
Definition BusModule.h:45
CANTramModule()=default
Default constructor.
Definition I2CInterface.h:8
Definition Interface.h:7
Describes an available output (GPIO or shift register bit).
Definition OutputDefinition.h:24
Definition SPIChip.h:9
Definition UARTInterface.h:7