blob: d345ad3e8e2695ae58ef36d0253b61601a34f6e0 [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 ddk.protocol.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 {
vector<voidptr> data;
bool is_read;
bool stop;
};
[Layout = "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> op) -> (zx.status status, vector<I2cOp> op);
/// Returns the maximum transfer size for read and write operations on the channel.
GetMaxTransferSize() -> (zx.status s, usize size);
GetInterrupt(uint32 flags) -> (zx.status s, handle<interrupt> irq);
};