blob: 46d1e7aa7fc0e34ae5a9450cc7df3af72d3eec56 [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 I2C_10_BIT_ADDR_MASK = 0xF000;
const uint32 I2C_MAX_RW_OPS = 8;
const uint32 I2C_MAX_TOTAL_TRANSFER = 4096;
/// See `Transact` below for usage.
struct I2cOp {
[Buffer] vector<uint8>:MAX data;
bool is_read;
bool stop;
};
[Transport = "Banjo", BanjoLayout = "ddk-protocol", HandleWrappers]
protocol I2c {
/// Writes and reads data on an i2c channel. Up to I2C_MAX_RW_OPS operations can be passed in
/// with a maximum of I2C_MAX_TOTAL_TRANSFER total bytes transfered.
/// For write ops, i2c_op_t.data points to data to write. The data to write does not need to be
/// kept alive after this call. For read ops, i2c_op_t.data is ignored. Any combination of
/// reads and writes can be specified. At least the last op must have the stop flag set.
/// The results of the operations are returned asynchronously via the transact_cb.
/// The cookie parameter can be used to pass your own private data to the transact_cb callback.
[Async]
Transact(vector<I2cOp>:MAX op) -> (zx.status status, vector<I2cOp>:MAX op);
/// Returns the maximum transfer size for read and write operations on the channel.
GetMaxTransferSize() -> (zx.status s, uint64 size);
GetInterrupt(uint32 flags) -> (zx.status s, zx.handle:INTERRUPT irq);
};