blob: 5a14dbc94bf73a041735e2948250cda24ab202ce [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.gpio;
using zx;
/// Flags for `ConfigIn`.
const GPIO_PULL_DOWN uint32 = 0x0;
const GPIO_PULL_UP uint32 = 0x1;
const GPIO_NO_PULL uint32 = 0x2;
const GPIO_PULL_MASK uint32 = 0x3;
/// Values for `SetPolarity`.
type GpioPolarity = strict enum : uint32 {
LOW = 0x0;
HIGH = 0x1;
};
@transport("Banjo")
@banjo_layout("ddk-protocol")
protocol Gpio {
/// Configures a GPIO for input.
ConfigIn(struct {
flags uint32;
}) -> (struct {
s zx.status;
});
/// Configures a GPIO for output.
ConfigOut(struct {
initial_value uint8;
}) -> (struct {
s zx.status;
});
/// Configures the GPIO pin for an alternate function (I2C, SPI, etc)
/// the interpretation of "function" is platform dependent.
SetAltFunction(struct {
function uint64;
}) -> (struct {
s zx.status;
});
/// Reads the current value of a GPIO (0 or 1).
Read() -> (struct {
s zx.status;
value uint8;
});
/// Sets the current value of the GPIO (any non-zero value maps to 1).
Write(struct {
value uint8;
}) -> (struct {
s zx.status;
});
/// Gets an interrupt object pertaining to a particular GPIO pin.
GetInterrupt(struct {
flags uint32;
}) -> (resource struct {
s zx.status;
irq zx.handle:INTERRUPT;
});
/// Release the interrupt.
ReleaseInterrupt() -> (struct {
s zx.status;
});
/// Set GPIO polarity.
SetPolarity(struct {
polarity GpioPolarity;
}) -> (struct {
s zx.status;
});
/// Set GPIO drive strength.
SetDriveStrength(struct {
ds_ua uint64;
}) -> (struct {
s zx.status;
actual_ds_ua uint64;
});
/// Get GPIO drive strength.
GetDriveStrength() -> (struct {
s zx.status;
value uint64;
});
};