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 70 /* Internal option: enable the basic USBX error checking. This define is typically used 71 while debugging application. */ 72 #if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_HOST_CLASS_PROLIFIC_ENABLE_ERROR_CHECKING) 73 #define UX_HOST_CLASS_PROLIFIC_ENABLE_ERROR_CHECKING 74 #endif 75 76 77 /* Define PROLIFIC Class constants. */ 78 79 #define UX_HOST_CLASS_PROLIFIC_DEVICE_INIT_DELAY (1 * UX_PERIODIC_RATE) 80 #define UX_HOST_CLASS_PROLIFIC_CLASS_TRANSFER_TIMEOUT 300000 81 #define UX_HOST_CLASS_PROLIFIC_SETUP_BUFFER_SIZE 16 82 #define UX_HOST_CLASS_PROLIFIC_DEVICE_PRESENT 1 83 #define UX_HOST_CLASS_PROLIFIC_DEVICE_NOT_PRESENT 0 84 #define UX_HOST_CLASS_PROLIFIC_DEVICE_STATE_OFFSET 8 85 #define UX_HOST_CLASS_PROLIFIC_DEVICE_STATE_MASK 0x7F 86 #define UX_HOST_CLASS_PROLIFIC_DEVICE_TYPE_0 0 87 #define UX_HOST_CLASS_PROLIFIC_DEVICE_TYPE_1 1 88 #define UX_HOST_CLASS_PROLIFIC_DEVICE_TYPE_HX 2 89 #define UX_HOST_CLASS_PROLIFIC_VENDOR_READ_REQUEST 1 90 #define UX_HOST_CLASS_PROLIFIC_VENDOR_WRITE_REQUEST 1 91 92 /* Define PROLIFIC Class descriptor subtypes in functional descriptors. */ 93 #define UX_HOST_CLASS_PROLIFIC_HEADER_DESCRIPTOR 0X00 94 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_DESCRIPTOR 0X01 95 #define UX_HOST_CLASS_PROLIFIC_ABSTRACT_CONTROL_MGT_DESCRIPTOR 0X02 96 #define UX_HOST_CLASS_PROLIFIC_DIRECT_LINE_MGT_DESCRIPTOR 0X03 97 #define UX_HOST_CLASS_PROLIFIC_TELEPHONE_RINGER_DESCRIPTOR 0X04 98 #define UX_HOST_CLASS_PROLIFIC_REPORT_CAPABILITY_DESCRIPTOR 0X05 99 #define UX_HOST_CLASS_PROLIFIC_UNION_DESCRIPTOR 0X06 100 #define UX_HOST_CLASS_PROLIFIC_COUNTRY_SELECTION_DESCRIPTOR 0X07 101 #define UX_HOST_CLASS_PROLIFIC_TELEPHONE_OPERATIONAL_DESCRIPTOR 0X08 102 #define UX_HOST_CLASS_PROLIFIC_USB_TERMINAL_DESCRIPTOR 0X09 103 104 /* Define PROLIFIC Class call management descriptors. */ 105 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_CAPABILITIES 0x03 106 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_DCM 0x01 107 #define UX_HOST_CLASS_PROLIFIC_CALL_MANAGEMENT_DCI 0x02 108 109 /* Define PROLIFIC command request values. */ 110 111 #define UX_HOST_CLASS_PROLIFIC_REQ_SEND_ENCAPSULATED_COMMAND 0x00 112 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_ENCAPSULATED_COMMAND 0x01 113 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_COMM_FEATURE 0x02 114 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_COMM_FEATURE 0x03 115 #define UX_HOST_CLASS_PROLIFIC_REQ_CLEAR_COMM_FEATURE 0x04 116 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_AUX_LINE_STATE 0x10 117 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_HOOK_STATE 0x11 118 #define UX_HOST_CLASS_PROLIFIC_REQ_PULSE_SETUP 0x12 119 #define UX_HOST_CLASS_PROLIFIC_REQ_SEND_PULSE 0x13 120 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_PUSLE_TIME 0x14 121 #define UX_HOST_CLASS_PROLIFIC_REQ_RING_AUX_JACK 0x15 122 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_LINE_CODING 0x20 123 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_LINE_CODING 0x21 124 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_LINE_STATE 0x22 125 #define UX_HOST_CLASS_PROLIFIC_REQ_SEND_BREAK 0x23 126 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_RINGER_PARMS 0x30 127 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_RINGER_PARMS 0x31 128 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_OPERATION_PARMS 0x32 129 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_OPERATION_PARMS 0x33 130 #define UX_HOST_CLASS_PROLIFIC_REQ_SET_LINE_PARMS 0x34 131 #define UX_HOST_CLASS_PROLIFIC_REQ_GET_LINE_PARMS 0x35 132 133 /* Define PROLIFIC line output control values. */ 134 135 #define UX_HOST_CLASS_PROLIFIC_CTRL_DTR 0x01 136 #define UX_HOST_CLASS_PROLIFIC_CTRL_RTS 0x02 137 138 /* Define PROLIFIC line input control values. */ 139 140 #define UX_HOST_CLASS_PROLIFIC_CTRL_DCD 0x01 141 #define UX_HOST_CLASS_PROLIFIC_CTRL_DSR 0x02 142 #define UX_HOST_CLASS_PROLIFIC_CTRL_BRK 0x04 143 #define UX_HOST_CLASS_PROLIFIC_CTRL_RI 0x08 144 145 #define UX_HOST_CLASS_PROLIFIC_CTRL_FRAMING 0x10 146 #define UX_HOST_CLASS_PROLIFIC_CTRL_PARITY 0x20 147 #define UX_HOST_CLASS_PROLIFIC_CTRL_OVERRUN 0x40 148 149 #define UX_HOST_CLASS_PROLIFIC_COMMAND_EEPROM_READ 0x8484 150 #define UX_HOST_CLASS_PROLIFIC_COMMAND_EEPROM_WRITE 0x0404 151 #define UX_HOST_CLASS_PROLIFIC_COMMAND_EEPROM_ADDRESS 0x8383 152 #define UX_HOST_CLASS_PROLIFIC_COMMAND_REG_CONFIGURE 0x0002 153 #define UX_HOST_CLASS_PROLIFIC_COMMAND_PIPE1_RESET 0x0008 154 #define UX_HOST_CLASS_PROLIFIC_COMMAND_PIPE2_RESET 0x0009 155 156 /* Define PROLIFIC Class packet equivalences. */ 157 158 #define UX_HOST_CLASS_PROLIFIC_PACKET_SIZE 128 159 160 /* Define PROLIFIC default values. */ 161 162 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_RATE 19200 163 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_DATA_BIT 8 164 165 /* Define PROLIFIC line coding definitions. */ 166 167 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_0 0 168 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_15 1 169 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_2 2 170 171 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_NONE 0 172 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_ODD 1 173 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_EVEN 2 174 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_MARK 3 175 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY_SPACE 4 176 177 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_LENGTH 7 178 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_RATE 0 179 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT 4 180 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_PARITY 5 181 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DATA_BIT 6 182 183 /* Define PROLIFIC line state definitions. */ 184 185 #define UX_HOST_CLASS_PROLIFIC_LINE_STATE_STOP_BIT_0 0 186 #define UX_HOST_CLASS_PROLIFIC_LINE_CODING_STOP_BIT_15 1 187 188 /* Define PROLIFIC IOCTL Functions. */ 189 190 #define UX_HOST_CLASS_PROLIFIC_IOCTL_SET_LINE_CODING 0 191 #define UX_HOST_CLASS_PROLIFIC_IOCTL_GET_LINE_CODING 1 192 #define UX_HOST_CLASS_PROLIFIC_IOCTL_SET_LINE_STATE 2 193 #define UX_HOST_CLASS_PROLIFIC_IOCTL_SEND_BREAK 3 194 #define UX_HOST_CLASS_PROLIFIC_IOCTL_PURGE 4 195 #define UX_HOST_CLASS_PROLIFIC_IOCTL_ABORT_IN_PIPE 5 196 #define UX_HOST_CLASS_PROLIFIC_IOCTL_ABORT_OUT_PIPE 6 197 #define UX_HOST_CLASS_PROLIFIC_IOCTL_REPORT_DEVICE_STATUS_CHANGE 7 198 #define UX_HOST_CLASS_PROLIFIC_IOCTL_GET_DEVICE_STATUS 8 199 200 /* Define PROLIFIC Reception States. */ 201 202 #define UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_STOPPED 0 203 #define UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_STARTED 1 204 #define UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_IN_TRANSFER 2 205 206 207 /* Define PROLIFIC Class instance structure. */ 208 209 typedef struct UX_HOST_CLASS_PROLIFIC_STRUCT 210 { 211 struct UX_HOST_CLASS_PROLIFIC_STRUCT 212 *ux_host_class_prolific_next_instance; 213 UX_HOST_CLASS *ux_host_class_prolific_class; 214 UX_DEVICE *ux_host_class_prolific_device; 215 UX_ENDPOINT *ux_host_class_prolific_bulk_in_endpoint; 216 UX_ENDPOINT *ux_host_class_prolific_bulk_out_endpoint; 217 UX_ENDPOINT *ux_host_class_prolific_interrupt_endpoint; 218 UX_INTERFACE *ux_host_class_prolific_interface; 219 UINT ux_host_class_prolific_instance_status; 220 UINT ux_host_class_prolific_state; 221 UX_SEMAPHORE ux_host_class_prolific_semaphore; 222 ULONG ux_host_class_prolific_notification_count; 223 ULONG ux_host_class_prolific_device_state; 224 VOID (*ux_host_class_prolific_device_status_change_callback)(struct UX_HOST_CLASS_PROLIFIC_STRUCT *prolific, 225 ULONG device_state); 226 227 ULONG ux_host_class_prolific_version; 228 UCHAR ux_host_class_prolific_device_type; 229 struct UX_HOST_CLASS_PROLIFIC_RECEPTION_STRUCT 230 *ux_host_class_prolific_reception; 231 232 } UX_HOST_CLASS_PROLIFIC; 233 234 235 /* Define PROLIFIC reception structure. */ 236 237 typedef struct UX_HOST_CLASS_PROLIFIC_RECEPTION_STRUCT 238 { 239 240 ULONG ux_host_class_prolific_reception_state; 241 ULONG ux_host_class_prolific_reception_block_size; 242 UCHAR *ux_host_class_prolific_reception_data_buffer; 243 ULONG ux_host_class_prolific_reception_data_buffer_size; 244 UCHAR *ux_host_class_prolific_reception_data_head; 245 UCHAR *ux_host_class_prolific_reception_data_tail; 246 VOID (*ux_host_class_prolific_reception_callback)(struct UX_HOST_CLASS_PROLIFIC_STRUCT *prolific, 247 UINT status, 248 UCHAR *reception_buffer, 249 ULONG reception_size); 250 251 } UX_HOST_CLASS_PROLIFIC_RECEPTION; 252 253 /* Define PROLIFIC Line Coding IOCTL structure. */ 254 255 typedef struct UX_HOST_CLASS_PROLIFIC_LINE_CODING_STRUCT 256 { 257 258 ULONG ux_host_class_prolific_line_coding_dter; 259 ULONG ux_host_class_prolific_line_coding_stop_bit; 260 ULONG ux_host_class_prolific_line_coding_parity; 261 ULONG ux_host_class_prolific_line_coding_data_bits; 262 263 } UX_HOST_CLASS_PROLIFIC_LINE_CODING; 264 265 /* Define PROLIFIC Line State IOCTL structure. */ 266 267 typedef struct UX_HOST_CLASS_PROLIFIC_LINE_STATE_STRUCT 268 { 269 270 ULONG ux_host_class_prolific_line_state_rts; 271 ULONG ux_host_class_prolific_line_state_dtr; 272 273 } UX_HOST_CLASS_PROLIFIC_LINE_STATE; 274 275 /* Define PROLIFIC Line break IOCTL structure. */ 276 277 typedef struct UX_HOST_CLASS_PROLIFIC_LINE_BREAK_STRUCT 278 { 279 280 ULONG ux_host_class_prolific_line_break; 281 282 } UX_HOST_CLASS_PROLIFIC_LINE_BREAK; 283 284 285 /* Define Prolific Class function prototypes. */ 286 287 UINT _ux_host_class_prolific_activate(UX_HOST_CLASS_COMMAND *command); 288 UINT _ux_host_class_prolific_configure(UX_HOST_CLASS_PROLIFIC *prolific); 289 UINT _ux_host_class_prolific_deactivate(UX_HOST_CLASS_COMMAND *command); 290 UINT _ux_host_class_prolific_endpoints_get(UX_HOST_CLASS_PROLIFIC *prolific); 291 UINT _ux_host_class_prolific_entry(UX_HOST_CLASS_COMMAND *command); 292 UINT _ux_host_class_prolific_read (UX_HOST_CLASS_PROLIFIC *prolific, UCHAR *data_pointer, 293 ULONG requested_length, ULONG *actual_length); 294 UINT _ux_host_class_prolific_write(UX_HOST_CLASS_PROLIFIC *prolific, UCHAR *data_pointer, 295 ULONG requested_length, ULONG *actual_length); 296 UINT _ux_host_class_prolific_ioctl(UX_HOST_CLASS_PROLIFIC *prolific, ULONG request, 297 VOID *parameter); 298 UINT _ux_host_class_prolific_command(UX_HOST_CLASS_PROLIFIC *prolific, ULONG command, 299 ULONG value, UCHAR *data_buffer, ULONG data_length); 300 VOID _ux_host_class_prolific_transfer_request_completed(UX_TRANSFER *transfer_request); 301 UINT _ux_host_class_prolific_reception_stop (UX_HOST_CLASS_PROLIFIC *prolific, 302 UX_HOST_CLASS_PROLIFIC_RECEPTION *prolific_reception); 303 UINT _ux_host_class_prolific_reception_start (UX_HOST_CLASS_PROLIFIC *prolific, 304 UX_HOST_CLASS_PROLIFIC_RECEPTION *prolific_reception); 305 306 VOID _ux_host_class_prolific_reception_callback (UX_TRANSFER *transfer_request); 307 UINT _ux_host_class_prolific_setup(UX_HOST_CLASS_PROLIFIC *prolific); 308 309 310 UINT _uxe_host_class_prolific_read (UX_HOST_CLASS_PROLIFIC *prolific, UCHAR *data_pointer, 311 ULONG requested_length, ULONG *actual_length); 312 UINT _uxe_host_class_prolific_write(UX_HOST_CLASS_PROLIFIC *prolific, UCHAR *data_pointer, 313 ULONG requested_length, ULONG *actual_length); 314 UINT _uxe_host_class_prolific_ioctl(UX_HOST_CLASS_PROLIFIC *prolific, ULONG request, 315 VOID *parameter); 316 UINT _uxe_host_class_prolific_command(UX_HOST_CLASS_PROLIFIC *prolific, ULONG command, 317 ULONG value, UCHAR *data_buffer, ULONG data_length); 318 UINT _uxe_host_class_prolific_reception_stop (UX_HOST_CLASS_PROLIFIC *prolific, 319 UX_HOST_CLASS_PROLIFIC_RECEPTION *prolific_reception); 320 UINT _uxe_host_class_prolific_reception_start (UX_HOST_CLASS_PROLIFIC *prolific, 321 UX_HOST_CLASS_PROLIFIC_RECEPTION *prolific_reception); 322 323 324 /* Define Prolific Class API prototypes. */ 325 326 #define ux_host_class_prolific_entry _ux_host_class_prolific_entry 327 #define ux_host_class_prolific_setup _ux_host_class_prolific_setup 328 329 #if defined(UX_HOST_CLASS_PROLIFIC_ENABLE_ERROR_CHECKING) 330 331 #define ux_host_class_prolific_read _uxe_host_class_prolific_read 332 #define ux_host_class_prolific_write _uxe_host_class_prolific_write 333 #define ux_host_class_prolific_ioctl _uxe_host_class_prolific_ioctl 334 #define ux_host_class_prolific_command _uxe_host_class_prolific_command 335 #define ux_host_class_prolific_reception_stop _uxe_host_class_prolific_reception_stop 336 #define ux_host_class_prolific_reception_start _uxe_host_class_prolific_reception_start 337 338 #else 339 340 #define ux_host_class_prolific_read _ux_host_class_prolific_read 341 #define ux_host_class_prolific_write _ux_host_class_prolific_write 342 #define ux_host_class_prolific_ioctl _ux_host_class_prolific_ioctl 343 #define ux_host_class_prolific_command _ux_host_class_prolific_command 344 #define ux_host_class_prolific_reception_stop _ux_host_class_prolific_reception_stop 345 #define ux_host_class_prolific_reception_start _ux_host_class_prolific_reception_start 346 347 #endif 348 349 /* Determine if a C++ compiler is being used. If so, complete the standard 350 C conditional started above. */ 351 #ifdef __cplusplus 352 } 353 #endif 354 355 #endif 356