| // 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.serialimpl; |
| |
| using zx; |
| using fuchsia.hardware.serial; |
| |
| type SerialState = strict enum : 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. |
| @transport("Banjo") |
| @banjo_layout("ddk-callback") |
| protocol SerialNotify { |
| Callback(struct { |
| state SerialState; |
| }) -> (); |
| }; |
| |
| @transport("Banjo") |
| @banjo_layout("ddk-protocol") |
| protocol SerialImpl { |
| GetInfo() -> (struct { |
| s zx.status; |
| info fuchsia.hardware.serial.SerialPortInfo; |
| }); |
| /// Configures the given serial port. |
| Config(struct { |
| baud_rate uint32; |
| flags uint32; |
| }) -> (struct { |
| s zx.status; |
| }); |
| Enable(struct { |
| enable bool; |
| }) -> (struct { |
| s zx.status; |
| }); |
| Read() -> (struct { |
| s zx.status; |
| @buffer |
| buf vector<uint8>:MAX; |
| }); |
| Write(struct { |
| @buffer |
| buf vector<uint8>:MAX; |
| }) -> (struct { |
| s zx.status; |
| actual uint64; |
| }); |
| SetNotifyCallback(resource struct { |
| cb client_end:SerialNotify; |
| }) -> (struct { |
| s zx.status; |
| }); |
| }; |