eive-obsw/linux/boardtest/I2cTestClass.h

40 lines
931 B
C++

#ifndef LINUX_BOARDTEST_I2CTESTCLASS_H_
#define LINUX_BOARDTEST_I2CTESTCLASS_H_
#include <mission/power/bpxBattDefs.h>
#include <test/TestTask.h>
#include <array>
#include <string>
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_ */