diff --git a/fpga/include/villas/fpga/ips/i2c.hpp b/fpga/include/villas/fpga/ips/i2c.hpp index d342b4cc8..132e88f9e 100644 --- a/fpga/include/villas/fpga/ips/i2c.hpp +++ b/fpga/include/villas/fpga/ips/i2c.hpp @@ -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 &data); bool read(u8 address, std::vector &data, size_t max_read); diff --git a/fpga/lib/ips/i2c.cpp b/fpga/lib/ips/i2c.cpp index 186c96f89..577700ac8 100644 --- a/fpga/lib/ips/i2c.cpp +++ b/fpga/lib/ips/i2c.cpp @@ -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);