blob: 4ee8465572a3adde464fbf5635d6ad100e2935bf [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.serialimpl.async;
using zx;
using fuchsia.hardware.serial;
type SerialState = strict enum : uint32 {
READABLE = 0x1;
WRITABLE = 0x2;
};
@transport("Banjo")
@banjo_layout("ddk-protocol")
closed protocol SerialImplAsync {
strict GetInfo() -> (struct {
s zx.Status;
info fuchsia.hardware.serial.SerialPortInfo;
});
/// Configures the given serial port.
strict Config(struct {
baud_rate uint32;
flags uint32;
}) -> (struct {
s zx.Status;
});
strict Enable(struct {
enable bool;
}) -> (struct {
s zx.Status;
});
/// Queues a receive operation. It is an error to queue
/// more than one receive operation at a time.
/// The callback will be invoked on the interrupt thread or the calling thread
/// if the write completes immediately.
/// ZX_ERR_NOT_SUPPORTED will be returned if a read is already pending.
@async
strict ReadAsync() -> (struct {
s zx.Status;
@buffer
buf vector<uint8>:MAX;
});
/// Queues a packet for transmission. It is an error to queue
/// more than one transmit at a time. The callback will be invoked
/// on the interrupt thread, or the calling thread if data is available.
/// ZX_ERR_NOT_SUPPORTED will be returned if a write is already pending.
@async
strict WriteAsync(struct {
@buffer
buf vector<uint8>:MAX;
}) -> (struct {
s zx.Status;
});
/// Immediately cancels all outstanding asynchronous I/O
strict CancelAll() -> ();
};