1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** USBX Component */ 17 /** */ 18 /** PROLIFIC Class */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /**************************************************************************/ 25 /* */ 26 /* COMPONENT DEFINITION RELEASE */ 27 /* */ 28 /* ux_host_class_prolific.h PORTABLE C */ 29 /* 6.1.8 */ 30 /* AUTHOR */ 31 /* */ 32 /* Chaoqiong Xiao, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file contains all the header and extern functions used by the */ 37 /* USBX PROLIFIC class. */ 38 /* */ 39 /* RELEASE HISTORY */ 40 /* */ 41 /* DATE NAME DESCRIPTION */ 42 /* */ 43 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 44 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 45 /* used UX prefix to refer to */ 46 /* TX symbols instead of using */ 47 /* them directly, */ 48 /* resulting in version 6.1 */ 49 /* 08-02-2021 Wen Wang Modified comment(s), */ 50 /* added extern "C" keyword */ 51 /* for compatibility with C++, */ 52 /* resulting in version 6.1.8 */ 53 /* */ 54 /**************************************************************************/ 55 56 #ifndef UX_HOST_CLASS_PROLIFIC_H 57 #define UX_HOST_CLASS_PROLIFIC_H 58 59 /* Determine if a C++ compiler is being used. If so, ensure that standard 60 C is used to process the API information. */ 61 62 #ifdef __cplusplus 63 64 /* Yes, C++ compiler is present. Use standard C. */ 65 extern "C" { 66 67 #endif 68 69 /* Define PROLIFIC Class constants. */ 70 71 #define UX_HOST_CLASS_PROLIFIC_DEVICE_INIT_DELAY (1 * UX_PERIODIC_RATE) 72 #define UX_HOST_CLASS_PROLIFIC_CLASS_TRANSFER_TIMEOUT 300000 73 #define UX_HOST_CLASS_PROLIFIC_SETUP_BUFFER_SIZE 16 74 #define UX_HOST_CLASS_PROLIFIC_DEVICE_PRESENT 1 75 #define UX_HOST_CLASS_PROLIFIC_DEVICE_NOT_PRESENT 0 76 #define UX_HOST_CLASS_PROLIFIC_DEVICE_STATE_OFFSET 8 77 #define UX_HOST_CLASS_PROLIFIC_DEVICE_STATE_MASK 0x7F 78 #define UX_HOST_CLASS_PROLIFIC_DEVICE_TYPE_0 0 79 #define UX_HOST_CLASS_PROLIFIC_DEVICE_TYPE_1 1 80 #define UX_HOST_CLASS_PROLIFIC_DEVICE_TYPE_HX 2 81 #define UX_HOST_CLASS_PROLIFIC_VENDOR_READ_REQUEST 1 82 #define UX_HOST_CLASS_PROLIFIC_VENDOR_WRITE_REQUEST 1 83 84 /* Define PROLIFIC Class descriptor subtypes in functional descriptors. */ 85 #define UX_HOST_CLASS_PROLIFIC_HEADER_DESCRIPTOR 0X00 86 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_DESCRIPTOR 0X01 87 #define UX_HOST_CLASS_PROLIFIC_ABSTRACT_CONTROL_MGT_DESCRIPTOR 0X02 88 #define UX_HOST_CLASS_PROLIFIC_DIRECT_LINE_MGT_DESCRIPTOR 0X03 89 #define UX_HOST_CLASS_PROLIFIC_TELEPHONE_RINGER_DESCRIPTOR 0X04 90 #define UX_HOST_CLASS_PROLIFIC_REPORT_CAPABILITY_DESCRIPTOR 0X05 91 #define UX_HOST_CLASS_PROLIFIC_UNION_DESCRIPTOR 0X06 92 #define UX_HOST_CLASS_PROLIFIC_COUNTRY_SELECTION_DESCRIPTOR 0X07 93 #define UX_HOST_CLASS_PROLIFIC_TELEPHONE_OPERATIONAL_DESCRIPTOR 0X08 94 #define UX_HOST_CLASS_PROLIFIC_USB_TERMINAL_DESCRIPTOR 0X09 95 96 /* Define PROLIFIC Class call management descriptors. */ 97 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_CAPABILITIES 0x03 98 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_DCM 0x01 99 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_DCI 0x02 100 101 /* Define PROLIFIC command request values. */ 102 103 #define UX_HOST_CLASS_PROLIFIC_REQ_SEND_ENCAPSULATED_COMMAND 0x00 104 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_ENCAPSULATED_COMMAND 0x01 105 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_COMM_FEATURE 0x02 106 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_COMM_FEATURE 0x03 107 #define UX_HOST_CLASS_PROLIFIC_REQ_CLEAR_COMM_FEATURE 0x04 108 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_AUX_LINE_STATE 0x10 109 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_HOOK_STATE 0x11 110 #define UX_HOST_CLASS_PROLIFIC_REQ_PULSE_SETUP 0x12 111 #define UX_HOST_CLASS_PROLIFIC_REQ_SEND_PULSE 0x13 112 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_PUSLE_TIME 0x14 113 #define UX_HOST_CLASS_PROLIFIC_REQ_RING_AUX_JACK 0x15 114 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_LINE_CODING 0x20 115 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_LINE_CODING 0x21 116 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_LINE_STATE 0x22 117 #define UX_HOST_CLASS_PROLIFIC_REQ_SEND_BREAK 0x23 118 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_RINGER_PARMS 0x30 119 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_RINGER_PARMS 0x31 120 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_OPERATION_PARMS 0x32 121 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_OPERATION_PARMS 0x33 122 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_LINE_PARMS 0x34 123 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_LINE_PARMS 0x35 124 125 /* Define PROLIFIC line output control values. */ 126 127 #define UX_HOST_CLASS_PROLIFIC_CTRL_DTR 0x01 128 #define UX_HOST_CLASS_PROLIFIC_CTRL_RTS 0x02 129 130 /* Define PROLIFIC line input control values. */ 131 132 #define UX_HOST_CLASS_PROLIFIC_CTRL_DCD 0x01 133 #define UX_HOST_CLASS_PROLIFIC_CTRL_DSR 0x02 134 #define UX_HOST_CLASS_PROLIFIC_CTRL_BRK 0x04 135 #define UX_HOST_CLASS_PROLIFIC_CTRL_RI 0x08 136 137 #define UX_HOST_CLASS_PROLIFIC_CTRL_FRAMING 0x10 138 #define UX_HOST_CLASS_PROLIFIC_CTRL_PARITY 0x20 139 #define UX_HOST_CLASS_PROLIFIC_CTRL_OVERRUN 0x40 140 141 #define UX_HOST_CLASS_PROLIFIC_COMMAND_EEPROM_READ 0x8484 142 #define UX_HOST_CLASS_PROLIFIC_COMMAND_EEPROM_WRITE 0x0404 143 #define UX_HOST_CLASS_PROLIFIC_COMMAND_EEPROM_ADDRESS 0x8383 144 #define UX_HOST_CLASS_PROLIFIC_COMMAND_REG_CONFIGURE 0x0002 145 #define UX_HOST_CLASS_PROLIFIC_COMMAND_PIPE1_RESET 0x0008 146 #define UX_HOST_CLASS_PROLIFIC_COMMAND_PIPE2_RESET 0x0009 147 148 /* Define PROLIFIC Class packet equivalences. */ 149 150 #define UX_HOST_CLASS_PROLIFIC_PACKET_SIZE 128 151 152 /* Define PROLIFIC default values. */ 153 154 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_RATE 19200 155 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_DATA_BIT 8 156 157 /* Define PROLIFIC line coding definitions. */ 158 159 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_0 0 160 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_15 1 161 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_2 2 162 163 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_NONE 0 164 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_ODD 1 165 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_EVEN 2 166 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_MARK 3 167 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_SPACE 4 168 169 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_LENGTH 7 170 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_RATE 0 171 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT 4 172 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY 5 173 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DATA_BIT 6 174 175 /* Define PROLIFIC line state definitions. */ 176 177 #define UX_HOST_CLASS_PROLIFIC_LINE_STATE_STOP_BIT_0 0 178 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_15 1 179 180 /* Define PROLIFIC IOCTL Functions. */ 181 182 #define UX_HOST_CLASS_PROLIFIC_IOCTL_SET_LINE_CODING 0 183 #define UX_HOST_CLASS_PROLIFIC_IOCTL_GET_LINE_CODING 1 184 #define UX_HOST_CLASS_PROLIFIC_IOCTL_SET_LINE_STATE 2 185 #define UX_HOST_CLASS_PROLIFIC_IOCTL_SEND_BREAK 3 186 #define UX_HOST_CLASS_PROLIFIC_IOCTL_PURGE 4 187 #define UX_HOST_CLASS_PROLIFIC_IOCTL_ABORT_IN_PIPE 5 188 #define UX_HOST_CLASS_PROLIFIC_IOCTL_ABORT_OUT_PIPE 6 189 #define UX_HOST_CLASS_PROLIFIC_IOCTL_REPORT_DEVICE_STATUS_CHANGE 7 190 #define UX_HOST_CLASS_PROLIFIC_IOCTL_GET_DEVICE_STATUS 8 191 192 /* Define PROLIFIC Reception States. */ 193 194 #define UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_STOPPED 0 195 #define UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_STARTED 1 196 #define UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_IN_TRANSFER 2 197 198 199 /* Define PROLIFIC Class instance structure. */ 200 201 typedef struct UX_HOST_CLASS_PROLIFIC_STRUCT 202 { 203 struct UX_HOST_CLASS_PROLIFIC_STRUCT 204 *ux_host_class_prolific_next_instance; 205 UX_HOST_CLASS *ux_host_class_prolific_class; 206 UX_DEVICE *ux_host_class_prolific_device; 207 UX_ENDPOINT *ux_host_class_prolific_bulk_in_endpoint; 208 UX_ENDPOINT *ux_host_class_prolific_bulk_out_endpoint; 209 UX_ENDPOINT *ux_host_class_prolific_interrupt_endpoint; 210 UX_INTERFACE *ux_host_class_prolific_interface; 211 UINT ux_host_class_prolific_instance_status; 212 UINT ux_host_class_prolific_state; 213 UX_SEMAPHORE ux_host_class_prolific_semaphore; 214 ULONG ux_host_class_prolific_notification_count; 215 ULONG ux_host_class_prolific_device_state; 216 VOID (*ux_host_class_prolific_device_status_change_callback)(struct UX_HOST_CLASS_PROLIFIC_STRUCT *prolific, 217 ULONG device_state); 218 219 ULONG ux_host_class_prolific_version; 220 UCHAR ux_host_class_prolific_device_type; 221 struct UX_HOST_CLASS_PROLIFIC_RECEPTION_STRUCT 222 *ux_host_class_prolific_reception; 223 224 } UX_HOST_CLASS_PROLIFIC; 225 226 227 /* Define PROLIFIC reception structure. */ 228 229 typedef struct UX_HOST_CLASS_PROLIFIC_RECEPTION_STRUCT 230 { 231 232 ULONG ux_host_class_prolific_reception_state; 233 ULONG ux_host_class_prolific_reception_block_size; 234 UCHAR *ux_host_class_prolific_reception_data_buffer; 235 ULONG ux_host_class_prolific_reception_data_buffer_size; 236 UCHAR *ux_host_class_prolific_reception_data_head; 237 UCHAR *ux_host_class_prolific_reception_data_tail; 238 VOID (*ux_host_class_prolific_reception_callback)(struct UX_HOST_CLASS_PROLIFIC_STRUCT *prolific, 239 UINT status, 240 UCHAR *reception_buffer, 241 ULONG reception_size); 242 243 } UX_HOST_CLASS_PROLIFIC_RECEPTION; 244 245 /* Define PROLIFIC Line Coding IOCTL structure. */ 246 247 typedef struct UX_HOST_CLASS_PROLIFIC_LINE_CODING_STRUCT 248 { 249 250 ULONG ux_host_class_prolific_line_coding_dter; 251 ULONG ux_host_class_prolific_line_coding_stop_bit; 252 ULONG ux_host_class_prolific_line_coding_parity; 253 ULONG ux_host_class_prolific_line_coding_data_bits; 254 255 } UX_HOST_CLASS_PROLIFIC_LINE_CODING; 256 257 /* Define PROLIFIC Line State IOCTL structure. */ 258 259 typedef struct UX_HOST_CLASS_PROLIFIC_LINE_STATE_STRUCT 260 { 261 262 ULONG ux_host_class_prolific_line_state_rts; 263 ULONG ux_host_class_prolific_line_state_dtr; 264 265 } UX_HOST_CLASS_PROLIFIC_LINE_STATE; 266 267 /* Define PROLIFIC Line break IOCTL structure. */ 268 269 typedef struct UX_HOST_CLASS_PROLIFIC_LINE_BREAK_STRUCT 270 { 271 272 ULONG ux_host_class_prolific_line_break; 273 274 } UX_HOST_CLASS_PROLIFIC_LINE_BREAK; 275 276 277 /* Define Prolific Class function prototypes. */ 278 279 UINT _ux_host_class_prolific_activate(UX_HOST_CLASS_COMMAND *command); 280 UINT _ux_host_class_prolific_configure(UX_HOST_CLASS_PROLIFIC *prolific); 281 UINT _ux_host_class_prolific_deactivate(UX_HOST_CLASS_COMMAND *command); 282 UINT _ux_host_class_prolific_endpoints_get(UX_HOST_CLASS_PROLIFIC *prolific); 283 UINT _ux_host_class_prolific_entry(UX_HOST_CLASS_COMMAND *command); 284 UINT _ux_host_class_prolific_read (UX_HOST_CLASS_PROLIFIC *prolific, UCHAR *data_pointer, 285 ULONG requested_length, ULONG *actual_length); 286 UINT _ux_host_class_prolific_write(UX_HOST_CLASS_PROLIFIC *prolific, UCHAR *data_pointer, 287 ULONG requested_length, ULONG *actual_length); 288 UINT _ux_host_class_prolific_ioctl(UX_HOST_CLASS_PROLIFIC *prolific, ULONG request, 289 VOID *parameter); 290 UINT _ux_host_class_prolific_command(UX_HOST_CLASS_PROLIFIC *prolific, ULONG command, 291 ULONG value, UCHAR *data_buffer, ULONG data_length); 292 VOID _ux_host_class_prolific_transfer_request_completed(UX_TRANSFER *transfer_request); 293 UINT _ux_host_class_prolific_reception_stop (UX_HOST_CLASS_PROLIFIC *prolific, 294 UX_HOST_CLASS_PROLIFIC_RECEPTION *prolific_reception); 295 UINT _ux_host_class_prolific_reception_start (UX_HOST_CLASS_PROLIFIC *prolific, 296 UX_HOST_CLASS_PROLIFIC_RECEPTION *prolific_reception); 297 298 VOID _ux_host_class_prolific_reception_callback (UX_TRANSFER *transfer_request); 299 UINT _ux_host_class_prolific_setup(UX_HOST_CLASS_PROLIFIC *prolific); 300 301 /* Define Prolific Class API prototypes. */ 302 303 #define ux_host_class_prolific_entry _ux_host_class_prolific_entry 304 #define ux_host_class_prolific_read _ux_host_class_prolific_read 305 #define ux_host_class_prolific_write _ux_host_class_prolific_write 306 #define ux_host_class_prolific_ioctl _ux_host_class_prolific_ioctl 307 #define ux_host_class_prolific_command _ux_host_class_prolific_command 308 #define ux_host_class_prolific_reception_stop _ux_host_class_prolific_reception_stop 309 #define ux_host_class_prolific_reception_start _ux_host_class_prolific_reception_start 310 #define ux_host_class_prolific_setup _ux_host_class_prolific_setup 311 312 /* Determine if a C++ compiler is being used. If so, complete the standard 313 C conditional started above. */ 314 #ifdef __cplusplus 315 } 316 #endif 317 318 #endif 319