eive-obsw/linux/boardtest/I2cTestClass.h

40 lines
931 B
C
Raw Permalink Normal View History

2021-02-14 19:22:58 +01:00
#ifndef LINUX_BOARDTEST_I2CTESTCLASS_H_
#define LINUX_BOARDTEST_I2CTESTCLASS_H_
2023-03-26 16:13:54 +02:00
#include <mission/power/bpxBattDefs.h>
2022-11-28 11:35:28 +01:00
#include <test/TestTask.h>
2021-02-14 19:22:58 +01:00
2022-02-03 13:37:48 +01:00
#include <array>
2022-02-03 16:04:24 +01:00
#include <string>
2022-01-17 13:48:55 +01:00
class I2cTestClass : public TestTask {
public:
2022-02-03 13:37:48 +01:00
I2cTestClass(object_id_t objectId, std::string i2cdev);
2021-02-14 19:22:58 +01:00
2022-02-03 13:37:48 +01:00
ReturnValue_t initialize() override;
2022-01-17 13:48:55 +01:00
ReturnValue_t performPeriodicAction() override;
2021-02-14 19:22:58 +01:00
2022-01-17 13:48:55 +01:00
private:
2022-02-03 16:04:24 +01:00
enum TestModes { NONE, BPX_BATTERY };
2022-02-03 13:37:48 +01:00
struct I2cInfo {
int addr = 0;
int fd = 0;
};
TestModes mode = TestModes::NONE;
void battInit();
void battPeriodic();
2022-02-03 16:04:24 +01:00
I2cInfo bpxInfo = {.addr = 0x07, .fd = 0};
2022-02-03 13:37:48 +01:00
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);
2021-02-14 19:22:58 +01:00
};
#endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */