1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <zircon/compiler.h> 8 #include <zircon/types.h> 9 #include <zircon/device/ioctl.h> 10 #include <zircon/device/ioctl-wrapper.h> 11 12 __BEGIN_CDECLS; 13 14 // flags for serial_config() 15 #define SERIAL_DATA_BITS_5 (0 << 0) 16 #define SERIAL_DATA_BITS_6 (1 << 0) 17 #define SERIAL_DATA_BITS_7 (2 << 0) 18 #define SERIAL_DATA_BITS_8 (3 << 0) 19 #define SERIAL_DATA_BITS_MASK (3 << 0) 20 21 #define SERIAL_STOP_BITS_1 (0 << 2) 22 #define SERIAL_STOP_BITS_2 (1 << 2) 23 #define SERIAL_STOP_BITS_MASK (1 << 2) 24 25 #define SERIAL_PARITY_NONE (0 << 3) 26 #define SERIAL_PARITY_EVEN (1 << 3) 27 #define SERIAL_PARITY_ODD (2 << 3) 28 #define SERIAL_PARITY_MASK (3 << 3) 29 30 #define SERIAL_FLOW_CTRL_NONE (0 << 5) 31 #define SERIAL_FLOW_CTRL_CTS_RTS (1 << 5) 32 #define SERIAL_FLOW_CTRL_MASK (1 << 5) 33 34 // Set this flag to change baud rate but leave other properties unchanged 35 #define SERIAL_SET_BAUD_RATE_ONLY (1 << 31) 36 37 // serial port device class 38 #define SERIAL_CLASS_GENERIC 0 39 #define SERIAL_CLASS_BLUETOOTH_HCI 1 40 #define SERIAL_CLASS_CONSOLE 2 41 42 typedef struct { 43 uint32_t baud_rate; 44 uint32_t flags; 45 } serial_config_t; 46 47 // Sets the configuration for a serial device 48 #define IOCTL_SERIAL_CONFIG IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_SERIAL, 0) 49 50 #define IOCTL_SERIAL_GET_CLASS IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_SERIAL, 1) 51 52 IOCTL_WRAPPER_IN(ioctl_serial_config, IOCTL_SERIAL_CONFIG, serial_config_t) 53 IOCTL_WRAPPER_OUT(ioctl_serial_get_class, IOCTL_SERIAL_GET_CLASS, uint32_t) 54 55 __END_CDECLS; 56