blob: 4c627991276097a1f722fe4838ebfa75cbaefe3e [file] [log] [blame]
Marc Olberding1e17db52025-08-27 12:25:28 -07001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2025 NVIDIA
3
4#pragma once
5
Marc Olberding5d50e522025-09-03 18:23:32 -07006#include <cstdint>
Marc Olberding1e17db52025-08-27 12:25:28 -07007#include <string>
8
9namespace i2c
10{
11
12void rebind_controller(const std::string_view number);
13void new_device(unsigned int bus, unsigned int address,
14 std::string_view device_type);
Marc Olberding5d50e522025-09-03 18:23:32 -070015
16// a simple RAII wrapper for raw i2c comms
17struct RawDevice
18{
19 RawDevice(size_t bus, uint8_t address);
20 ~RawDevice();
21 RawDevice(const RawDevice&) = delete;
22 RawDevice& operator=(const RawDevice&) = delete;
23 RawDevice& operator=(RawDevice&&) = default;
24 RawDevice(RawDevice&&) = default;
25
26 int read_byte(uint8_t reg, uint8_t& val);
27
28 int fd;
29};
Marc Olberding1e17db52025-08-27 12:25:28 -070030} // namespace i2c