blob: 7e50d48c8bcc5b9bf8b2ae9fef35de966e449085 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.hardware.i2c;
using zx;
const uint32 MAX_TRANSFER_SIZE = 8196; // More than enough for I2C
enum SegmentType {
/// Flags the end of a serialized list of segments.
END = 1;
/// Segment to be read from the I2C device.
READ = 2;
/// Segment to be written to the I2C device.
WRITE = 3;
};
/// Segment header for a serialized SubordinateTransfer.
/// TODO(ZX-3029): Avoid requiring serialization and have SubordinateTransfer take an argument of
/// `vector<Segment>:MAX_SEGMENTS` instead once we have better support in the C bindings or for C++.
struct Segment {
uint32 type;
uint32 len;
};
[Layout = "Simple"]
protocol Device {
/// Send and receive data on the I2C device.
SubordinateTransfer(vector<uint8>:MAX_TRANSFER_SIZE in) -> (zx.status s,
vector<uint8>:MAX_TRANSFER_SIZE out);
};