blob: 2faceefb8cdcc72d076c80890e0b0c9cfa9d6712 [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.serialimpl;
using zx;
using ddk.protocol.serial;
enum SerialState : uint32 {
READABLE = 0x1;
WRITABLE = 0x2;
};
/// Callback for notification of readable/writeable state changes
/// This may be called from an interrupt thread it should just signal another thread
/// and return as soon as possible. In particular, it may not be safe to make protocol calls
/// from these callbacks.
[Layout = "ddk-callback"]
protocol SerialNotify {
Callback(SerialState state) -> ();
};
[Layout = "ddk-protocol"]
protocol SerialImpl {
GetInfo() -> (zx.status s, ddk.protocol.serial.SerialPortInfo info);
/// Configures the given serial port.
Config(uint32 baud_rate, uint32 flags) -> (zx.status s);
Enable(bool enable) -> (zx.status s);
Read() -> (zx.status s, vector<voidptr> buf);
Write(vector<voidptr> buf) -> (zx.status s, usize actual);
SetNotifyCallback(SerialNotify cb) -> (zx.status s);
};