blob: fc1d5aa1a54a649258a2e40dce33807c368c6e79 [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.i2cimpl;
using zx;
const I2C_IMPL_10_BIT_ADDR_MASK uint32 = 0xF000;
/// The maximum number of I2cImplOp's that may be passed to Transact.
const I2C_IMPL_MAX_RW_OPS uint32 = 8;
/// The maximum length of all read or all write transfers in bytes.
const I2C_IMPL_MAX_TOTAL_TRANSFER uint32 = 4096;
/// See `Transact` below for usage.
type I2cImplOp = struct {
address uint16;
@buffer
@mutable
data vector<uint8>:MAX;
is_read bool;
stop bool;
};
/// Low-level protocol for i2c drivers.
@transport("Banjo")
@banjo_layout("ddk-protocol")
closed protocol I2cImpl {
strict GetMaxTransferSize() -> (struct {
s zx.Status;
size uint64;
});
/// Sets the bitrate for the i2c bus in KHz units.
strict SetBitrate(struct {
bitrate uint32;
}) -> (struct {
s zx.Status;
});
/// |Transact| assumes that all ops buf are not null.
/// |Transact| assumes that all ops length are not zero.
/// |Transact| assumes that at least the last op has stop set to true.
strict Transact(struct {
op vector<I2cImplOp>:MAX;
}) -> (struct {
status zx.Status;
});
};