blob: efa5cdbfc066997f80a2bc5ba053799e7e403c30 [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.serial;
using zx;
// Flags that can be passed to Serial/Config()
// Select the character width
const uint32 SERIAL_DATA_BITS_5 = 0x0;
const uint32 SERIAL_DATA_BITS_6 = 0x1;
const uint32 SERIAL_DATA_BITS_7 = 0x2;
const uint32 SERIAL_DATA_BITS_8 = 0x3;
const uint32 SERIAL_DATA_BITS_MASK = 0x3;
// Select the number of stop bits
const uint32 SERIAL_STOP_BITS_1 = 0x0;
const uint32 SERIAL_STOP_BITS_2 = 0x4;
const uint32 SERIAL_STOP_BITS_MASK = 0x4;
// Select the parity mechanism
const uint32 SERIAL_PARITY_NONE = 0x00;
const uint32 SERIAL_PARITY_EVEN = 0x08;
const uint32 SERIAL_PARITY_ODD = 0x10;
const uint32 SERIAL_PARITY_MASK = 0x18;
// Select the flow control mechanism
const uint32 SERIAL_FLOW_CTRL_NONE = 0x00;
const uint32 SERIAL_FLOW_CTRL_CTS_RTS = 0x20;
const uint32 SERIAL_FLOW_CTRL_MASK = 0x20;
// Set this flag to change baud rate but leave other properties unchanged
const uint32 SERIAL_SET_BAUD_RATE_ONLY = 0x80000000;
struct SerialPortInfo {
/// Values from the FIDL enum fuchsia.hardware.serial.Class
uint32 serial_class;
/// Vendor and product ID of hardware attached to this serial port,
/// or zero if not applicable.
uint32 serial_vid;
uint32 serial_pid;
};
/// High level serial protocol for use by client drivers.
/// When used with the platform device protocol, "port" will be relative to
/// the list of serial ports assigned to your device rather than the global
/// list of serial ports.
[Layout = "ddk-protocol"]
protocol Serial {
GetInfo() -> (zx.status s, SerialPortInfo info);
/// Configures the given serial port.
Config(uint32 baud_rate, uint32 flags) -> (zx.status s);
/// Returns a socket that can be used for reading and writing data
/// from the given serial port.
OpenSocket() -> (zx.status s, handle<socket> @handle);
};