eive-obsw/linux/boardtest/I2cTestClass.h
Robin Mueller 9456dc1a00
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
applied auto-formatter
2022-02-03 16:04:24 +01:00

41 lines
972 B
C++

#ifndef LINUX_BOARDTEST_I2CTESTCLASS_H_
#define LINUX_BOARDTEST_I2CTESTCLASS_H_
#include <test/testtasks/TestTask.h>
#include <array>
#include <string>
#include "mission/devices/devicedefinitions/BpxBatteryDefinitions.h"
class I2cTestClass : public TestTask {
public:
I2cTestClass(object_id_t objectId, std::string i2cdev);
ReturnValue_t initialize() override;
ReturnValue_t performPeriodicAction() override;
private:
enum TestModes { NONE, BPX_BATTERY };
struct I2cInfo {
int addr = 0;
int fd = 0;
};
TestModes mode = TestModes::NONE;
void battInit();
void battPeriodic();
I2cInfo bpxInfo = {.addr = 0x07, .fd = 0};
std::string i2cdev;
size_t sendLen = 0;
size_t recvLen = 0;
std::array<uint8_t, 64> cmdBuf = {};
std::array<uint8_t, 64> replyBuf = {};
ReturnValue_t i2cWrite(int fd, uint8_t* data, size_t len);
ReturnValue_t i2cRead(int fd, uint8_t* data, size_t len);
};
#endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */