Marc Olberding | 1e17db5 | 2025-08-27 12:25:28 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: 2025 NVIDIA |
| 3 | |
| 4 | #pragma once |
| 5 | |
Marc Olberding | 5d50e52 | 2025-09-03 18:23:32 -0700 | [diff] [blame^] | 6 | #include <cstdint> |
Marc Olberding | 1e17db5 | 2025-08-27 12:25:28 -0700 | [diff] [blame] | 7 | #include <string> |
| 8 | |
| 9 | namespace i2c |
| 10 | { |
| 11 | |
| 12 | void rebind_controller(const std::string_view number); |
| 13 | void new_device(unsigned int bus, unsigned int address, |
| 14 | std::string_view device_type); |
Marc Olberding | 5d50e52 | 2025-09-03 18:23:32 -0700 | [diff] [blame^] | 15 | |
| 16 | // a simple RAII wrapper for raw i2c comms |
| 17 | struct 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 Olberding | 1e17db5 | 2025-08-27 12:25:28 -0700 | [diff] [blame] | 30 | } // namespace i2c |