-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a46894f
commit 5f1dd5a
Showing
18 changed files
with
787 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2024 tobias | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
|
||
#ifndef EXTBLUETOOTH_H | ||
#define EXTBLUETOOTH_H | ||
|
||
#include "extension/ExtDeviceI2C.h" | ||
#include "defines.h" | ||
|
||
|
||
class ExtBluetooth : public ExtDeviceI2C { | ||
public: | ||
ExtBluetooth(uint8_t address); | ||
~ExtBluetooth(); | ||
|
||
void initialize() override; | ||
|
||
void readBtData(); | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2024 Tobias Himmler | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
|
||
#ifndef EXTDEVICE_I2C_H | ||
#define EXTDEVICE_I2C_H | ||
|
||
#include "extension/ExtPeripheral.h" | ||
#include <stdint.h> | ||
|
||
#include "inverter/Inverter.hpp" | ||
|
||
class ExtDeviceI2C : public ExtPeripheral { | ||
private: | ||
static ExtDeviceI2C* instance; | ||
|
||
SemaphoreHandle_t mutexI2cRx = NULL; | ||
uint8_t mI2cRxBuf[256]; | ||
|
||
static void onReceiveWrapper(int len); | ||
static void onRequestWrapper(); | ||
void onReceiveCb(int len); | ||
void onRequestCb(); | ||
|
||
protected: | ||
uint8_t deviceAddress; | ||
|
||
void i2cCyclicRun(Inverter &inverter); | ||
|
||
void I2cRxSemaphoreTake(); | ||
void I2cRxSemaphoreGive(); | ||
|
||
void i2cWriteRegister(uint8_t u8_i2cDevAdr, uint8_t u8_reg, uint8_t u8_data); | ||
void i2cWriteBytes(uint8_t devAdr, uint8_t *data, uint8_t dataLen); | ||
void i2cReadBytes(uint8_t *data, uint8_t dataLen); | ||
uint8_t i2cRequest(uint8_t devAdr, uint8_t dataLen); | ||
|
||
void i2cSendData(Inverter &inverter, uint8_t i2cAdr, uint8_t data1, uint8_t data2, uint8_t data3, const void *dataAdr, uint8_t dataLen); | ||
void i2cSendData(Inverter &inverter, uint8_t i2cAdr, uint8_t data1, uint8_t data2, uint8_t data3, std::string data, uint8_t dataLen); | ||
void i2cSendData(Inverter &inverter, uint8_t i2cAdr, uint8_t data1, uint8_t data2, uint8_t data3, int16_t data); | ||
|
||
uint8_t isDeviceAvailable(uint8_t devAdresse); | ||
|
||
public: | ||
ExtDeviceI2C(uint8_t address); | ||
|
||
|
||
protected: | ||
//void writeByte(uint8_t reg, uint8_t data); | ||
//uint8_t readByte(uint8_t reg); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2024 tobias | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
|
||
#ifndef EXTDISPLAY_H | ||
#define EXTDISPLAY_H | ||
|
||
#include "extension/ExtDeviceI2C.h" | ||
#include "defines.h" | ||
|
||
|
||
class ExtDisplay : public ExtDeviceI2C { | ||
public: | ||
ExtDisplay(uint8_t address); | ||
~ExtDisplay(); | ||
|
||
void initialize() override; | ||
|
||
void sendDataStr(Inverter &inverter, uint8_t data1, uint8_t data2, std::string data, uint8_t dataLen); | ||
void sendData(Inverter &inverter); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2024 tobias | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
|
||
#ifndef EXTMANAGER_H | ||
#define EXTMANAGER_H | ||
|
||
#include <vector> | ||
#include <memory> | ||
#include "extension/ExtPeripheral.h" | ||
#include "extension/ExtSerial.h" | ||
#include "extension/ExtDisplay.h" | ||
#include "extension/ExtBluetooth.h" | ||
|
||
|
||
class ExtManager { | ||
public: | ||
ExtManager(); | ||
|
||
void initialize(); | ||
void cyclicRun(Inverter &inverter); | ||
|
||
ExtSerial &getSerial(size_t index); | ||
ExtDisplay &getDisplay(); | ||
ExtBluetooth &getBt(); | ||
|
||
private: | ||
const std::vector<uint8_t> serialAdresses = {I2C_DEV_ADDR_SERIAL_EXTENSION}; | ||
|
||
std::vector<std::unique_ptr<ExtSerial>> extSerials; | ||
ExtDisplay extDisplay; | ||
ExtBluetooth extBluetooth; | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2024 Tobias Himmler | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
|
||
#ifndef EXTPERIPHERAL_H | ||
#define EXTPERIPHERAL_H | ||
|
||
class ExtPeripheral { | ||
protected: | ||
bool enabled = false; | ||
|
||
virtual void initialize() = 0; // Initialisiert das Gerät | ||
|
||
void setEnabled(bool enable) { enabled = enable; } | ||
|
||
public: | ||
virtual ~ExtPeripheral() = default; // Virtueller Destruktor für saubere Speicherfreigabe | ||
|
||
bool isEnabled() const { return enabled; } | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2024 tobias | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
|
||
#ifndef EXTSERIAL_H | ||
#define EXTSERIAL_H | ||
|
||
#include "extension/ExtDeviceI2C.h" | ||
#include "defines.h" | ||
|
||
|
||
class ExtSerial : public ExtDeviceI2C { | ||
public: | ||
ExtSerial(uint8_t address); | ||
~ExtSerial(); | ||
|
||
void initialize() override; | ||
|
||
void extSerialSetEnable(uint8_t u8_serialDevNr, serialRxTxEn_e serialRxTxEn); | ||
|
||
}; | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.