blob: f3e261cffd72b0662d67d15d888d394896260a1a [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.
@available(added=7)
library fuchsia.hardware.i2c;
using zx;
const I2C_10_BIT_ADDR_MASK uint32 = 0xF000;
const I2C_MAX_RW_OPS uint32 = 8;
const I2C_MAX_TOTAL_TRANSFER uint32 = 4096;
/// See `Transact` below for usage.
type I2cOp = struct {
@buffer
data vector<uint8>:MAX;
is_read bool;
stop bool;
};
@transport("Banjo")
@banjo_layout("ddk-protocol")
@handle_wrappers
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(struct {
op vector<I2cOp>:MAX;
}) -> (struct {
status zx.status;
op vector<I2cOp>:MAX;
});
/// Returns the maximum transfer size for read and write operations on the channel.
GetMaxTransferSize() -> (struct {
s zx.status;
size uint64;
});
};