blob: 84917661203788f88e1d1583801b1f1f7376b03a [file] [log] [blame] [edit]
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#pragma once
#include <cstdint>
#include <expected>
#include <string>
#include <system_error>
namespace i2c
{
void rebind_controller(const std::string_view number);
void new_device(unsigned int bus, unsigned int address,
std::string_view device_type);
// a simple RAII wrapper for raw i2c comms
struct RawDevice
{
RawDevice(size_t bus, uint8_t address);
~RawDevice();
RawDevice(const RawDevice&) = delete;
RawDevice& operator=(const RawDevice&) = delete;
RawDevice& operator=(RawDevice&&) = default;
RawDevice(RawDevice&&) = default;
std::expected<uint8_t, std::error_code> read_byte(uint8_t reg);
int fd;
};
} // namespace i2c