On this page
article
peary/interfaces/I2C/i2c.hpp
peary/interfaces/I2C/i2c.hpp
Peary I2C Interface. More…
Namespaces
| Name |
|---|
| peary |
| peary::interface |
Classes
| Name | |
|---|---|
| struct | peary::interface::I2cInterface |
| class | peary::interface::I2CEndpoint |
Detailed Description
Peary I2C Interface.
Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only
Source code
#pragma once
#include <cstdint>
#include <vector>
#include "peary/interfaces/Endpoint.hpp"
#include "peary/utils/exceptions.hpp"
namespace peary::interface {
struct I2cInterface {};
class I2CEndpoint : public Endpoint<I2cInterface, uint8_t, uint8_t> {
public:
I2CEndpoint(const std::string& bus, uint8_t address);
~I2CEndpoint();
// FIXME these are not nice, we should work on a way to allow different widths
// TDOD(simonspa)
// - This class should be templated for register and data width
// - this requires unified bus communication unlike now
// - this requires a different locking scheme, e.g. with a type enum instead of the class, otherwise they don't lock
// the same mutex and run in parallel
vector_t wordwrite(const uint16_t& reg, const vector_t& data);
vector_t wordread(const uint16_t reg, const unsigned int length);
protected:
data_t write_impl(const data_t& data) override;
pair_t write_impl(const pair_t& data) override;
vector_t write_impl(const reg_t& reg, const vector_t& data) override;
vector_t read_impl(const unsigned int length) override;
vector_t read_impl(const reg_t& reg, const unsigned int length) override;
private:
int fd_;
uint8_t address_;
};
} // namespace peary::interface
Updated on 2026-01-30 at 22:01:05 +0100