1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Printer Class */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_host_class_printer.h PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file contains all the header and extern functions used by the */
/* USBX printer class. */
/* */
/**************************************************************************/
#ifndef UX_HOST_CLASS_PRINTER_H
#define UX_HOST_CLASS_PRINTER_H
/* Determine if a C++ compiler is being used. If so, ensure that standard
C is used to process the API information. */
#ifdef __cplusplus
/* Yes, C++ compiler is present. Use standard C. */
extern "C" {
#endif
/* Internal option: enable the basic USBX error checking. This define is typically used
while debugging application. */
#if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_HOST_CLASS_PRINTER_ENABLE_ERROR_CHECKING)
#define UX_HOST_CLASS_PRINTER_ENABLE_ERROR_CHECKING
#endif
/* Define Printer Class constants. */
#define UX_HOST_CLASS_PRINTER_CLASS_TRANSFER_TIMEOUT 300000
#define UX_HOST_CLASS_PRINTER_CLASS 7
#define UX_HOST_CLASS_PRINTER_SUBCLASS 1
#define UX_HOST_CLASS_PRINTER_PROTOCOL_BI_DIRECTIONAL 2
#define UX_HOST_CLASS_PRINTER_PROTOCOL_IEEE_1284_4_BI_DIR 3
#define UX_HOST_CLASS_PRINTER_GET_STATUS 1
#define UX_HOST_CLASS_PRINTER_SOFT_RESET 2
#define UX_HOST_CLASS_PRINTER_STATUS_LENGTH 4
#define UX_HOST_CLASS_PRINTER_DESCRIPTOR_LENGTH 1024
#define UX_HOST_CLASS_PRINTER_GET_DEVICE_ID 0
#define UX_HOST_CLASS_PRINTER_NAME_LENGTH 64
/* Define Printer Class 1284 descriptor tag constants. */
#define UX_HOST_CLASS_PRINTER_TAG_DESCRIPTION "DESCRIPTION:"
#define UX_HOST_CLASS_PRINTER_TAG_DES "DES:"
/* Define Printer Class string constants. */
#define UX_HOST_CLASS_PRINTER_GENERIC_NAME "USB PRINTER"
/* Define Printer flag constants. */
#define UX_HOST_CLASS_PRINTER_FLAG_LOCK 0x1u
/* Define Printer Class structure. */
typedef struct UX_HOST_CLASS_PRINTER_STRUCT
{
struct UX_HOST_CLASS_PRINTER_STRUCT
*ux_host_class_printer_next_instance;
UX_HOST_CLASS *ux_host_class_printer_class;
UX_DEVICE *ux_host_class_printer_device;
UX_INTERFACE *ux_host_class_printer_interface;
UX_ENDPOINT *ux_host_class_printer_bulk_out_endpoint;
UX_ENDPOINT *ux_host_class_printer_bulk_in_endpoint;
UINT ux_host_class_printer_state;
UCHAR ux_host_class_printer_name[UX_HOST_CLASS_PRINTER_NAME_LENGTH];
#if !defined(UX_HOST_STANDALONE)
UX_SEMAPHORE ux_host_class_printer_semaphore;
#else
UCHAR *ux_host_class_printer_allocated;
ULONG ux_host_class_printer_flags;
UINT ux_host_class_printer_status;
UCHAR ux_host_class_printer_enum_state;
UCHAR ux_host_class_printer_read_state;
UCHAR ux_host_class_printer_write_state;
UCHAR ux_host_class_printer_next_state;
#endif
} UX_HOST_CLASS_PRINTER;
#if !defined(UX_HOST_STANDALONE)
#define _ux_host_class_printer_unlock(printer) _ux_host_semaphore_put(&(printer) -> ux_host_class_printer_semaphore)
#else
#define _ux_host_class_printer_unlock(printer) do { (printer)->ux_host_class_printer_flags &= ~UX_HOST_CLASS_PRINTER_FLAG_LOCK; } while(0)
#endif
/* Define Printer Class function prototypes. */
UINT _ux_host_class_printer_activate(UX_HOST_CLASS_COMMAND *command);
UINT _ux_host_class_printer_configure(UX_HOST_CLASS_PRINTER *printer);
UINT _ux_host_class_printer_deactivate(UX_HOST_CLASS_COMMAND *command);
UINT _ux_host_class_printer_endpoints_get(UX_HOST_CLASS_PRINTER *printer);
UINT _ux_host_class_printer_entry(UX_HOST_CLASS_COMMAND *command);
UINT _ux_host_class_printer_name_get(UX_HOST_CLASS_PRINTER *printer);
UINT _ux_host_class_printer_device_id_get(UX_HOST_CLASS_PRINTER *printer, UCHAR *descriptor_buffer, ULONG length);
UINT _ux_host_class_printer_read (UX_HOST_CLASS_PRINTER *printer, UCHAR *data_pointer,
ULONG requested_length, ULONG *actual_length);
UINT _ux_host_class_printer_soft_reset(UX_HOST_CLASS_PRINTER *printer);
UINT _ux_host_class_printer_status_get(UX_HOST_CLASS_PRINTER *printer, ULONG *printer_status);
UINT _ux_host_class_printer_write(UX_HOST_CLASS_PRINTER *printer, UCHAR * data_pointer,
ULONG requested_length, ULONG *actual_length);
// UINT _uxe_host_class_printer_activate(UX_HOST_CLASS_COMMAND *command);
UINT _uxe_host_class_printer_name_get(UX_HOST_CLASS_PRINTER *printer);
UINT _uxe_host_class_printer_device_id_get(UX_HOST_CLASS_PRINTER *printer, UCHAR *descriptor_buffer, ULONG length);
UINT _uxe_host_class_printer_read (UX_HOST_CLASS_PRINTER *printer, UCHAR *data_pointer,
ULONG requested_length, ULONG *actual_length);
UINT _uxe_host_class_printer_soft_reset(UX_HOST_CLASS_PRINTER *printer);
UINT _uxe_host_class_printer_status_get(UX_HOST_CLASS_PRINTER *printer, ULONG *printer_status);
UINT _uxe_host_class_printer_write(UX_HOST_CLASS_PRINTER *printer, UCHAR * data_pointer,
ULONG requested_length, ULONG *actual_length);
/* Define Printer Class API prototypes. */
#if defined(UX_HOST_CLASS_PRINTER_ENABLE_ERROR_CHECKING)
#define ux_host_class_printer_entry _ux_host_class_printer_entry
#define ux_host_class_printer_activate _ux_host_class_printer_activate
#define ux_host_class_printer_name_get _uxe_host_class_printer_name_get
#define ux_host_class_printer_device_id_get _uxe_host_class_printer_device_id_get
#define ux_host_class_printer_read _uxe_host_class_printer_read
#define ux_host_class_printer_soft_reset _uxe_host_class_printer_soft_reset
#define ux_host_class_printer_status_get _uxe_host_class_printer_status_get
#define ux_host_class_printer_write _uxe_host_class_printer_write
#else
#define ux_host_class_printer_entry _ux_host_class_printer_entry
#define ux_host_class_printer_activate _ux_host_class_printer_activate
#define ux_host_class_printer_name_get _ux_host_class_printer_name_get
#define ux_host_class_printer_device_id_get _ux_host_class_printer_device_id_get
#define ux_host_class_printer_read _ux_host_class_printer_read
#define ux_host_class_printer_soft_reset _ux_host_class_printer_soft_reset
#define ux_host_class_printer_status_get _ux_host_class_printer_status_get
#define ux_host_class_printer_write _ux_host_class_printer_write
#endif /* UX_HOST_CLASS_PRINTER_ENABLE_ERROR_CHECKING */
/* Determine if a C++ compiler is being used. If so, complete the standard
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif
|