1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

I2c: use Switch::selfTest to check i2c bus

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
Niklas Eiling 2024-01-09 17:06:23 +01:00 committed by Niklas Eiling
parent d4a868ae7c
commit b5682290c2
2 changed files with 8 additions and 0 deletions

View file

@ -32,6 +32,7 @@ public:
I2c();
virtual ~I2c();
virtual bool init() override;
virtual bool check() override;
virtual bool reset() override;
bool write(u8 address, std::vector<u8> &data);
bool read(u8 address, std::vector<u8> &data, size_t max_read);

View file

@ -60,6 +60,13 @@ bool I2c::init() {
return true;
}
bool I2c::check() {
if (!initDone) {
throw RuntimeError("I2C not initialized");
}
return getSwitch().selfTest();
}
bool I2c::reset() {
// we cannot lock here because this may be called in a destructor
XIic_Reset(&xIic);