Program Listing for File i2c.hh

Return to documentation for file (include/i2c_bus/i2c.hh)

#ifndef HIVLE_I2C_HH
#define HIVLE_I2C_HH

#include <cstdint>

namespace iplo {

class I2C {
    const char* _fileName;
    int _fd;
public:
    explicit I2C(const char* fileName);

    void selectDevice(std::uint8_t address);

    [[nodiscard]] std::int32_t readByte();

    [[nodiscard]] std::int32_t readByteData(std::uint8_t reg);

    [[nodiscard]] std::int32_t readWordData(std::uint16_t reg);

    [[nodiscard]] std::int32_t writeByte(std::uint8_t val);

    [[nodiscard]] std::int32_t writeByteData(std::uint8_t reg, std::uint8_t val);

    [[nodiscard]] std::int32_t writeWordData(std::uint8_t reg, std::uint16_t val);

    ~I2C();
};

} /* namespace iplo */

#endif /* HIVLE_I2C_HH */