| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /******************************************************************************* |
| 2 | |||
| 3 | USB Host Printer Client Driver |
||
| 4 | |||
| 5 | Summary: |
||
| 6 | This is the Printer client driver file for a USB Embedded Host device. |
||
| 7 | |||
| 8 | Description: |
||
| 9 | This is the Printer client driver file for a USB Embedded Host device. |
||
| 10 | It allows an embedded application to utilize a USB printer to provide |
||
| 11 | printed output. |
||
| 12 | |||
| 13 | USB printers utilize the USB Printer Class to communicate with a USB |
||
| 14 | Host. This class defines the USB transfer type, the endpoint structure, |
||
| 15 | a device requests that can be performed. The actual commands sent to |
||
| 16 | the printer, however, are dictated by the printer language used by the |
||
| 17 | particular printer. |
||
| 18 | |||
| 19 | Many different printer languages are utilized by the wide variety of |
||
| 20 | printers on the market. Typically, low end printers receive printer-specific |
||
| 21 | binary data, utilizing the processing power of the USB Host to perform |
||
| 22 | all of the complex calculations required to translate text and graphics to |
||
| 23 | a simple binary representation. This works well when a PC is the USB Host, |
||
| 24 | but it is not conducive to an embedded application with limited resources. |
||
| 25 | |||
| 26 | Many printers on the market use a command based printer language, relying |
||
| 27 | on the printer itself to interpret commands to produce the desired output. |
||
| 28 | Some languages are standardized across printers from a particular |
||
| 29 | manufacturer, and some are used across multiple manufacturer. This method |
||
| 30 | lends itself better to embedded applications by allowing the printer to |
||
| 31 | take on some of the computational overhead. Microchip provides support for |
||
| 32 | some printer languages, including PostScript and PCL 5 for full sheet |
||
| 33 | printers and ESC/POS for receipt and label printers. Additional printer |
||
| 34 | language can be implemented. Refer to the USB Embedded Host Printer Class |
||
| 35 | application notes for more details on implementing printer language support. |
||
| 36 | |||
| 37 | |||
| 38 | Remarks: |
||
| 39 | This driver should be used in a project with usb_host.c to provided the USB |
||
| 40 | Embedded Host and hardware interfaces, plus one or more language support |
||
| 41 | files. |
||
| 42 | |||
| 43 | To interface with USB Embedded Host layer, the routine USBHostPrinterInitialize() |
||
| 44 | should be specified as the Initialize() function, and |
||
| 45 | USBHostPrinterEventHandler() should be specified as the EventHandler() |
||
| 46 | function in the usbClientDrvTable[] array declared in usb_config.c. |
||
| 47 | |||
| 48 | This driver requires transfer events from usb_host.c, so |
||
| 49 | USB_ENABLE_TRANSFER_EVENT must be defined. |
||
| 50 | |||
| 51 | Since the printer class is performed with bulk transfers, |
||
| 52 | USB_SUPPORT_BULK_TRANSFERS must be defined. |
||
| 53 | |||
| 54 | *******************************************************************************/ |
||
| 55 | //DOM-IGNORE-BEGIN |
||
| 56 | /****************************************************************************** |
||
| 57 | |||
| 58 | * FileName: usb_host_printer.h |
||
| 59 | * Dependencies: None |
||
| 60 | * Processor: PIC24/dsPIC30/dsPIC33/PIC32 |
||
| 61 | * Compiler: C30 v3.10b/C32 v1.02 |
||
| 62 | * Company: Microchip Technology, Inc. |
||
| 63 | |||
| 64 | Software License Agreement |
||
| 65 | |||
| 66 | The software supplied herewith by Microchip Technology Incorporated |
||
| 67 | (the Company) for its PICmicro® Microcontroller is intended and |
||
| 68 | supplied to you, the Companys customer, for use solely and |
||
| 69 | exclusively on Microchip PICmicro Microcontroller products. The |
||
| 70 | software is owned by the Company and/or its supplier, and is |
||
| 71 | protected under applicable copyright laws. All rights are reserved. |
||
| 72 | Any use in violation of the foregoing restrictions may subject the |
||
| 73 | user to criminal sanctions under applicable laws, as well as to |
||
| 74 | civil liability for the breach of the terms and conditions of this |
||
| 75 | license. |
||
| 76 | |||
| 77 | THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
||
| 78 | WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
||
| 79 | TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
||
| 80 | PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
||
| 81 | IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
||
| 82 | CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
||
| 83 | |||
| 84 | *******************************************************************************/ |
||
| 85 | |||
| 86 | //DOM-IGNORE-BEGIN |
||
| 87 | /******************************************************************** |
||
| 88 | File Description: |
||
| 89 | |||
| 90 | Change History: |
||
| 91 | Rev Description |
||
| 92 | ---------- ----------- |
||
| 93 | 2.6 - 2.6A No chance except stack revision number |
||
| 94 | |||
| 95 | 2.7 Minor updates to USBHostPrinterGetStatus() header |
||
| 96 | to better describe the function requirements and |
||
| 97 | operation. |
||
| 98 | |||
| 99 | 2.7a No change |
||
| 100 | ********************************************************************/ |
||
| 101 | //DOM-IGNORE-END |
||
| 102 | |||
| 103 | #ifndef __USBHOSTPRINTER_H__ |
||
| 104 | #define __USBHOSTPRINTER_H__ |
||
| 105 | //DOM-IGNORE-END |
||
| 106 | |||
| 107 | |||
| 108 | // ***************************************************************************** |
||
| 109 | // ***************************************************************************** |
||
| 110 | // Section: Configuration |
||
| 111 | // ***************************************************************************** |
||
| 112 | // ***************************************************************************** |
||
| 113 | |||
| 114 | // ***************************************************************************** |
||
| 115 | /* Max Number of Supported Devices |
||
| 116 | |||
| 117 | This value represents the maximum number of attached devices this class driver |
||
| 118 | can support. If the user does not define a value, it will be set to 1. |
||
| 119 | Currently this must be set to 1, due to limitations in the USB Host layer. |
||
| 120 | */ |
||
| 121 | #ifndef USB_MAX_PRINTER_DEVICES |
||
| 122 | #define USB_MAX_PRINTER_DEVICES 1 |
||
| 123 | #endif |
||
| 124 | |||
| 125 | #if USB_MAX_PRINTER_DEVICES != 1 |
||
| 126 | #error The Printer client driver supports only one attached device. |
||
| 127 | #endif |
||
| 128 | |||
| 129 | |||
| 130 | //#define DEBUG_MODE |
||
| 131 | |||
| 132 | // ***************************************************************************** |
||
| 133 | // ***************************************************************************** |
||
| 134 | // Section: Constants |
||
| 135 | // ***************************************************************************** |
||
| 136 | // ***************************************************************************** |
||
| 137 | |||
| 138 | // For use with POS printers that support Code128 bar codes (extended |
||
| 139 | // barcodes). This is the value of the first data byte of the bar code |
||
| 140 | // data, which begins the character code specification. The next byte |
||
| 141 | // must be 'A', 'B', or 'C'. |
||
| 142 | #define BARCODE_CODE128_CODESET_CHAR '{' |
||
| 143 | // For use with POS printers that support Code128 bar codes (extended |
||
| 144 | // barcodes). This is the value of the first data byte of the bar code |
||
| 145 | // data, which begins the character code specification. The next byte |
||
| 146 | // must be 'A', 'B', or 'C'. |
||
| 147 | #define BARCODE_CODE128_CODESET_STRING "{" |
||
| 148 | // For use with POS printers that support Code128 bar codes (extended |
||
| 149 | // barcodes). This is the value of the second data byte of the bar code |
||
| 150 | // data to specify character code set CODE A. This code set should be |
||
| 151 | // used if control characters (0x00-0x1F) are included in the data. |
||
| 152 | #define BARCODE_CODE128_CODESET_A_CHAR 'A' |
||
| 153 | // For use with POS printers that support Code128 bar codes (extended |
||
| 154 | // barcodes). This is the value of the second data byte of the bar code |
||
| 155 | // data to specify character code set CODE A. This code set should be |
||
| 156 | // used if control characters (0x00-0x1F) are included in the data. |
||
| 157 | #define BARCODE_CODE128_CODESET_A_STRING "A" |
||
| 158 | // For use with POS printers that support Code128 bar codes (extended |
||
| 159 | // barcodes). This is the value of the second data byte of the bar code |
||
| 160 | // data to specify character code set CODE B. This code set should be |
||
| 161 | // used if lower case letters and higher ASCII characters (0x60-0x7F) |
||
| 162 | // are included in the data. |
||
| 163 | #define BARCODE_CODE128_CODESET_B_CHAR 'B' |
||
| 164 | // For use with POS printers that support Code128 bar codes (extended |
||
| 165 | // barcodes). This is the value of the second data byte of the bar code |
||
| 166 | // data to specify character code set CODE B. This code set should be |
||
| 167 | // used if lower case letters and higher ASCII characters (0x60-0x7F) |
||
| 168 | // are included in the data. |
||
| 169 | #define BARCODE_CODE128_CODESET_B_STRING "B" |
||
| 170 | // For use with POS printers that support Code128 bar codes (extended |
||
| 171 | // barcodes). This is the value of the second data byte of the bar code |
||
| 172 | // data to specify character code set CODE C. This code set can be |
||
| 173 | // used only if the data values are between 0 and 99 (0x00-0x63). |
||
| 174 | #define BARCODE_CODE128_CODESET_C_CHAR 'C' |
||
| 175 | // For use with POS printers that support Code128 bar codes (extended |
||
| 176 | // barcodes). This is the value of the second data byte of the bar code |
||
| 177 | // data to specify character code set CODE C. This code set can be |
||
| 178 | // used only if the data values are between 0 and 99 (0x00-0x63). |
||
| 179 | #define BARCODE_CODE128_CODESET_C_STRING "C" |
||
| 180 | // For use with POS printers. May not be valid for all printers. Print |
||
| 181 | // the bar code text in 18x36 dot font. Do not alter this value. |
||
| 182 | #define BARCODE_TEXT_18x36 0 |
||
| 183 | // For use with POS printers. May not be valid for all printers. Print |
||
| 184 | // the bar code text in 12x24 dot font. Do not alter this value. |
||
| 185 | #define BARCODE_TEXT_12x24 1 |
||
| 186 | // For use with POS printers. Do not print readable bar code text. Do |
||
| 187 | // not alter this value. |
||
| 188 | #define BARCODE_TEXT_OMIT 0 |
||
| 189 | // For use with POS printers. Print readable text above the bar code. |
||
| 190 | // Do not alter this value. |
||
| 191 | #define BARCODE_TEXT_ABOVE 1 |
||
| 192 | // For use with POS printers. Print readable text below the bar code. |
||
| 193 | // Do not alter this value. |
||
| 194 | #define BARCODE_TEXT_BELOW 2 |
||
| 195 | // For use with POS printers. Print readable text above and below the bar |
||
| 196 | // code. Do not alter this value. |
||
| 197 | #define BARCODE_TEXT_ABOVE_AND_BELOW 3 |
||
| 198 | // Indicates a black line for drawing graphics objects. |
||
| 199 | #define PRINTER_COLOR_BLACK 0 |
||
| 200 | // Indicates a white line for drawing graphics objects. |
||
| 201 | #define PRINTER_COLOR_WHITE 1 |
||
| 202 | // bRequest value for the GET_DEVICE_ID USB class-specific request. |
||
| 203 | #define PRINTER_DEVICE_REQUEST_GET_DEVICE_ID 0x00 |
||
| 204 | // bRequest value for the GET_PORT_STATUS USB class-specific request. |
||
| 205 | #define PRINTER_DEVICE_REQUEST_GET_PORT_STATUS 0x01 |
||
| 206 | // bRequest value for the SOFT_RESET USB class-specific request. |
||
| 207 | #define PRINTER_DEVICE_REQUEST_SOFT_RESET 0x02 |
||
| 208 | // Indicates a solid color fill for filled graphics objects. |
||
| 209 | #define PRINTER_FILL_SOLID 0 |
||
| 210 | // Indicates a shaded fill for filled graphics objects. Requires a |
||
| 211 | // specified fill percentage. |
||
| 212 | #define PRINTER_FILL_SHADED 1 |
||
| 213 | // Indicates a hatched fill for graphics objects. Requires a |
||
| 214 | // specified line spacing and angle. |
||
| 215 | #define PRINTER_FILL_HATCHED 2 |
||
| 216 | // Indicates a cross-hatched fill for graphics objects. Requires a |
||
| 217 | // specified line spacing and angle. |
||
| 218 | #define PRINTER_FILL_CROSS_HATCHED 3 |
||
| 219 | // Indicates a dashed line for drawing graphics objects. |
||
| 220 | #define PRINTER_LINE_TYPE_DASHED 1 |
||
| 221 | // Indicates a dotted line for drawing graphics objects. |
||
| 222 | #define PRINTER_LINE_TYPE_DOTTED 2 |
||
| 223 | // Indicates a solid line for drawing graphics objects. |
||
| 224 | #define PRINTER_LINE_TYPE_SOLID 0 |
||
| 225 | // Indicates a normal width line for drawing graphics objects. |
||
| 226 | #define PRINTER_LINE_WIDTH_NORMAL 0 |
||
| 227 | // Indicates a thick line for drawing graphics objects. |
||
| 228 | #define PRINTER_LINE_WIDTH_THICK 1 |
||
| 229 | // Drawn lines will have a butt end. |
||
| 230 | #define PRINTER_LINE_END_BUTT 0 |
||
| 231 | // Drawn lines will have a round end. |
||
| 232 | #define PRINTER_LINE_END_ROUND 1 |
||
| 233 | // Drawn lines will have a square end. |
||
| 234 | #define PRINTER_LINE_END_SQUARE 2 |
||
| 235 | // Drawn lines will be joined with a bevel. |
||
| 236 | #define PRINTER_LINE_JOIN_BEVEL 0 |
||
| 237 | // Drawn lines will be joined with a miter. |
||
| 238 | #define PRINTER_LINE_JOIN_MITER 1 |
||
| 239 | // Drawn lines will be joined with a round. |
||
| 240 | #define PRINTER_LINE_JOIN_ROUND 2 |
||
| 241 | // The height of the page in points when in landscape mode. |
||
| 242 | #define PRINTER_PAGE_LANDSCAPE_HEIGHT 612 |
||
| 243 | // The width of the page in points when in landscape mode. |
||
| 244 | #define PRINTER_PAGE_LANDSCAPE_WIDTH 792 |
||
| 245 | // The height of the page in points when in portrait mode. |
||
| 246 | #define PRINTER_PAGE_PORTRAIT_HEIGHT 792 |
||
| 247 | // The width of the page in points when in portrait mode. |
||
| 248 | #define PRINTER_PAGE_PORTRAIT_WIDTH 612 |
||
| 249 | // Image print with double horizontal density. |
||
| 250 | #define PRINTER_POS_DENSITY_HORIZONTAL_DOUBLE 2 |
||
| 251 | // Image print with single horizontal density. |
||
| 252 | #define PRINTER_POS_DENSITY_HORIZONTAL_SINGLE 1 |
||
| 253 | // Image print with 8-dot vertical density. |
||
| 254 | #define PRINTER_POS_DENSITY_VERTICAL_8 8 |
||
| 255 | // Image print with 24-dot vertical density. |
||
| 256 | #define PRINTER_POS_DENSITY_VERTICAL_24 24 |
||
| 257 | // POS print direction left to right, starting at the top left corner. |
||
| 258 | #define PRINTER_POS_LEFT_TO_RIGHT 0 |
||
| 259 | // POS print direction bottom to top, starting at the bottom left corner. |
||
| 260 | #define PRINTER_POS_BOTTOM_TO_TOP 1 |
||
| 261 | // POS print direction right to left, startin at the bottom right corner. |
||
| 262 | #define PRINTER_POS_RIGHT_TO_LEFT 2 |
||
| 263 | // POS print direction top to bottom, starting at the top right corner. |
||
| 264 | #define PRINTER_POS_TOP_TO_BOTTOM 3 |
||
| 265 | |||
| 266 | |||
| 267 | // Constant to use to set the supportsPOS member of the |
||
| 268 | // USB_PRINTER_FUNCTION_SUPPORT union. |
||
| 269 | #define USB_PRINTER_FUNCTION_SUPPORT_POS 0x0002 |
||
| 270 | // Constant to use to set the supportsVectorGraphics member of the |
||
| 271 | // USB_PRINTER_FUNCTION_SUPPORT union. |
||
| 272 | #define USB_PRINTER_FUNCTION_SUPPORT_VECTOR_GRAPHICS 0x0001 |
||
| 273 | |||
| 274 | |||
| 275 | //#define PRINTER_IMAGE_COMPRESSION_NONE 0 |
||
| 276 | //#define PRINTER_IMAGE_BITS_PER_SAMPLE_1 1 |
||
| 277 | |||
| 278 | // ***************************************************************************** |
||
| 279 | // Section: USB Printer Client Events |
||
| 280 | // ***************************************************************************** |
||
| 281 | |||
| 282 | // This is an optional offset for the values of the generated events. |
||
| 283 | // If necessary, the application can use a non-zero offset for the |
||
| 284 | // generic events to resolve conflicts in event number. |
||
| 285 | #ifndef EVENT_PRINTER_OFFSET |
||
| 286 | #define EVENT_PRINTER_OFFSET 0 |
||
| 287 | #endif |
||
| 288 | |||
| 289 | // This event indicates that a Printer device has been attached. |
||
| 290 | // When USB_HOST_APP_EVENT_HANDLER is called with this event, the *data |
||
| 291 | // parameter points to a structure of the type |
||
| 292 | // USB_PRINTER_DEVICE_ID, which provides important information about |
||
| 293 | // the attached printer. The size parameter is the size of this |
||
| 294 | // structure. |
||
| 295 | #define EVENT_PRINTER_ATTACH (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+0) |
||
| 296 | |||
| 297 | // This event indicates that the specified device has been detached |
||
| 298 | // from the USB. When USB_HOST_APP_EVENT_HANDLER is called with this |
||
| 299 | // event, *data points to a BYTE that contains the device address, and |
||
| 300 | // size is the size of a BYTE. |
||
| 301 | #define EVENT_PRINTER_DETACH (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+1) |
||
| 302 | |||
| 303 | // This event indicates that a previous write request has completed. |
||
| 304 | // When USB_HOST_APP_EVENT_HANDLER is called with this event, *data |
||
| 305 | // points to the buffer that completed transmission, and size is the |
||
| 306 | // actual number of bytes that were written to the device. |
||
| 307 | #define EVENT_PRINTER_TX_DONE (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+2) |
||
| 308 | |||
| 309 | // This event indicates that a previous read request has completed. |
||
| 310 | // When USB_HOST_APP_EVENT_HANDLER is called with this event, *data |
||
| 311 | // points to the receive buffer, and size is the actual number of bytes |
||
| 312 | // read from the device. |
||
| 313 | #define EVENT_PRINTER_RX_DONE (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+3) |
||
| 314 | |||
| 315 | // This event indicates that the printer request has completed. |
||
| 316 | // These requests occur on endpoint 0 and include getting the printer |
||
| 317 | // status and performing a soft reset. |
||
| 318 | #define EVENT_PRINTER_REQUEST_DONE (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+4) |
||
| 319 | |||
| 320 | // This event indicates that a bus error occurred while trying to |
||
| 321 | // perform a write. The error code is returned in the size parameter. |
||
| 322 | // The data parameter is returned as NULL. |
||
| 323 | #define EVENT_PRINTER_TX_ERROR (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+5) |
||
| 324 | |||
| 325 | // This event indicates that a bus error occurred while trying to |
||
| 326 | // perform a read. The error code is returned in the size parameter. |
||
| 327 | // The data parameter is returned as NULL. |
||
| 328 | #define EVENT_PRINTER_RX_ERROR (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+6) |
||
| 329 | |||
| 330 | // This event indicates that a bus error occurred while trying to |
||
| 331 | // perform a device request. The error code is returned in the size |
||
| 332 | // parameter. The data parameter is returned as NULL. |
||
| 333 | #define EVENT_PRINTER_REQUEST_ERROR (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+7) |
||
| 334 | |||
| 335 | // This event indicates that a printer has attached for which we do not |
||
| 336 | // have printer language support. Therefore, we cannot talk to this |
||
| 337 | // printer. This event can also occur if there is not enough dynamic |
||
| 338 | // memory available to read the device ID string. |
||
| 339 | #define EVENT_PRINTER_UNSUPPORTED (EVENT_PRINTER_BASE+EVENT_PRINTER_OFFSET+8) |
||
| 340 | |||
| 341 | |||
| 342 | // ***************************************************************************** |
||
| 343 | // Section: USB Printer Commands, Flags, and Errors |
||
| 344 | // ***************************************************************************** |
||
| 345 | |||
| 346 | //----------------------------------------------------------------------------- |
||
| 347 | /* USB Printer Client Driver Commands |
||
| 348 | |||
| 349 | The main interface to the USB Printer Client Driver is through the function |
||
| 350 | USBHostPrinterCommand(). These are the commands that can be passed to that |
||
| 351 | function. |
||
| 352 | */ |
||
| 353 | |||
| 354 | typedef enum |
||
| 355 | { |
||
| 356 | // This command is used internally by the printer client driver. |
||
| 357 | // Applications do not issue this command. This command informs the |
||
| 358 | // language support code that a new device has attached. |
||
| 359 | // Some language support requires the maintenance of certain information about |
||
| 360 | // the printering status. This command, with the USB_PRINTER_DETACHED command, |
||
| 361 | // allows the language support information to be maintained properly as printers |
||
| 362 | // are attached and detached. The data and size parameters are not used by |
||
| 363 | // this command, and can be passed as USB_NULL and 0 respectively. |
||
| 364 | USB_PRINTER_ATTACHED, |
||
| 365 | |||
| 366 | // This command is used internally by the printer client driver. |
||
| 367 | // Applications do not issue this command. This command informs the |
||
| 368 | // language support code that a device has detached. |
||
| 369 | // Some language support requires the maintenance of certain information about |
||
| 370 | // the printering status. This command, with the USB_PRINTER_ATTACHED command, |
||
| 371 | // allows the language support information to be maintained properly as printers |
||
| 372 | // are attached and detached. The data and size parameters are not used by |
||
| 373 | // this command, and can be passed as USB_NULL and 0 respectively. |
||
| 374 | USB_PRINTER_DETACHED, |
||
| 375 | |||
| 376 | // This command instructs the printer driver to send the buffer directly to |
||
| 377 | // the printer, without interpretation by the printer driver. This is |
||
| 378 | // normally used only when debugging new commands. The data parameter should |
||
| 379 | // point to the data to be sent, and size should indicate the number of bytes |
||
| 380 | // to send. This command supports sending data from either RAM or |
||
| 381 | // ROM. If the data is in ROM, be sure to set the |
||
| 382 | // USB_PRINTER_TRANSFER_FROM_ROM flag. If the data is in RAM but the |
||
| 383 | // application may overwrite it, set the USB_PRINTER_TRANSFER_COPY_DATA |
||
| 384 | // flag to tell the printer client driver to make a local copy of the data, |
||
| 385 | // allowing the application to overwrite the original buffer when |
||
| 386 | // USBHostPrinterCommand() terminates. |
||
| 387 | USB_PRINTER_TRANSPARENT, |
||
| 388 | |||
| 389 | // This command should be issued at the beginning of every print job. It |
||
| 390 | // ensures that the printer is set back to a default state. The data and |
||
| 391 | // size parameters are not used by this command, and can be passed as USB_NULL |
||
| 392 | // and 0 respectively. |
||
| 393 | USB_PRINTER_JOB_START, |
||
| 394 | |||
| 395 | // This command should be issued at the end of every print job. It ejects the |
||
| 396 | // currently printing page, and ensures that the printer is set back to a |
||
| 397 | // default state. The data and size parameters are not used by this command, |
||
| 398 | // and can be passed as USB_NULL and 0 respectively. |
||
| 399 | USB_PRINTER_JOB_STOP, |
||
| 400 | |||
| 401 | // This command sets the current page orientation to portrait. This command |
||
| 402 | // must be issued immediately after the USB_PRINTER_JOB_START and |
||
| 403 | // USB_PRINTER_EJECT_PAGE commands in order for the command to take effect |
||
| 404 | // properly. Only one orientation command should be sent per page, or the |
||
| 405 | // output may not be properly generated. The default orientation is |
||
| 406 | // portrait. The data and size parameters are not used by this command, |
||
| 407 | // and can be passed as USB_NULL and 0 respectively. |
||
| 408 | USB_PRINTER_ORIENTATION_PORTRAIT, |
||
| 409 | |||
| 410 | // This command sets the current page orientation to landscape. This command |
||
| 411 | // must be issued immediately after the USB_PRINTER_JOB_START and |
||
| 412 | // USB_PRINTER_EJECT_PAGE commands in order for the command to take effect |
||
| 413 | // properly. Only one orientation command should be sent per page, or the |
||
| 414 | // output may not be properly generated. The default orientation is |
||
| 415 | // portrait. The data and size parameters are not used by this command, |
||
| 416 | // and can be passed as USB_NULL and 0 respectively. |
||
| 417 | USB_PRINTER_ORIENTATION_LANDSCAPE, |
||
| 418 | |||
| 419 | // This command selects the text font. To make usage easier, the size |
||
| 420 | // parameter is used to hold the font name indication. The data pointer |
||
| 421 | // should be passed in as USB_NULL. Refer to the enums USB_PRINTER_FONTS and |
||
| 422 | // USB_PRINTER_FONTS_POS for the valid values for the font name. With POS |
||
| 423 | // printers, the font name also indicates the font size. |
||
| 424 | USB_PRINTER_FONT_NAME, |
||
| 425 | |||
| 426 | // (Full sheet printers only.) This command selects the font size in |
||
| 427 | // terms of points. To make usage |
||
| 428 | // easier, the size parameter is used to hold the font size. The data |
||
| 429 | // pointer should be passed in as USB_NULL. For POS printers, the size is |
||
| 430 | // specified as a scale factor. The value of bits [3:0] plus one is the |
||
| 431 | // vertical scale, and the value of bits [7:4] plus one is the horizontal |
||
| 432 | // scale. Each direction can be scaled a maximum of x10. For example, the |
||
| 433 | // value 0x00 is x1 scaling in both directions, and 0x95 is x10 scaling |
||
| 434 | // horizontally and x6 scaling vertically. |
||
| 435 | USB_PRINTER_FONT_SIZE, |
||
| 436 | |||
| 437 | // This command sets the current font to italic. The data and size |
||
| 438 | // parameters are not used by this command, and can be passed as USB_NULL and |
||
| 439 | // 0 respectively. |
||
| 440 | USB_PRINTER_FONT_ITALIC, |
||
| 441 | |||
| 442 | // This command sets the current font to upright (not italic). The data |
||
| 443 | // and size parameters are not used by this command, and can be passed as |
||
| 444 | // USB_NULL and 0 respectively. |
||
| 445 | USB_PRINTER_FONT_UPRIGHT, |
||
| 446 | |||
| 447 | // This command sets the current font to bold. The data and size |
||
| 448 | // parameters are not used by this command, and can be passed as USB_NULL and |
||
| 449 | // 0 respectively. |
||
| 450 | USB_PRINTER_FONT_BOLD, |
||
| 451 | |||
| 452 | // This command sets the current font to regular weight (not bold). The |
||
| 453 | // data and size parameters are not used by this command, and can be |
||
| 454 | // passed as USB_NULL and 0 respectively. |
||
| 455 | USB_PRINTER_FONT_MEDIUM, |
||
| 456 | |||
| 457 | // This command ejects the currently printing page. The command |
||
| 458 | // USB_PRINTER_JOB_STOP will also eject the page. After this command, the |
||
| 459 | // selected paper orientation (portrait or landscape) and selected font |
||
| 460 | // must be reset. The data and size parameters are not used |
||
| 461 | // by this command, and can be passed as USB_NULL and 0 respectively. |
||
| 462 | USB_PRINTER_EJECT_PAGE, |
||
| 463 | |||
| 464 | // This command initiates a text print. To print text, first issue a |
||
| 465 | // USB_PRINTER_TEXT_START command. Then issue a USB_PRINTER_TEXT command |
||
| 466 | // with the text to be printed, setting the transferFlags parameter correctly |
||
| 467 | // for the location of the source text (RAM, ROM, or external memory. |
||
| 468 | // Finally, use the USB_PRINTER_TEXT_STOP |
||
| 469 | // command to terminate the text print. For best compatibility across |
||
| 470 | // printers, do not insert other commands into this sequence. The |
||
| 471 | // data and size parameters are not used by this command, and can be passed |
||
| 472 | // as USB_NULL and 0 respectively. |
||
| 473 | USB_PRINTER_TEXT_START, |
||
| 474 | |||
| 475 | // This command specifies text to print. The data parameter should point |
||
| 476 | // to the buffer of data to send, and size should indicate how many bytes |
||
| 477 | // of data to print. This command supports printing text from either RAM |
||
| 478 | // or ROM. Be sure to set the transferFlags parameter correctly |
||
| 479 | // for the location of the data source. If the data is in RAM but the |
||
| 480 | // application may overwrite it, set the USB_PRINTER_TRANSFER_COPY_DATA |
||
| 481 | // flag to tell the printer client driver to make a local copy of the data, |
||
| 482 | // allowing the application to overwrite the original buffer when |
||
| 483 | // USBHostPrinterCommand() terminates. Refer to the USB_PRINTER_TEXT_START |
||
| 484 | // command for the sequence required to print text. |
||
| 485 | USB_PRINTER_TEXT, |
||
| 486 | |||
| 487 | // This command terminates a text print. Refer to the |
||
| 488 | // USB_PRINTER_TEXT_START command for the sequence required to print text. |
||
| 489 | // The data and size parameters are not used by this command, and can be passed |
||
| 490 | // as USB_NULL and 0 respectively. For POS printers, size is the number of |
||
| 491 | // lines to feed after the print. To get the best result, a minimum of one |
||
| 492 | // line is recommended. The data parameter is not used, and can be |
||
| 493 | // passed as USB_NULL. |
||
| 494 | USB_PRINTER_TEXT_STOP, |
||
| 495 | |||
| 496 | // This command sets the current printing position on the page. Refer to |
||
| 497 | // the documentation for a description of the page coordinates. Both X and |
||
| 498 | // Y coordinates are passed in the size parameter. The X coordinate is |
||
| 499 | // passed in the most significant (upper) WORD, and the Y coordinate is |
||
| 500 | // passed in the least significant (lower) WORD. The macro |
||
| 501 | // USBHostPrinterPosition( X, Y ) can be used to create the paramater. POS |
||
| 502 | // printers support specifying the Y-axis position while in page mode only. |
||
| 503 | // The data pointer should be passed in as USB_NULL. |
||
| 504 | USB_PRINTER_SET_POSITION, |
||
| 505 | |||
| 506 | // This command is used to initialize the printing of a bitmapped image. |
||
| 507 | // This command requires a pointer to a variable of type |
||
| 508 | // USB_PRINTER_IMAGE_INFO. To print a bitmapped image, obtain the |
||
| 509 | // information required by the USB_PRINTER_IMAGE_INFO structure, and issue |
||
| 510 | // this command. Each row of bitmapped data can now be sent to the |
||
| 511 | // printer. For each row, first issue the USB_PRINTER_IMAGE_DATA_HEADER |
||
| 512 | // command. Then issue the USB_PRINTER_IMAGE_DATA command, with the |
||
| 513 | // transferFlags parameter set appropriately for the location of the |
||
| 514 | // bitmapped data. After all rows of data have been sent, terminate the |
||
| 515 | // image print with the USB_PRINTER_IMAGE_STOP command. Be sure that |
||
| 516 | // adequate heap space is available, particularly when printing from ROM |
||
| 517 | // or external memory, and when printing to a POS printer. When printing |
||
| 518 | // images on POS printers, ensure that the dot density capabilities of the |
||
| 519 | // printer are set correctly. If they are not, the printer will print |
||
| 520 | // garbage characters. Refer to the Printer Client Driver section of the |
||
| 521 | // Help file for more information about printing images. |
||
| 522 | USB_PRINTER_IMAGE_START, |
||
| 523 | |||
| 524 | // This command is issued before each row of bitmapped image data. The |
||
| 525 | // size parameter is the width of the image in terms of pixels. The |
||
| 526 | // *data parameter is not used and should be passed in as USB_NULL. Refer to |
||
| 527 | // the USB_PRINTER_IMAGE_START command for the sequence required to print |
||
| 528 | // an image. When printing |
||
| 529 | // images on POS printers, ensure that the dot density capabilities of the |
||
| 530 | // printer are set correctly. If they are not, the printer will print |
||
| 531 | // garbage characters. |
||
| 532 | USB_PRINTER_IMAGE_DATA_HEADER, |
||
| 533 | |||
| 534 | // This command is issued for each row of bitmapped image data. The |
||
| 535 | // *data parameter should point to the data, and size should be the |
||
| 536 | // number of bits of data to send to the printer, which should match the |
||
| 537 | // value passed in the USB_PRINTER_IMAGE_DATA_HEADER command. This command |
||
| 538 | // supports reading image data from either RAM or ROM. Be sure to |
||
| 539 | // set the transferFlags parameter appropriately to indicate the location of the |
||
| 540 | // bitmapped data. If the data is in RAM but the application may overwrite |
||
| 541 | // it, set the USB_PRINTER_TRANSFER_COPY_DATA flag to tell the printer |
||
| 542 | // client driver to make a local copy of the data, allowing the application |
||
| 543 | // to overwrite the original buffer when USBHostPrinterCommand() terminates. |
||
| 544 | // Refer to the USB_PRINTER_IMAGE_START command for the sequence |
||
| 545 | // required to print an image. Be sure that |
||
| 546 | // adequate heap space is available, particularly when printing from ROM |
||
| 547 | // or external memory, and when printing to a POS printer. When printing |
||
| 548 | // images on POS printers, ensure that the dot density capabilities of the |
||
| 549 | // printer are set correctly. If they are not, the printer will print |
||
| 550 | // garbage characters. Refer to the Printer Client Driver section of the |
||
| 551 | // Help file for more information about printing images. |
||
| 552 | USB_PRINTER_IMAGE_DATA, |
||
| 553 | |||
| 554 | // This command is used to terminate printing a bitmapped image. Refer to |
||
| 555 | // the USB_PRINTER_IMAGE_START command for the sequence required to print |
||
| 556 | // an image. |
||
| 557 | USB_PRINTER_IMAGE_STOP, |
||
| 558 | |||
| 559 | //-------------------------------------------------------------------------- |
||
| 560 | |||
| 561 | // Commands between USB_PRINTER_VECTOR_GRAPHICS_START and |
||
| 562 | // USB_PRINTER_VECTOR_GRAPHICS_END are valid only with printers that support |
||
| 563 | // vector graphics. This support is determined by the interface function |
||
| 564 | // of the type USB_PRINTER_LANGUAGE_SUPPORTED that is specified in the |
||
| 565 | // usb_config.c configuration file. |
||
| 566 | USB_PRINTER_VECTOR_GRAPHICS_START, |
||
| 567 | |||
| 568 | // (Vector graphics support required.) |
||
| 569 | // This command sets the line type for drawing graphics. The line type |
||
| 570 | // indication is passed in the size parameter. Valid values are |
||
| 571 | // PRINTER_LINE_TYPE_SOLID, PRINTER_LINE_TYPE_DOTTED, and |
||
| 572 | // PRINTER_LINE_TYPE_DASHED. The data pointer parameter is not used and |
||
| 573 | // should be set to USB_NULL. |
||
| 574 | USB_PRINTER_GRAPHICS_LINE_TYPE, |
||
| 575 | |||
| 576 | // (Vector graphics support required.) |
||
| 577 | // This command sets the width of the line for drawing vector graphics. |
||
| 578 | // The width indication is passed in the size parameter. For full sheet |
||
| 579 | // printers, valid values are PRINTER_LINE_WIDTH_NORMAL and |
||
| 580 | // PRINTER_LINE_WIDTH_THICK. For POS printers, the size is specified in |
||
| 581 | // dots (1-255). The data pointer parameter is not used and should be set |
||
| 582 | // to USB_NULL. |
||
| 583 | USB_PRINTER_GRAPHICS_LINE_WIDTH, |
||
| 584 | |||
| 585 | // (Vector graphics support required.) |
||
| 586 | // This command sets the style of the end of the lines used for drawing |
||
| 587 | // vector graphics. The style indication is passed in the size |
||
| 588 | // parameter. Valid values are PRINTER_LINE_END_BUTT, |
||
| 589 | // PRINTER_LINE_END_ROUND, and PRINTER_LINE_END_SQUARE. The data |
||
| 590 | // pointer parameter is not used and should be set to USB_NULL. |
||
| 591 | USB_PRINTER_GRAPHICS_LINE_END, |
||
| 592 | |||
| 593 | // (Vector graphics support required.) |
||
| 594 | // This commands sets the style of how lines are joined when drawing vector |
||
| 595 | // graphics. The style indication is passed in the size parameter. Valid |
||
| 596 | // values are PRINTER_LINE_JOIN_BEVEL, PRINTER_LINE_JOIN_MITER, and |
||
| 597 | // PRINTER_LINE_JOIN_ROUND. The data pointer parameter is not used and |
||
| 598 | // should be set to USB_NULL. |
||
| 599 | USB_PRINTER_GRAPHICS_LINE_JOIN, |
||
| 600 | |||
| 601 | // (Vector graphics support required.) |
||
| 602 | // This command sets the fill type for drawing filled vector graphics. |
||
| 603 | // The data pointer should point to a data structure that matches the |
||
| 604 | // sFillType structure in the USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 605 | // Valid values for the fillType member are: |
||
| 606 | // * PRINTER_FILL_SOLID. Other structure members are ignored. |
||
| 607 | // * PRINTER_FILL_SHADED. 0 <= shading <= 100 |
||
| 608 | // * PRINTER_FILL_HATCHED. The spacing is specified in points, angle is |
||
| 609 | // specified in degrees. |
||
| 610 | // * PRINTER_FILL_CROSS_HATCHED. The spacing is specified in points, angle is |
||
| 611 | // specified in degrees. |
||
| 612 | // Note: This command is not supported by all printer languages with vector |
||
| 613 | // graphics, and not all fill types are supported by all printers. Refer |
||
| 614 | // to the specific language for the supported fill types. |
||
| 615 | USB_PRINTER_GRAPHICS_FILL_TYPE, |
||
| 616 | |||
| 617 | // (Vector graphics support required.) |
||
| 618 | // This command sets the color of the line for drawing vector graphics. The |
||
| 619 | // color indication is passed in the size parameter. Valid values |
||
| 620 | // are PRINTER_COLOR_BLACK and PRINTER_COLOR_WHITE. The data pointer |
||
| 621 | // parameter is not used and should be set to USB_NULL. |
||
| 622 | USB_PRINTER_GRAPHICS_COLOR, |
||
| 623 | |||
| 624 | // (Vector graphics support required.) |
||
| 625 | // This command moves the graphics pen to the specified position. The |
||
| 626 | // position is specified in terms of points. The X-axis position value is |
||
| 627 | // passed in the most significant word of the size parameter, and the Y-axis |
||
| 628 | // position value is passed in the least significant word of the size |
||
| 629 | // parameter. POS printers support specifying the Y-axis position while in |
||
| 630 | // page mode only. The data pointer parameter is not used and should be set to USB_NULL. |
||
| 631 | USB_PRINTER_GRAPHICS_MOVE_TO, |
||
| 632 | |||
| 633 | // (Vector graphics support required.) |
||
| 634 | // This command moves the graphics pen to the specified relative position. |
||
| 635 | // The change in position is specified in terms of points. The X-axis |
||
| 636 | // position change is passed in the most significant word of the size |
||
| 637 | // parameter, and the Y-axis position change is passed in the least |
||
| 638 | // significant word of the size parameter. POS printers do not support |
||
| 639 | // specifying the Y-axis position. |
||
| 640 | USB_PRINTER_GRAPHICS_MOVE_RELATIVE, |
||
| 641 | |||
| 642 | // (Vector graphics support required.) |
||
| 643 | // This command draws a line from one specified x,y position to another |
||
| 644 | // specified x,y position. The data pointer should point to a data |
||
| 645 | // structure that matches the sLine structure in the |
||
| 646 | // USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 647 | USB_PRINTER_GRAPHICS_LINE, |
||
| 648 | |||
| 649 | // (Vector graphics support required.) |
||
| 650 | // This command draws a line from the current x,y position to the |
||
| 651 | // specified x,y position. The new x,y position is passed in the size |
||
| 652 | // parameter. The X-axis position value is passed in the most significant |
||
| 653 | // word of the size parameter, and the Y-axis position value is passed in |
||
| 654 | // the least significant word of the size parameter. The data pointer |
||
| 655 | // parameter is not used and should be set to USB_NULL. |
||
| 656 | USB_PRINTER_GRAPHICS_LINE_TO, |
||
| 657 | |||
| 658 | // (Vector graphics support required.) |
||
| 659 | // This command draws a line from the current x,y position to the |
||
| 660 | // x,y position defined by the indicated displacement. The x and y |
||
| 661 | // displacements are passed in the size parameter. The X-axis displacement |
||
| 662 | // is passed in the most significant word of the size parameter, and the |
||
| 663 | // Y-axis displacement is passed in the least significant word of the size |
||
| 664 | // parameter. The data pointer parameter is not used and should be set to USB_NULL. |
||
| 665 | USB_PRINTER_GRAPHICS_LINE_TO_RELATIVE, |
||
| 666 | |||
| 667 | // (Vector graphics support required.) |
||
| 668 | // This command draws an arc, or a piece of a circle. The data pointer |
||
| 669 | // should point to a data structure that matches the sArc structure in the |
||
| 670 | // USB_PRINTER_GRAPHICS_PARAMETERS union. This command can print only one |
||
| 671 | // arc of a circle, unlike the Graphics library, which can print multiple |
||
| 672 | // separated arcs of the same circle. |
||
| 673 | USB_PRINTER_GRAPHICS_ARC, |
||
| 674 | |||
| 675 | // (Vector graphics support required.) |
||
| 676 | // This command draws a circle using the current pen color and width. The |
||
| 677 | // inside of the circle is not filled. To draw a filled circle, use the |
||
| 678 | // command USB_PRINTER_GRAPHICS_CIRCLE_FILLED. The data pointer should |
||
| 679 | // point to a data structure that matches the sCircle structure in the |
||
| 680 | // USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 681 | USB_PRINTER_GRAPHICS_CIRCLE, |
||
| 682 | |||
| 683 | // (Vector graphics support required.) |
||
| 684 | // This command draws a filled circle using the current pen color. To draw |
||
| 685 | // the outline of a circle, use the command |
||
| 686 | // USB_PRINTER_GRAPHICS_CIRCLE_FILLED. The data pointer should point to a |
||
| 687 | // data structure that matches the sCircle structure in the |
||
| 688 | // USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 689 | USB_PRINTER_GRAPHICS_CIRCLE_FILLED, |
||
| 690 | |||
| 691 | // (Vector graphics support required.) |
||
| 692 | // This command draws an outlined bevel (rectangle with rounded corners) |
||
| 693 | // using the current pen color and width. The inside of the bevel is not |
||
| 694 | // filled. To draw a filled bevel, use the command |
||
| 695 | // USB_PRINTER_GRAPHICS_BEVEL_FILLED. The data pointer should point to a |
||
| 696 | // data structure that matches the sBevel structure in the |
||
| 697 | // USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 698 | USB_PRINTER_GRAPHICS_BEVEL, |
||
| 699 | |||
| 700 | // (Vector graphics support required.) |
||
| 701 | // This command draws a filled bevel using the current pen color. To draw |
||
| 702 | // the outline of a bevel, use the command |
||
| 703 | // USB_PRINTER_GRAPHICS_BEVEL_FILLED. The data pointer should point to a |
||
| 704 | // data structure that matches the sBevel structure in the |
||
| 705 | // USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 706 | USB_PRINTER_GRAPHICS_BEVEL_FILLED, |
||
| 707 | |||
| 708 | // (Vector graphics support required.) |
||
| 709 | // This command draws a rectangle using the current pen color and width. The |
||
| 710 | // inside of the rectangle is not filled. To draw a filled rectangle, use |
||
| 711 | // the command USB_PRINTER_GRAPHICS_RECTANGLE_FILLED. The data pointer should |
||
| 712 | // point to a data structure that matches the sRectangle structure in the |
||
| 713 | // USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 714 | USB_PRINTER_GRAPHICS_RECTANGLE, |
||
| 715 | |||
| 716 | // (Vector graphics support required.) |
||
| 717 | // This command draws a filled rectangle using the current pen color. To draw |
||
| 718 | // the outline of a rectangle, use the command |
||
| 719 | // USB_PRINTER_GRAPHICS_RECTANGLE. The data pointer should point to a |
||
| 720 | // data structure that matches the sRectangle structure in the |
||
| 721 | // USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 722 | USB_PRINTER_GRAPHICS_RECTANGLE_FILLED, |
||
| 723 | |||
| 724 | // (Vector graphics support required.) |
||
| 725 | // This command draws the outline of a polygon with a specified number of |
||
| 726 | // sides, using the current pen color and width. The data pointer should |
||
| 727 | // point to a data structure that matches the sPolygon structure in the |
||
| 728 | // USB_PRINTER_GRAPHICS_PARAMETERS union. This structure contains the |
||
| 729 | // number of verticies of the polygon and a pointer to an array containing |
||
| 730 | // x,y coordinates of the verticies. Line segments are drawn to each vertex |
||
| 731 | // in the order that they appear in the array. |
||
| 732 | USB_PRINTER_GRAPHICS_POLYGON, |
||
| 733 | |||
| 734 | // Commands between USB_PRINTER_VECTOR_GRAPHICS_START and |
||
| 735 | // USB_PRINTER_VECTOR_GRAPHICS_END are valid only with printers that support |
||
| 736 | // vector graphics. This support is determined by the interface function |
||
| 737 | // of the type USB_PRINTER_LANGUAGE_SUPPORTED that is specified in the |
||
| 738 | // usb_config.c configuration file. |
||
| 739 | USB_PRINTER_VECTOR_GRAPHICS_END, |
||
| 740 | |||
| 741 | //-------------------------------------------------------------------------- |
||
| 742 | |||
| 743 | #ifdef USB_PRINTER_LANGUAGE_ESCPOS |
||
| 744 | |||
| 745 | // Commands between USB_PRINTER_POS_START and USB_PRINTER_POS_END are valid |
||
| 746 | // only with point-of-sale printers. This support is determined by the |
||
| 747 | // interface function of the type USB_PRINTER_LANGUAGE_SUPPORTED that is |
||
| 748 | // specified in the usb_config.c configuration file. |
||
| 749 | USB_PRINTER_POS_START, |
||
| 750 | |||
| 751 | // (POS support required.) This command sets the printer into page mode. |
||
| 752 | // In this mode, print commands are retained by the printer until it |
||
| 753 | // receives the USB_PRINTER_EJECT_PAGE command. This allows the application |
||
| 754 | // to create more sophisticated output. The data pointer should point to a |
||
| 755 | // data struture that matches the sPage structure in the |
||
| 756 | // USB_PRINTER_GRAPHICS_PARAMETERS union. This structure contains the |
||
| 757 | // horizontal and vertical starting point, the horizontal and vertical print |
||
| 758 | // length, and the print direction and starting point. Valid values for the |
||
| 759 | // print direction and starting point are: |
||
| 760 | // * PRINTER_POS_LEFT_TO_RIGHT |
||
| 761 | // * PRINTER_POS_BOTTOM_TO_TOP |
||
| 762 | // * PRINTER_POS_RIGHT_TO_LEFT |
||
| 763 | // * PRINTER_POS_TOP_TO_BOTTOM |
||
| 764 | USB_PRINTER_POS_PAGE_MODE, |
||
| 765 | |||
| 766 | // (POS support required.) This command sets the printer into standard mode. |
||
| 767 | // In this mode, print commands are processed and printed immediately. This |
||
| 768 | // is typically the default mode for a POS printer. |
||
| 769 | USB_PRINTER_POS_STANDARD_MODE, |
||
| 770 | |||
| 771 | // (POS support required.) This command feeds the specified number of |
||
| 772 | // lines, as dictated by the size parameter (between 0 and 255). The data |
||
| 773 | // parameter is not used, and should be set to USB_NULL. |
||
| 774 | USB_PRINTER_POS_FEED, |
||
| 775 | |||
| 776 | // (POS support required.) This command is a simplified method of printing |
||
| 777 | // a text line to a POS printer. This command prints a single, null |
||
| 778 | // terminated string and feeds a specified number of lines after the print. |
||
| 779 | // The data pointer must point to a null terminated string located in RAM. |
||
| 780 | // Printing strings from ROM is not supported. The size parameter should |
||
| 781 | // be set to the number of lines to feed after the text is printed. |
||
| 782 | USB_PRINTER_POS_TEXT_LINE, |
||
| 783 | |||
| 784 | // (POS support required.) This command cuts the paper completely. The |
||
| 785 | // data parameter is not used, and should be passed as USB_NULL. The least |
||
| 786 | // significant byte of the size parameter indicates the number of vertical |
||
| 787 | // motion units (printer dependent, typical values are 1/360 inch to |
||
| 788 | // 1/144 inch) to feed before the cut. Not all POS printer models support |
||
| 789 | // this command. |
||
| 790 | #ifdef USB_PRINTER_POS_CUTTER_SUPPORT |
||
| 791 | USB_PRINTER_POS_CUT, |
||
| 792 | #endif |
||
| 793 | |||
| 794 | // (POS support required.) This command cuts the paper, leaving one point |
||
| 795 | // uncut. The data parameter is not used, and should be passed as USB_NULL. |
||
| 796 | // The least significant byte of the size parameter indicates the number of |
||
| 797 | // vertical motion units (printer dependent, typical values are 1/360 inch |
||
| 798 | // to 1/144 inch) to feed before the cut. Not all POS printer models support |
||
| 799 | // this command. |
||
| 800 | #ifdef USB_PRINTER_POS_CUTTER_SUPPORT |
||
| 801 | USB_PRINTER_POS_CUT_PARTIAL, |
||
| 802 | #endif |
||
| 803 | |||
| 804 | // (POS support required.) This command sets the printing justification to |
||
| 805 | // the center of the print area. The data and size parameters are not used, |
||
| 806 | // and should be set to USB_NULL and 0 respectively. |
||
| 807 | USB_PRINTER_POS_JUSTIFICATION_CENTER, |
||
| 808 | |||
| 809 | // (POS support required.) This command sets the printing justification to |
||
| 810 | // the left side of the print area. The data and size parameters are not used, |
||
| 811 | // and should be set to USB_NULL and 0 respectively. |
||
| 812 | USB_PRINTER_POS_JUSTIFICATION_LEFT, |
||
| 813 | |||
| 814 | // (POS support required.) This command sets the printing justification to |
||
| 815 | // the right side of the print area. The data and size parameters are not used, |
||
| 816 | // and should be set to USB_NULL and 0 respectively. |
||
| 817 | USB_PRINTER_POS_JUSTIFICATION_RIGHT, |
||
| 818 | |||
| 819 | // (POS support required.) This command enables or disables white/black |
||
| 820 | // reverse printing of characters. When enabled, characters are printed in |
||
| 821 | // white on a black background, and underlining is not performed. To enable |
||
| 822 | // reverse printing, set the size parameter to 1. To disable reverse printing, |
||
| 823 | // set the size parameter to 0. (Only the least significant bit of the size |
||
| 824 | // parameter is examined.) The data parameter is not used, and should be set |
||
| 825 | // to USB_NULL. Not all POS printer models support |
||
| 826 | // this command. |
||
| 827 | #ifdef USB_PRINTER_POS_REVERSE_TEXT_SUPPORT |
||
| 828 | USB_PRINTER_POS_FONT_REVERSE, |
||
| 829 | #endif |
||
| 830 | |||
| 831 | // (POS support required.) This command enables or disables underlining. |
||
| 832 | // Underlining is not performed if reverse printing is enabled. To enable |
||
| 833 | // underlining, set the size parameter to 1. To disable underlining, set |
||
| 834 | // the size parameter to 0. (Only the least significant bit of the size |
||
| 835 | // parameter is examined.) The data parameter is not used, and should be set |
||
| 836 | // to USB_NULL. |
||
| 837 | USB_PRINTER_POS_FONT_UNDERLINE, |
||
| 838 | |||
| 839 | // (POS support required.) This command changes the print color to black. |
||
| 840 | // This command is available only with printers that support two color |
||
| 841 | // printing. The data and size parameters are not used, |
||
| 842 | // and should be set to USB_NULL and 0 respectively. |
||
| 843 | #ifdef USB_PRINTER_POS_TWO_COLOR_SUPPORT |
||
| 844 | USB_PRINTER_POS_COLOR_BLACK, |
||
| 845 | #endif |
||
| 846 | |||
| 847 | // (POS support required.) This command changes the print color to red. |
||
| 848 | // This command is available only with printers that support two color |
||
| 849 | // printing. The data and size parameters are not used, |
||
| 850 | // and should be set to USB_NULL and 0 respectively. |
||
| 851 | #ifdef USB_PRINTER_POS_TWO_COLOR_SUPPORT |
||
| 852 | USB_PRINTER_POS_COLOR_RED, |
||
| 853 | #endif |
||
| 854 | |||
| 855 | // (POS support required.) This command prints a bar code. Not all POS |
||
| 856 | // printers provide bar code support, and the types of bar codes supported |
||
| 857 | // may vary; check the technical documentation for the desired target |
||
| 858 | // printer. The data pointer should point to a data structure that matches |
||
| 859 | // the sBarCode structure in the USB_PRINTER_GRAPHICS_PARAMETERS union. |
||
| 860 | // This structure contains the type of bar code (as specified by the |
||
| 861 | // USB_PRINTER_POS_BARCODE_FORMAT enumeration) and the bar code data. |
||
| 862 | #ifdef USB_PRINTER_POS_BARCODE_SUPPORT |
||
| 863 | USB_PRINTER_POS_BARCODE, |
||
| 864 | #endif |
||
| 865 | |||
| 866 | // Commands between USB_PRINTER_POS_START and USB_PRINTER_POS_END are valid |
||
| 867 | // only with point-of-sale printers. This support is determined by the |
||
| 868 | // interface function of the type USB_PRINTER_LANGUAGE_SUPPORTED that is |
||
| 869 | // specified in the usb_config.c configuration file. |
||
| 870 | USB_PRINTER_POS_END, |
||
| 871 | |||
| 872 | #endif |
||
| 873 | |||
| 874 | } USB_PRINTER_COMMAND; |
||
| 875 | |||
| 876 | |||
| 877 | //----------------------------------------------------------------------------- |
||
| 878 | // Section: Printer Transfer Flags |
||
| 879 | |||
| 880 | // This flag indicates that the printer client driver should make a |
||
| 881 | // copy of the data passed to the command. This allows the application |
||
| 882 | // to reuse the data storage immediately instead of waiting until the |
||
| 883 | // transfer is sent to the printer. The client driver will allocate |
||
| 884 | // space in the heap for the data copy. If there is not enough |
||
| 885 | // available memory, the command will terminate with a |
||
| 886 | // USB_PRINTER_OUT_OF_MEMORY error. Otherwise, the original data will |
||
| 887 | // be copied to the temporary data space. This temporary data will be |
||
| 888 | // freed upon completion, regardless of whether or not the command was |
||
| 889 | // performed successfully. NOTE: If the data is located in ROM, the |
||
| 890 | // flag USB_PRINTER_TRANSFER_FROM_ROM must be used instead. |
||
| 891 | #define USB_PRINTER_TRANSFER_COPY_DATA 0x01 |
||
| 892 | |||
| 893 | // This flag indicates that the data will not change in the time |
||
| 894 | // between the printer command being issued and the data actually being |
||
| 895 | // sent to the printer. |
||
| 896 | #define USB_PRINTER_TRANSFER_STATIC_DATA 0x00 |
||
| 897 | |||
| 898 | // This flag indicates that the application layer wants to receive an |
||
| 899 | // event notification when the command completes. |
||
| 900 | #define USB_PRINTER_TRANSFER_NOTIFY 0x02 |
||
| 901 | |||
| 902 | // This flag indicates that the source of the command data is in ROM. |
||
| 903 | // The data will be copied to RAM, since the USB Host layer cannot read |
||
| 904 | // data from ROM. If there is not enough available heap space to make |
||
| 905 | // a copy of the data, the command will fail. If using this flag, do |
||
| 906 | // not set the USB_PRINTER_TRANSFER_COPY_DATA flag. |
||
| 907 | #define USB_PRINTER_TRANSFER_FROM_ROM 0x04 |
||
| 908 | |||
| 909 | // This flag indicates that the source of the command data is in RAM. |
||
| 910 | // The application can then choose whether or not to have the printer |
||
| 911 | // client driver make a copy of the data. |
||
| 912 | #define USB_PRINTER_TRANSFER_FROM_RAM 0x00 |
||
| 913 | |||
| 914 | // This flag indicates that the source of the command data is in |
||
| 915 | // external memory. This flag is for use only with the |
||
| 916 | // USB_PRINTER_IMAGE_DATA and USB_PRINTER_TEXT commands. |
||
| 917 | //for future implementation #define USB_PRINTER_TRANSFER_FROM_EXTERNAL 0x08 |
||
| 918 | |||
| 919 | // Use this macro to set the USB_PRINTER_TRANSFER_COPY_DATA flag |
||
| 920 | // in a variable. |
||
| 921 | #define USBHOSTPRINTER_SETFLAG_COPY_DATA(x) {x |= USB_PRINTER_TRANSFER_COPY_DATA;} |
||
| 922 | |||
| 923 | // Use this macro to clear the USB_PRINTER_TRANSFER_COPY_DATA flag |
||
| 924 | // in a variable. |
||
| 925 | #define USBHOSTPRINTER_SETFLAG_STATIC_DATA(x) {x &= ~USB_PRINTER_TRANSFER_COPY_DATA;} |
||
| 926 | |||
| 927 | // Use this macro to set the USB_PRINTER_TRANSFER_NOTIFY flag in a |
||
| 928 | // variable. |
||
| 929 | #define USBHOSTPRINTER_SETFLAG_NOTIFY(x) {x |= USB_PRINTER_TRANSFER_NOTIFY;} |
||
| 930 | |||
| 931 | |||
| 932 | //----------------------------------------------------------------------------- |
||
| 933 | /* Printer Fonts |
||
| 934 | |||
| 935 | This enumeration defines the various printer fonts. If new fonts are added, |
||
| 936 | they must be added at the end of the list, just before the |
||
| 937 | USB_PRINTER_FONT_MAX_FONT definition, as the printer language support files |
||
| 938 | may utilize them for indexing purposes. |
||
| 939 | */ |
||
| 940 | typedef enum |
||
| 941 | { |
||
| 942 | USB_PRINTER_FONT_AVANT_GARDE = 0, // Avant Garde font |
||
| 943 | USB_PRINTER_FONT_BOOKMAN, // Bookman font |
||
| 944 | USB_PRINTER_FONT_COURIER, // Courier font |
||
| 945 | USB_PRINTER_FONT_HELVETICA, // Helvetica font |
||
| 946 | USB_PRINTER_FONT_HELVETICA_NARROW, // Helvetica Narrow font |
||
| 947 | USB_PRINTER_FONT_NEW_CENTURY_SCHOOLBOOK, // New Century Schoolbook font |
||
| 948 | USB_PRINTER_FONT_PALATINO, // Palatino font |
||
| 949 | USB_PRINTER_FONT_TIMES_NEW_ROMAN, // Times New Roman font |
||
| 950 | USB_PRINTER_FONT_MAX_FONT // Font out of range |
||
| 951 | } USB_PRINTER_FONTS; |
||
| 952 | |||
| 953 | |||
| 954 | //----------------------------------------------------------------------------- |
||
| 955 | /* POS Printer Fonts |
||
| 956 | |||
| 957 | This enumeration defines the various printer fonts used by POS printers. If |
||
| 958 | new fonts are added, they must be added at the end of the list, just before the |
||
| 959 | USB_PRINTER_FONT_POS_MAX_FONT definition, as the printer language support files |
||
| 960 | may utilize them for indexing purposes. |
||
| 961 | */ |
||
| 962 | typedef enum |
||
| 963 | { |
||
| 964 | USB_PRINTER_FONT_POS_18x36, // Character size 18x36 |
||
| 965 | USB_PRINTER_FONT_POS_18x72, // Character size 18x36, double height |
||
| 966 | USB_PRINTER_FONT_POS_36x36, // Character size 18x36, double width |
||
| 967 | USB_PRINTER_FONT_POS_36x72, // Character size 18x36, double height and width |
||
| 968 | USB_PRINTER_FONT_POS_12x24, // Character size 12x24 |
||
| 969 | USB_PRINTER_FONT_POS_12x48, // Character size 12x24, double height |
||
| 970 | USB_PRINTER_FONT_POS_24x24, // Character size 12x24, double width |
||
| 971 | USB_PRINTER_FONT_POS_24x48, // Character size 12x24, double height and width |
||
| 972 | USB_PRINTER_FONT_POS_MAX_FONT // Font out of range |
||
| 973 | } USB_PRINTER_FONTS_POS; |
||
| 974 | |||
| 975 | |||
| 976 | //----------------------------------------------------------------------------- |
||
| 977 | /* Printer Errors |
||
| 978 | |||
| 979 | These are errors that can be returned by the printer client driver. Note that |
||
| 980 | USB Embedded Host errors can also be returned. |
||
| 981 | */ |
||
| 982 | typedef enum |
||
| 983 | { |
||
| 984 | // The command was successful. |
||
| 985 | USB_PRINTER_SUCCESS = 0, |
||
| 986 | |||
| 987 | // The command cannot be performed because the printer client driver's |
||
| 988 | // command queue is full. Use the function USBHostPrinterCommandReady() |
||
| 989 | // to determine if there is space available in the queue. |
||
| 990 | USB_PRINTER_BUSY = USB_ERROR_CLASS_DEFINED, |
||
| 991 | |||
| 992 | // An invalid printer command was requested. Refer to the enumeration |
||
| 993 | // USB_PRINTER_COMMAND for the list of valid commands. |
||
| 994 | USB_PRINTER_UNKNOWN_COMMAND, |
||
| 995 | |||
| 996 | // A device with the indicated address is not attached or is not |
||
| 997 | // a printer. |
||
| 998 | USB_PRINTER_UNKNOWN_DEVICE, |
||
| 999 | |||
| 1000 | // Not enough free heap space is available to perform the command. |
||
| 1001 | USB_PRINTER_OUT_OF_MEMORY, |
||
| 1002 | |||
| 1003 | // The number of attached printers exceeds the maximum specified by |
||
| 1004 | // USB_MAX_PRINTER_DEVICES. Refer to the USB configuration tool. |
||
| 1005 | USB_PRINTER_TOO_MANY_DEVICES, |
||
| 1006 | |||
| 1007 | // An invalid or out of range parameter was passed. Run time checking |
||
| 1008 | // of graphics coordinates must be enabled by defining |
||
| 1009 | // PRINTER_GRAPHICS_COORDINATE_CHECKING. |
||
| 1010 | USB_PRINTER_BAD_PARAMETER |
||
| 1011 | |||
| 1012 | } USB_PRINTER_ERRORS; |
||
| 1013 | |||
| 1014 | |||
| 1015 | //----------------------------------------------------------------------------- |
||
| 1016 | /* Bar Code Formats |
||
| 1017 | |||
| 1018 | These are the bar code formats for printing bar codes on POS printers. They |
||
| 1019 | are used in conjuction with the USB_PRINTER_POS_BARCODE command |
||
| 1020 | (USB_PRINTER_COMMAND). Bar code information is passed using the sBarCode |
||
| 1021 | structure within the USB_PRINTER_GRAPHICS_PARAMETERS union. The exact values |
||
| 1022 | to send for each bar code type can vary for the particular POS printer, and not |
||
| 1023 | all printers support all bar code types. Be sure to test the output on the |
||
| 1024 | target printer, and adjust the values specified in usb_host_printer_esc_pos.c |
||
| 1025 | if necessary. Refer to the printer's technical documentation for the required |
||
| 1026 | values. Do not alter this enumeration. |
||
| 1027 | */ |
||
| 1028 | #ifdef USB_PRINTER_POS_BARCODE_SUPPORT |
||
| 1029 | typedef enum |
||
| 1030 | { |
||
| 1031 | // UPC-A bar code format. Typically used for making products with a |
||
| 1032 | // unique code,as well as for coupons, periodicals, and paperback books. |
||
| 1033 | // The data for this bar code must consist |
||
| 1034 | // of 11 values from '0' to '9' (ASCII), and the data length for this |
||
| 1035 | // bar code must be 11. The first digit is the number system character: |
||
| 1036 | // * 0, 6, 7 Regular UPC codes |
||
| 1037 | // * 2 Random weight items |
||
| 1038 | // * 3 National Drug Code and National Health Related Items Code |
||
| 1039 | // * 4 In-store marking of non-food items |
||
| 1040 | // * 5 Coupons |
||
| 1041 | // * 1, 8, 9 Reserved |
||
| 1042 | // A check digit will be automatically calculated and appended. |
||
| 1043 | // For more information, refer to the UPC Symbol Specification Manual |
||
| 1044 | // from the Uniform Code Council. |
||
| 1045 | USB_PRINTER_POS_BARCODE_UPC_A = 0, |
||
| 1046 | // UPC-E bar code format. Similar to UPC-A but with restrictions. Data |
||
| 1047 | // lengths of 6, 7, or 11 bytes are supported. Not all printers support |
||
| 1048 | // the 6 or 7 byte widths; 11 byte data is recommended. If the data length is |
||
| 1049 | // not 6, then the first the first digit (the number system character) |
||
| 1050 | // must be set to '0'. If 11 data bytes are presented, the printer will |
||
| 1051 | // generate a shortened 6-digit code. |
||
| 1052 | // The check digit will be automatically calculated and appended. |
||
| 1053 | USB_PRINTER_POS_BARCODE_UPC_E, |
||
| 1054 | // EAN/JAN-13 bar code format. Similar to UPC-A, but there are 12 |
||
| 1055 | // numeric digits plus a checksum digit. |
||
| 1056 | // The check digit will be automatically calculated and appended. |
||
| 1057 | USB_PRINTER_POS_BARCODE_EAN13, |
||
| 1058 | // EAN/JAN-8 bar code format. Similar to UPC-E, but there are 7 |
||
| 1059 | // numeric digits, and the first digit (the number system character) |
||
| 1060 | // must be set to '0'. |
||
| 1061 | // The check digit will be automatically calculated and appended. |
||
| 1062 | USB_PRINTER_POS_BARCODE_EAN8, |
||
| 1063 | // CODE39 bar code format. Typically used in applications where the |
||
| 1064 | // data length may change. This format uses encoded numeric characters, |
||
| 1065 | // uppercase alphabet characters, and the symbols '-' (dash), '.' (period), |
||
| 1066 | // ' ' (space), '$' (dollar sign), '/' (forward slash), '+' (plus), and |
||
| 1067 | // '%' (percent). |
||
| 1068 | // If the bPrintCheckDigit flag is set, then the check digit will be |
||
| 1069 | // automatically calculated and appended. Otherwise, no check digit |
||
| 1070 | // will be printed. |
||
| 1071 | USB_PRINTER_POS_BARCODE_CODE39, |
||
| 1072 | // ITF, or Interleaved 2 of 5, bar code format. Used in |
||
| 1073 | // applications that have a fixed data length for all items. Only the |
||
| 1074 | // digits 0-9 can be encoded, and there must be an even number of |
||
| 1075 | // digits. |
||
| 1076 | USB_PRINTER_POS_BARCODE_ITF, |
||
| 1077 | // Codabar bar code format. Useful in applications that contain mostly |
||
| 1078 | // numeric digits and variable data sizes. This format utilizes the |
||
| 1079 | // digits 0-9, letters A-D (used as start/stop characters), '-' (dash), |
||
| 1080 | // '$' (dollar sign), ':' (colon), '/' (forward slash), '.' (period), |
||
| 1081 | // and '+' (plus). |
||
| 1082 | // If the bPrintCheckDigit flag is set, then the check digit will be |
||
| 1083 | // automatically calculated and appended. Otherwise, no check digit |
||
| 1084 | // will be printed. |
||
| 1085 | USB_PRINTER_POS_BARCODE_CODABAR, |
||
| 1086 | |||
| 1087 | #ifdef USE_PRINTER_POS_EXTENDED_BARCODE_FORMAT |
||
| 1088 | // (Available only if the printer supports extended bar code formats.) |
||
| 1089 | // CODE93 bar code format. Used in applications that require heavy |
||
| 1090 | // error checking. It has a variable data size, and uses 128-bit ASCII |
||
| 1091 | // characters. The start code, stop code, and check digits are added |
||
| 1092 | // automatically. |
||
| 1093 | USB_PRINTER_POS_BARCODE_CODE93, |
||
| 1094 | // (Available only if the printer supports extended bar code formats.) |
||
| 1095 | // Code 128 bar code format. Used in applications that require a large |
||
| 1096 | // amount of variable length data and extra error checking. It uses |
||
| 1097 | // 128-bit ASCII plus special symbols. The first two data bytes must |
||
| 1098 | // be the code set selection character. The first byte must be |
||
| 1099 | // BARCODE_CODE128_CODESET (0x7B), and the second byte must be 'A', |
||
| 1100 | // 'B', or 'C'. In general Code A should be used if the data contains |
||
| 1101 | // control characters (0x00 - 0x1F), and Code B should be used if the |
||
| 1102 | // data contains lower case letters and higher ASCII values (0x60-0x7F). |
||
| 1103 | // If an ASCII '{' (left brace, 0x7B) is contained in the data, it must |
||
| 1104 | // be encoded as two bytes with the value 0x7B. |
||
| 1105 | USB_PRINTER_POS_BARCODE_CODE128, |
||
| 1106 | // NOT YET SUPPORTED (Available only if the printer supports extended bar code formats.) |
||
| 1107 | // EAN-128 or UCC-128 bar code format. Used in shipping applications. |
||
| 1108 | // Refer to the Application Standard for Shopping Container Codes from |
||
| 1109 | // the Uniform Code Council. |
||
| 1110 | USB_PRINTER_POS_BARCODE_EAN128, |
||
| 1111 | #endif |
||
| 1112 | |||
| 1113 | // Bar code type out of range. |
||
| 1114 | USB_PRINTER_POS_BARCODE_MAX |
||
| 1115 | |||
| 1116 | } USB_PRINTER_POS_BARCODE_FORMAT; |
||
| 1117 | #endif |
||
| 1118 | |||
| 1119 | //DOM-IGNORE-BEGIN |
||
| 1120 | // For backward compatibility with typo. |
||
| 1121 | #define USB_PRINTER_POS_BARCODE_CODEABAR USB_PRINTER_POS_BARCODE_CODABAR |
||
| 1122 | //DOM-IGNORE-END |
||
| 1123 | |||
| 1124 | // ***************************************************************************** |
||
| 1125 | // ***************************************************************************** |
||
| 1126 | // Section: USB Data Structures |
||
| 1127 | // ***************************************************************************** |
||
| 1128 | // ***************************************************************************** |
||
| 1129 | |||
| 1130 | // This type is used to represent a generic RAM or ROM pointer when |
||
| 1131 | // passed to the function USBHostPrinterCommand() or a printer language |
||
| 1132 | // function of the type |
||
| 1133 | // USB_PRINTER_LANGUAGE_HANDLER. Note that the caller must indicate |
||
| 1134 | // whether the point is actually pointing to RAM or to ROM, so we can |
||
| 1135 | // tell which pointer is valid. Not all printer commands can actually |
||
| 1136 | // use data in ROM. Refer to the specific printer command in the |
||
| 1137 | // USB_PRINTER_COMMAND enumeration for more information. |
||
| 1138 | typedef union { |
||
| 1139 | void *pointerRAM; // Pointer to data in RAM. |
||
| 1140 | #if defined( __C30__ ) |
||
| 1141 | __prog__ void *pointerROM; // Pointer to data in ROM. |
||
| 1142 | #elif defined( __PIC32MX__ ) |
||
| 1143 | const void *pointerROM; // Pointer to data in ROM. |
||
| 1144 | #endif |
||
| 1145 | } USB_DATA_POINTER; |
||
| 1146 | |||
| 1147 | // Use this definition to cast a pointer being passed to the function |
||
| 1148 | // USBHostPrinterCommand() that points to data in RAM. |
||
| 1149 | #define USB_DATA_POINTER_RAM(x) ((USB_DATA_POINTER)(void *)x) |
||
| 1150 | // Use this definition to cast a pointer being passed to the function |
||
| 1151 | // USBHostPrinterCommand() that points to data in ROM. |
||
| 1152 | #if defined( __C30__ ) |
||
| 1153 | #define USB_DATA_POINTER_ROM(x) ((USB_DATA_POINTER)(__prog__ void *)x) |
||
| 1154 | #elif defined( __PIC32MX__ ) |
||
| 1155 | #define USB_DATA_POINTER_ROM(x) ((USB_DATA_POINTER)(const void *)x) |
||
| 1156 | #endif |
||
| 1157 | // Use this definition to pass a NULL pointer to the function |
||
| 1158 | // USBHostPrinterCommand(). |
||
| 1159 | #define USB_NULL (USB_DATA_POINTER)(void *)NULL |
||
| 1160 | |||
| 1161 | // ***************************************************************************** |
||
| 1162 | /* Printer Device Function support Information |
||
| 1163 | |||
| 1164 | This structure contains information about the functions that the attached |
||
| 1165 | printer supports. See the related constants for setting these flags via the |
||
| 1166 | val member: |
||
| 1167 | * USB_PRINTER_FUNCTION_SUPPORT_POS |
||
| 1168 | * USB_PRINTER_FUNCTION_SUPPORT_VECTOR_GRAPHICS |
||
| 1169 | */ |
||
| 1170 | |||
| 1171 | typedef union |
||
| 1172 | { |
||
| 1173 | WORD val; // The WORD representation of the support flags. |
||
| 1174 | struct |
||
| 1175 | { |
||
| 1176 | WORD supportsVectorGraphics : 1; // The printer supports vector graphics. |
||
| 1177 | WORD supportsPOS : 1; // The printer is a POS printer. |
||
| 1178 | } supportFlags; // Various printer function support flags. |
||
| 1179 | } USB_PRINTER_FUNCTION_SUPPORT; |
||
| 1180 | |||
| 1181 | |||
| 1182 | // ***************************************************************************** |
||
| 1183 | /* Printer Device ID Information |
||
| 1184 | |||
| 1185 | This structure contains identification information about an attached device. |
||
| 1186 | */ |
||
| 1187 | typedef struct _USB_PRINTER_DEVICE_ID |
||
| 1188 | { |
||
| 1189 | WORD vid; // Vendor ID of the device |
||
| 1190 | WORD pid; // Product ID of the device |
||
| 1191 | USB_PRINTER_FUNCTION_SUPPORT support; // Function support flags. |
||
| 1192 | BYTE deviceAddress; // Address of the device on the USB |
||
| 1193 | } USB_PRINTER_DEVICE_ID; |
||
| 1194 | |||
| 1195 | |||
| 1196 | // ***************************************************************************** |
||
| 1197 | /* Bitmapped Image Information |
||
| 1198 | |||
| 1199 | This structure contains the information needed to print a bitmapped graphic |
||
| 1200 | image. |
||
| 1201 | |||
| 1202 | When using a full sheet printer, utilize the resolution and the scale members |
||
| 1203 | to specify the size of the image. Some printer languages (e.g. PostScript) utilize |
||
| 1204 | a scale factor, while others (e.g. PCL 5) utilize a dots-per-inch resolution. |
||
| 1205 | Also, some printers that utilize the resolution specification support only |
||
| 1206 | certain values for the resolution. For maximum compatibility, specify both |
||
| 1207 | members of this structure. The following table shows example values that will |
||
| 1208 | generate similarly sized output. |
||
| 1209 | <code> |
||
| 1210 | Resolution (DPI) Scale |
||
| 1211 | ---------------- ----- |
||
| 1212 | 75 1.0 |
||
| 1213 | 100 0.75 |
||
| 1214 | 150 0.5 |
||
| 1215 | 200 0.37 |
||
| 1216 | 300 0.25 |
||
| 1217 | 600 0.13 |
||
| 1218 | </code> |
||
| 1219 | |||
| 1220 | When using a POS printer, utilize the densityVertical and densityHorizontal |
||
| 1221 | members to specify the size of the image. The densityHorizontal can be either |
||
| 1222 | single (1) or double (2). The valid values for densityVertical are printer |
||
| 1223 | dependent. Most printers support 8-dot, many support 8 and 24-dot, and a few |
||
| 1224 | support 8, 24, and 36-dot (represented by the values 8, 24, and 36 |
||
| 1225 | respectively). This value affects how the bit image data is sent to the |
||
| 1226 | printer. The set of allowable values must be configured correctly, since |
||
| 1227 | the image configuration method differs depending on the set of allowed values. |
||
| 1228 | To maintain the aspect ratio, the following selections are recommended: |
||
| 1229 | <code> |
||
| 1230 | Supported Horizontal Densities densityVertical densityHorizontal |
||
| 1231 | ------------------------------------------------------------------ |
||
| 1232 | 8-dot 8 1 (single) |
||
| 1233 | 8 and 24-dot 24 2 (double) |
||
| 1234 | 8, 24, and 36-dot 24 2 (double) |
||
| 1235 | </code> |
||
| 1236 | The 36-bit density is not recommended, as it requires a great deal of available |
||
| 1237 | heap space, is not supported by the USBHostPrinterPOSImageDataFormat() function, |
||
| 1238 | and produces the same output as the 24-dot density print. |
||
| 1239 | */ |
||
| 1240 | typedef struct |
||
| 1241 | { |
||
| 1242 | WORD width; // The width of the image in pixels. |
||
| 1243 | WORD height; // The height of the image in pixels. |
||
| 1244 | WORD positionX; // The position of the image on the X axis. |
||
| 1245 | WORD positionY; // The position of the image on the Y axis. |
||
| 1246 | union |
||
| 1247 | { |
||
| 1248 | struct |
||
| 1249 | { |
||
| 1250 | WORD resolution; // (Full sheet printers only.) The resolution |
||
| 1251 | // of the printed image. This |
||
| 1252 | // parameter is not supported by all printer |
||
| 1253 | // languages. |
||
| 1254 | float scale; // (Full sheet printers only.) The scaling |
||
| 1255 | // of the printed image. Both the |
||
| 1256 | // X axis and the Y axis are scaled by this |
||
| 1257 | // amount. This parameter is not supported by |
||
| 1258 | // all printer languages. |
||
| 1259 | }; |
||
| 1260 | struct |
||
| 1261 | { |
||
| 1262 | BYTE densityVertical; // (POS printers only.) The vertical dot |
||
| 1263 | // density of the bit image. Valid values |
||
| 1264 | // are printer dependent. See above. |
||
| 1265 | BYTE densityHorizontal; // (POS printers only.) The horizontal dot |
||
| 1266 | // density of the bit image. Valid values are |
||
| 1267 | // 1 (single) and 2 (double). See above. |
||
| 1268 | }; |
||
| 1269 | }; |
||
| 1270 | } USB_PRINTER_IMAGE_INFO; |
||
| 1271 | |||
| 1272 | |||
| 1273 | //----------------------------------------------------------------------------- |
||
| 1274 | /* USB Printer Graphics Parameter Structures |
||
| 1275 | |||
| 1276 | This union can be used to declare a variable that can hold the parameters for |
||
| 1277 | any printer graphics or POS printer command (USB_PRINTER_COMMAND). The union |
||
| 1278 | allows a single variable to be declared and then reused for any printer |
||
| 1279 | graphics command. |
||
| 1280 | */ |
||
| 1281 | |||
| 1282 | typedef union |
||
| 1283 | { |
||
| 1284 | // This structure is used by the USB_PRINTER_GRAPHICS_ARC command |
||
| 1285 | // (USB_PRINTER_COMMAND). |
||
| 1286 | struct |
||
| 1287 | { |
||
| 1288 | WORD xL; // X-axis position of the upper left corner. |
||
| 1289 | WORD yT; // Y-axis position of the upper left corner. |
||
| 1290 | WORD xR; // X-axis position of the lower right corner. |
||
| 1291 | WORD yB; // Y-axis position of the lower right corner. |
||
| 1292 | WORD r1; // The inner radius of the two concentric cicles that defines the thickness of the arc. |
||
| 1293 | WORD r2; // The outer of radius the two concentric circles that defines the thickness of the arc. |
||
| 1294 | WORD octant; // Bitmask of the octant that will be drawn. Moving in a clockwise direction from x = 0, y = +radius |
||
| 1295 | // * bit0 : first octant |
||
| 1296 | // * bit1 : second octant |
||
| 1297 | // * bit2 : third octant |
||
| 1298 | // * bit3 : fourth octant |
||
| 1299 | // * bit4 : fifth octant |
||
| 1300 | // * bit5 : sixth octant |
||
| 1301 | // * bit6 : seventh octant |
||
| 1302 | // * bit7 : eigth octant |
||
| 1303 | } sArc; |
||
| 1304 | |||
| 1305 | // This structure is used by the USB_PRINTER_POS_BARCODE command (USB_PRINTER_COMMAND). |
||
| 1306 | struct |
||
| 1307 | { |
||
| 1308 | //WORD x; // For future implementation - Horizontal location of the lower left corner of the bar code. |
||
| 1309 | //WORD y; // For future implementation - Vertical location of the lower left corner of the bar code. Readable text will print below this point. |
||
| 1310 | BYTE height; // Bar code height in dots. |
||
| 1311 | BYTE type; // Bar code type. See the USB_PRINTER_POS_BARCODE_FORMAT enumeration. |
||
| 1312 | BYTE textPosition; // Position of the readable text. Valid values are BARCODE_TEXT_OMIT, BARCODE_TEXT_ABOVE, BARCODE_TEXT_BELOW, BARCODE_TEXT_ABOVE_AND_BELOW. |
||
| 1313 | BYTE textFont; // Font of the readable text. Valid values are dependent on the particular POS printer (BARCODE_TEXT_12x24 and BARCODE_TEXT_18x36 for ESC/POS). |
||
| 1314 | BYTE *data; // Pointer to the bar code data. |
||
| 1315 | BYTE dataLength; // Number of bytes of bar code data. |
||
| 1316 | union |
||
| 1317 | { |
||
| 1318 | BYTE value; |
||
| 1319 | struct |
||
| 1320 | { |
||
| 1321 | BYTE bPrintCheckDigit : 1; // Whether or not to print an optional check digit. Valid for Code39 (USB_PRINTER_POS_BARCODE_FORMAT USB_PRINTER_POS_BARCODE_CODE39) and CODABAR (USB_PRINTER_POS_BARCODE_FORMAT USB_PRINTER_POS_BARCODE_CODABAR) formats only. |
||
| 1322 | } bits; |
||
| 1323 | } flags; |
||
| 1324 | } sBarCode; |
||
| 1325 | |||
| 1326 | // This structure is used by the USB_PRINTER_GRAPHICS_BEVEL and |
||
| 1327 | // USB_PRINTER_GRAPHICS_BEVEL_FILLED commands (USB_PRINTER_COMMAND). |
||
| 1328 | struct |
||
| 1329 | { |
||
| 1330 | WORD xL; // X-axis position of the left side of the bevel. |
||
| 1331 | WORD yT; // Y-axis position of the top of the bevel. |
||
| 1332 | WORD xR; // X-axis position of the right side of the bevel. |
||
| 1333 | WORD yB; // Y-axis position of the bottom of the bevel. |
||
| 1334 | WORD r; // The radius of the cicle that defines the rounded corner |
||
| 1335 | } sBevel; |
||
| 1336 | |||
| 1337 | // This structure is used by the USB_PRINTER_GRAPHICS_CIRCLE and |
||
| 1338 | // USB_PRINTER_GRAPHICS_CIRCLE_FILLED commands (USB_PRINTER_COMMAND). |
||
| 1339 | struct |
||
| 1340 | { |
||
| 1341 | WORD x; // X-axis position of the center of the circle. |
||
| 1342 | WORD y; // Y-axis position of the center of the circle. |
||
| 1343 | WORD r; // Radius of the circle. |
||
| 1344 | } sCircle; |
||
| 1345 | |||
| 1346 | // This structure is used by the USB_PRINTER_GRAPHICS_FILL_TYPE command (USB_PRINTER_COMMAND). |
||
| 1347 | struct |
||
| 1348 | { |
||
| 1349 | WORD fillType; // The type of fill. See USB_PRINTER_GRAPHICS_FILL_TYPE for valid values. |
||
| 1350 | WORD spacing; // Line spacing for hatched fill (if supported). |
||
| 1351 | WORD angle; // Line angle for hatched fill (if supported). |
||
| 1352 | WORD shading; // Shading level for shaded fill. Printer support may be limited. |
||
| 1353 | } sFillType; |
||
| 1354 | |||
| 1355 | // This structure is used by the USB_PRINTER_GRAPHICS_LINE command (USB_PRINTER_COMMAND). |
||
| 1356 | struct |
||
| 1357 | { |
||
| 1358 | WORD x1; // X-axis position of the first point. |
||
| 1359 | WORD y1; // Y-axis position of the first point. |
||
| 1360 | WORD x2; // X-axis position of the second point. |
||
| 1361 | WORD y2; // Y-axis position of the second point. |
||
| 1362 | } sLine; |
||
| 1363 | |||
| 1364 | // This structure is used by POS printers and the USB_PRINTER_POS_PAGE_MODE |
||
| 1365 | // command (USB_PRINTER_COMMAND). |
||
| 1366 | struct |
||
| 1367 | { |
||
| 1368 | WORD startPointHorizontal; // The horizontal page starting point. |
||
| 1369 | WORD startPointVertical; // The vertical page starting point. |
||
| 1370 | WORD lengthHorizontal; // The horizontal print length. |
||
| 1371 | WORD lengthVertical; // The vertical print length. |
||
| 1372 | BYTE printDirection; // The print direction and starting point. |
||
| 1373 | } sPage; |
||
| 1374 | |||
| 1375 | // This structure is used by the USB_PRINTER_GRAPHICS_POLYGON command (USB_PRINTER_COMMAND). |
||
| 1376 | struct |
||
| 1377 | { |
||
| 1378 | SHORT numPoints; // The number of points of the polygon. |
||
| 1379 | WORD *points; // The array of polygon points {x1, y1, x2, y2, ... xn, yn}. |
||
| 1380 | } sPolygon; |
||
| 1381 | |||
| 1382 | // This structure is used by the USB_PRINTER_GRAPHICS_RECTANGLE and |
||
| 1383 | // USB_PRINTER_GRAPHICS_RECTANGLE_FILLED commands (USB_PRINTER_COMMAND). |
||
| 1384 | struct |
||
| 1385 | { |
||
| 1386 | WORD xL; // X-axis position of the left side of the rectangle. |
||
| 1387 | WORD yT; // Y-axis position of the top of the rectangle. |
||
| 1388 | WORD xR; // X-axis position of the right side of the rectangle. |
||
| 1389 | WORD yB; // Y-axis position of the bottom of the rectangle. |
||
| 1390 | } sRectangle; |
||
| 1391 | |||
| 1392 | } USB_PRINTER_GRAPHICS_PARAMETERS; |
||
| 1393 | |||
| 1394 | |||
| 1395 | // ***************************************************************************** |
||
| 1396 | // ***************************************************************************** |
||
| 1397 | // Section: USB Host Printer - Printer Language Interface |
||
| 1398 | // ***************************************************************************** |
||
| 1399 | // ***************************************************************************** |
||
| 1400 | |||
| 1401 | /**************************************************************************** |
||
| 1402 | Function: |
||
| 1403 | BYTE (*USB_PRINTER_LANGUAGE_HANDLER) ( BYTE address, |
||
| 1404 | USB_PRINTER_COMMAND command, USB_DATA_POINTER data, DWORD size, BYTE flags ) |
||
| 1405 | |||
| 1406 | Summary: |
||
| 1407 | This is a typedef to use when defining a printer language command handler. |
||
| 1408 | |||
| 1409 | Description: |
||
| 1410 | This data type defines a pointer to a call-back function that must be |
||
| 1411 | implemented by a printer language driver. When the user calls the |
||
| 1412 | printer interface function, the appropriate language driver with this |
||
| 1413 | prototype will be called to generate the proper commands for the requested |
||
| 1414 | operation. |
||
| 1415 | |||
| 1416 | Not all printer commands support data from both RAM and ROM. Unless |
||
| 1417 | otherwise noted, the data pointer is assumed to point to RAM, regardless of |
||
| 1418 | the value of transferFlags. Refer to the specific command to see if ROM |
||
| 1419 | data is supported. |
||
| 1420 | |||
| 1421 | Precondition: |
||
| 1422 | None |
||
| 1423 | |||
| 1424 | Parameters: |
||
| 1425 | BYTE address - Device's address on the bus |
||
| 1426 | USB_PRINTER_COMMAND command - Command to execute. See the enumeration |
||
| 1427 | USB_PRINTER_COMMAND for the list of |
||
| 1428 | valid commands and their requirements. |
||
| 1429 | USB_DATA_POINTER data - Pointer to the required data. Note that |
||
| 1430 | the caller must set transferFlags |
||
| 1431 | appropriately to indicate if the pointer is |
||
| 1432 | a RAM pointer or a ROM pointer. |
||
| 1433 | DWORD size - Size of the data. For some commands, this |
||
| 1434 | parameter is used to hold the data itself. |
||
| 1435 | BYTE transferFlags - Flags that indicate details about the |
||
| 1436 | transfer operation. Refer to these flags |
||
| 1437 | * USB_PRINTER_TRANSFER_COPY_DATA |
||
| 1438 | * USB_PRINTER_TRANSFER_STATIC_DATA |
||
| 1439 | * USB_PRINTER_TRANSFER_NOTIFY |
||
| 1440 | * USB_PRINTER_TRANSFER_FROM_ROM |
||
| 1441 | * USB_PRINTER_TRANSFER_FROM_RAM |
||
| 1442 | |||
| 1443 | Return Values: |
||
| 1444 | USB_PRINTER_SUCCESS - The command was executed successfully. |
||
| 1445 | USB_PRINTER_UNKNOWN_DEVICE - A printer with the indicated address is not |
||
| 1446 | attached |
||
| 1447 | USB_PRINTER_TOO_MANY_DEVICES - The printer status array does not have |
||
| 1448 | space for another printer. |
||
| 1449 | USB_PRINTER_OUT_OF_MEMORY - Not enough available heap space to |
||
| 1450 | execute the command. |
||
| 1451 | other - See possible return codes from the |
||
| 1452 | function USBHostPrinterWrite(). |
||
| 1453 | |||
| 1454 | Remarks: |
||
| 1455 | None |
||
| 1456 | ***************************************************************************/ |
||
| 1457 | |||
| 1458 | typedef BYTE (*USB_PRINTER_LANGUAGE_HANDLER) ( BYTE address, |
||
| 1459 | USB_PRINTER_COMMAND command, USB_DATA_POINTER data, DWORD size, BYTE flags ); |
||
| 1460 | |||
| 1461 | |||
| 1462 | /**************************************************************************** |
||
| 1463 | Function: |
||
| 1464 | BOOL (*USB_PRINTER_LANGUAGE_SUPPORTED) ( char *deviceID, |
||
| 1465 | USB_PRINTER_FUNCTION_SUPPORT *support ) |
||
| 1466 | |||
| 1467 | Summary: |
||
| 1468 | This is a typedef to use when defining a function that determines if the |
||
| 1469 | printer with the given "COMMAND SET:" portion of the device ID string |
||
| 1470 | supports the particular printer language. |
||
| 1471 | |||
| 1472 | Description: |
||
| 1473 | This data type defines a pointer to a call-back function that must be |
||
| 1474 | implemented by a printer language driver. When the user calls a function |
||
| 1475 | of this type, the language driver will return a BOOL indicating if the |
||
| 1476 | language driver supports a printer with the indicated "COMMAND SET:" |
||
| 1477 | portion of the device ID string. If the printer is supported, this |
||
| 1478 | function also returns information about the types of operations that |
||
| 1479 | the printer supports. |
||
| 1480 | |||
| 1481 | Preconditions: |
||
| 1482 | None |
||
| 1483 | |||
| 1484 | Parameters: |
||
| 1485 | char *deviceID - Pointer to the "COMMAND SET:" portion of the device ID |
||
| 1486 | string of the attached printer. |
||
| 1487 | USB_PRINTER_FUNCTION_SUPPORT *support - Pointer to returned information |
||
| 1488 | about what types of functions this printer supports. |
||
| 1489 | |||
| 1490 | Return Values: |
||
| 1491 | TRUE - The printer language can be used with the attached printer. |
||
| 1492 | FALSE - The printer language cannot be used with the attached printer. |
||
| 1493 | |||
| 1494 | Remarks: |
||
| 1495 | The caller must first locate the "COMMAND SET:" section of the device ID |
||
| 1496 | string. To ensure that only the "COMMAND SET:" section of the device ID |
||
| 1497 | string is checked, the ";" at the end of the section should be temporarily |
||
| 1498 | replaced with a NULL. Otherwise, this function may find the printer |
||
| 1499 | language string in the comments or other section, and incorrectly indicate |
||
| 1500 | that the printer supports the language. |
||
| 1501 | |||
| 1502 | Device ID strings are case sensitive. |
||
| 1503 | ***************************************************************************/ |
||
| 1504 | |||
| 1505 | typedef BOOL (*USB_PRINTER_LANGUAGE_SUPPORTED) ( char *deviceID, |
||
| 1506 | USB_PRINTER_FUNCTION_SUPPORT *support ); |
||
| 1507 | |||
| 1508 | |||
| 1509 | /**************************************************************************** |
||
| 1510 | Function: |
||
| 1511 | WORD USB_PRINTER_EXTERNAL_MEMORY_CALLBACK |
||
| 1512 | (EXTDATA* memory, LONG offset, WORD nCount, void* buffer) |
||
| 1513 | |||
| 1514 | Summary: |
||
| 1515 | If printer data is obtained from external memory, then a function must be |
||
| 1516 | defined by the application to copy requested data from the external memory |
||
| 1517 | to a RAM buffer. |
||
| 1518 | |||
| 1519 | Description: |
||
| 1520 | If printer data is obtained from external memory, then a function must be |
||
| 1521 | defined by the application to copy requested data from the external memory |
||
| 1522 | to a RAM buffer. The label USB_PRINTER_EXTERNAL_MEMORY_CALLBACK must be |
||
| 1523 | set to the name of this function. |
||
| 1524 | |||
| 1525 | Precondition: |
||
| 1526 | None |
||
| 1527 | |||
| 1528 | Parameters: |
||
| 1529 | EXTDATA *memory - Pointer to the eternal memory bitmap |
||
| 1530 | LONG offset - Byte offset of required data. |
||
| 1531 | WORD nCount - Number of data bytes to copy into the buffer. |
||
| 1532 | void *buffer - Destination data buffer. |
||
| 1533 | |||
| 1534 | Returns: |
||
| 1535 | The function returns the number of data bytes transferred. |
||
| 1536 | |||
| 1537 | Example: |
||
| 1538 | <code> |
||
| 1539 | #define USB_PRINTER_EXTERNAL_MEMORY_CALLBACK ExternalMemoryCallback |
||
| 1540 | |||
| 1541 | ... |
||
| 1542 | |||
| 1543 | // If there are several memories in the system they can be selected by IDs. |
||
| 1544 | // In this example, ID for memory device used is assumed to be 0. |
||
| 1545 | #define X_MEMORY 0 |
||
| 1546 | |||
| 1547 | WORD ExternalMemoryCallback( EXTDATA *memory, LONG offset, WORD nCount, void *buffer ) |
||
| 1548 | { |
||
| 1549 | int i; |
||
| 1550 | long address; |
||
| 1551 | |||
| 1552 | // Address of the requested data is the starting address of the object |
||
| 1553 | // referred by EXTDATA structure plus offset |
||
| 1554 | address = memory->address+offset; |
||
| 1555 | |||
| 1556 | if (memory->ID == X_MEMORY) |
||
| 1557 | { |
||
| 1558 | // MemoryXReadByte() is some function implemented to access external memory. |
||
| 1559 | // Implementation will be specific to the memory used. In this example |
||
| 1560 | // it reads byte each time it is called. |
||
| 1561 | i = 0; |
||
| 1562 | while (i < nCount) |
||
| 1563 | { |
||
| 1564 | (BYTE*)buffer++ = MemoryXReadByte(address++); |
||
| 1565 | i++; |
||
| 1566 | } |
||
| 1567 | } |
||
| 1568 | // return the actual number of bytes retrieved |
||
| 1569 | return (i); |
||
| 1570 | } |
||
| 1571 | </code> |
||
| 1572 | |||
| 1573 | Remarks: |
||
| 1574 | None |
||
| 1575 | ***************************************************************************/ |
||
| 1576 | |||
| 1577 | //for future implementation |
||
| 1578 | // |
||
| 1579 | //#if defined( USB_PRINTER_EXTERNAL_MEMORY_CALLBACK ) |
||
| 1580 | // WORD USB_PRINTER_EXTERNAL_MEMORY_CALLBACK |
||
| 1581 | // (EXTDATA* memory, LONG offset, WORD nCount, void* buffer); |
||
| 1582 | //#else |
||
| 1583 | // // If the application does not have an external memory callback, we will |
||
| 1584 | // // define a stub. |
||
| 1585 | // #define USB_PRINTER_EXTERNAL_MEMORY_CALLBACK(m,o,c,b) 0 |
||
| 1586 | //#endif |
||
| 1587 | |||
| 1588 | |||
| 1589 | // ***************************************************************************** |
||
| 1590 | // ***************************************************************************** |
||
| 1591 | // Section: USB Data Structures - continued |
||
| 1592 | // ***************************************************************************** |
||
| 1593 | // ***************************************************************************** |
||
| 1594 | |||
| 1595 | //----------------------------------------------------------------------------- |
||
| 1596 | /* USB Printer Interface Structure |
||
| 1597 | |||
| 1598 | This structure represents the information needed to interface with a printer |
||
| 1599 | language. An array of these structures must be created in usb_config.c, so |
||
| 1600 | the USB printer client driver can determine what printer language to use to |
||
| 1601 | communicate with the printer. |
||
| 1602 | */ |
||
| 1603 | typedef struct |
||
| 1604 | { |
||
| 1605 | // Function in the printer language support file that handles all |
||
| 1606 | // printer commands. |
||
| 1607 | USB_PRINTER_LANGUAGE_HANDLER languageCommandHandler; |
||
| 1608 | // Function in the printer language support file that determines |
||
| 1609 | // if the printer supports this particular printer language. |
||
| 1610 | USB_PRINTER_LANGUAGE_SUPPORTED isLanguageSupported; |
||
| 1611 | } USB_PRINTER_INTERFACE; |
||
| 1612 | |||
| 1613 | |||
| 1614 | //----------------------------------------------------------------------------- |
||
| 1615 | /* USB Printer Specific Interface Structure |
||
| 1616 | |||
| 1617 | This structure is used to explicitly specify what printer language to use for a |
||
| 1618 | particular printer, and what print functions the printer supports. It can be |
||
| 1619 | used when a printer supports multiple languages with one language preferred over |
||
| 1620 | the others. It is required for printers that do not support the GET_DEVICE_ID |
||
| 1621 | printer class request. These printers do not report what printer languages |
||
| 1622 | they support. Typically, these printers also do not report Printer Class |
||
| 1623 | support in their Interface Descriptors, and must be explicitly supported by |
||
| 1624 | their VID and PID in the TPL. This structure links the VID and PID of the |
||
| 1625 | printer to the index in the usbPrinterClientLanguages[] array of |
||
| 1626 | USB_PRINTER_INTERFACE structures in usb_config.c that contains the appropriate |
||
| 1627 | printer language functions. |
||
| 1628 | */ |
||
| 1629 | typedef struct |
||
| 1630 | { |
||
| 1631 | WORD vid; // Printer vendor ID. |
||
| 1632 | WORD pid; // Printer product ID. |
||
| 1633 | WORD languageIndex; // Index into the usbPrinterClientLanguages[] array of USB_PRINTER_INTERFACE structures defined in usb_config.c. |
||
| 1634 | USB_PRINTER_FUNCTION_SUPPORT support; // Support flags that are set by this printer. |
||
| 1635 | } USB_PRINTER_SPECIFIC_INTERFACE; |
||
| 1636 | |||
| 1637 | |||
| 1638 | // ***************************************************************************** |
||
| 1639 | // ***************************************************************************** |
||
| 1640 | // Section: Host Stack Interface Functions |
||
| 1641 | // ***************************************************************************** |
||
| 1642 | // ***************************************************************************** |
||
| 1643 | |||
| 1644 | /*************************************************************************** |
||
| 1645 | Function: |
||
| 1646 | BOOL USBHostPrinterInitialize ( BYTE address, DWORD flags, BYTE clientDriverID ) |
||
| 1647 | |||
| 1648 | Summary: |
||
| 1649 | This function is called by the USB Embedded Host layer when a printer |
||
| 1650 | attaches. |
||
| 1651 | |||
| 1652 | Description: |
||
| 1653 | This routine is a call out from the USB Embedded Host layer to the USB |
||
| 1654 | printer client driver. It is called when a "printer" device has been |
||
| 1655 | connected to the host. Its purpose is to initialize and activate the USB |
||
| 1656 | Printer client driver. |
||
| 1657 | |||
| 1658 | Preconditions: |
||
| 1659 | The device has been configured. |
||
| 1660 | |||
| 1661 | Parameters: |
||
| 1662 | BYTE address - Device's address on the bus |
||
| 1663 | DWORD flags - Initialization flags |
||
| 1664 | BYTE clientDriverID - Client driver identification for device requests |
||
| 1665 | |||
| 1666 | Return Values: |
||
| 1667 | TRUE - Initialization was successful |
||
| 1668 | FALSE - Initialization failed |
||
| 1669 | |||
| 1670 | Remarks: |
||
| 1671 | Multiple client drivers may be used in a single application. The USB |
||
| 1672 | Embedded Host layer will call the initialize routine required for the |
||
| 1673 | attached device. |
||
| 1674 | ***************************************************************************/ |
||
| 1675 | |||
| 1676 | BOOL USBHostPrinterInitialize ( BYTE address, DWORD flags, BYTE clientDriverID ); |
||
| 1677 | |||
| 1678 | |||
| 1679 | /**************************************************************************** |
||
| 1680 | Function: |
||
| 1681 | BOOL USBHostPrinterEventHandler ( BYTE address, USB_EVENT event, |
||
| 1682 | void *data, DWORD size ) |
||
| 1683 | |||
| 1684 | Summary: |
||
| 1685 | This routine is called by the Host layer to notify the printer client of |
||
| 1686 | events that occur. |
||
| 1687 | |||
| 1688 | Description: |
||
| 1689 | This routine is called by the Host layer to notify the printer client of |
||
| 1690 | events that occur. If the event is recognized, it is handled and the |
||
| 1691 | routine returns TRUE. Otherwise, it is ignored and the routine returns |
||
| 1692 | FALSE. |
||
| 1693 | |||
| 1694 | This routine can notify the application with the following events: |
||
| 1695 | * EVENT_PRINTER_ATTACH |
||
| 1696 | * EVENT_PRINTER_DETACH |
||
| 1697 | * EVENT_PRINTER_TX_DONE |
||
| 1698 | * EVENT_PRINTER_RX_DONE |
||
| 1699 | * EVENT_PRINTER_REQUEST_DONE |
||
| 1700 | * EVENT_PRINTER_UNSUPPORTED |
||
| 1701 | |||
| 1702 | Preconditions: |
||
| 1703 | None |
||
| 1704 | |||
| 1705 | Parameters: |
||
| 1706 | BYTE address - Address of device with the event |
||
| 1707 | USB_EVENT event - The bus event that occured |
||
| 1708 | void *data - Pointer to event-specific data |
||
| 1709 | DWORD size - Size of the event-specific data |
||
| 1710 | Return Values: |
||
| 1711 | TRUE - The event was handled |
||
| 1712 | FALSE - The event was not handled |
||
| 1713 | |||
| 1714 | Remarks: |
||
| 1715 | None |
||
| 1716 | ***************************************************************************/ |
||
| 1717 | |||
| 1718 | BOOL USBHostPrinterEventHandler ( BYTE address, USB_EVENT event, void *data, DWORD size ); |
||
| 1719 | |||
| 1720 | |||
| 1721 | // ***************************************************************************** |
||
| 1722 | // ***************************************************************************** |
||
| 1723 | // Section: Application Interface Function Prototypes and Macro Functions |
||
| 1724 | // ***************************************************************************** |
||
| 1725 | // ***************************************************************************** |
||
| 1726 | |||
| 1727 | /**************************************************************************** |
||
| 1728 | Function: |
||
| 1729 | BYTE USBHostPrinterCommand( BYTE deviceAddress, USB_PRINTER_COMMAND command, |
||
| 1730 | USB_DATA_POINTER data, DWORD size, BYTE flags ) |
||
| 1731 | |||
| 1732 | Summary: |
||
| 1733 | This is the primary user interface function for the printer client |
||
| 1734 | driver. It is used to issue all printer commands. |
||
| 1735 | |||
| 1736 | Description: |
||
| 1737 | This is the primary user interface function for the printer client |
||
| 1738 | driver. It is used to issue all printer commands. Each generic printer |
||
| 1739 | command is translated to the appropriate command for the supported |
||
| 1740 | language and is enqueued for transfer to the printer. Before calling |
||
| 1741 | this routine, it is recommended to call the function |
||
| 1742 | USBHostPrinterCommandReady() to determine if there is space available |
||
| 1743 | in the printer's output queue. |
||
| 1744 | |||
| 1745 | Preconditions: |
||
| 1746 | None |
||
| 1747 | |||
| 1748 | Parameters: |
||
| 1749 | BYTE address - Device's address on the bus |
||
| 1750 | USB_PRINTER_COMMAND command - Command to execute. See the enumeration |
||
| 1751 | USB_PRINTER_COMMAND for the list of |
||
| 1752 | valid commands and their requirements. |
||
| 1753 | USB_DATA_POINTER data - Pointer to the required data. Note that |
||
| 1754 | the caller must set transferFlags |
||
| 1755 | appropriately to indicate if the pointer is |
||
| 1756 | a RAM pointer or a ROM pointer. |
||
| 1757 | DWORD size - Size of the data. For some commands, this |
||
| 1758 | parameter is used to hold the data itself. |
||
| 1759 | BYTE transferFlags - Flags that indicate details about the |
||
| 1760 | transfer operation. Refer to these flags |
||
| 1761 | * USB_PRINTER_TRANSFER_COPY_DATA |
||
| 1762 | * USB_PRINTER_TRANSFER_STATIC_DATA |
||
| 1763 | * USB_PRINTER_TRANSFER_NOTIFY |
||
| 1764 | * USB_PRINTER_TRANSFER_FROM_ROM |
||
| 1765 | * USB_PRINTER_TRANSFER_FROM_RAM |
||
| 1766 | |||
| 1767 | Returns: |
||
| 1768 | See the USB_PRINTER_ERRORS enumeration. Also, refer to the printer |
||
| 1769 | language command handler function, such as |
||
| 1770 | USBHostPrinterLanguagePostScript(). |
||
| 1771 | |||
| 1772 | Example: |
||
| 1773 | <code> |
||
| 1774 | if (USBHostPrinterCommandReady( address )) |
||
| 1775 | { |
||
| 1776 | USBHostPrinterCommand( address, USB_PRINTER_JOB_START, USB_NULL, 0, 0 ); |
||
| 1777 | } |
||
| 1778 | </code> |
||
| 1779 | |||
| 1780 | Remarks: |
||
| 1781 | When developing new commands, keep in mind that the function |
||
| 1782 | USBHostPrinterCommandReady() will be used before calling this function to |
||
| 1783 | see if there is space available in the output transfer queue. |
||
| 1784 | USBHostPrinterCommandReady() will routine TRUE if a single space is |
||
| 1785 | available in the output queue. Therefore, each command can generate only |
||
| 1786 | one output transfer. |
||
| 1787 | ***************************************************************************/ |
||
| 1788 | |||
| 1789 | BYTE USBHostPrinterCommand( BYTE deviceAddress, USB_PRINTER_COMMAND command, |
||
| 1790 | USB_DATA_POINTER data, DWORD size, BYTE flags ); |
||
| 1791 | |||
| 1792 | |||
| 1793 | /**************************************************************************** |
||
| 1794 | Function: |
||
| 1795 | BOOL USBHostPrinterCommandReady( BYTE deviceAddress ) |
||
| 1796 | |||
| 1797 | Description: |
||
| 1798 | This interface is used to check if the client driver has space available |
||
| 1799 | to enqueue another transfer. |
||
| 1800 | |||
| 1801 | Preconditions: |
||
| 1802 | None |
||
| 1803 | |||
| 1804 | Parameters: |
||
| 1805 | deviceAddress - USB Address of the device |
||
| 1806 | |||
| 1807 | Return Values: |
||
| 1808 | TRUE - The printer client driver has room for at least one more |
||
| 1809 | transfer request, or the device is not attached. The latter |
||
| 1810 | allows this routine to be called without generating an |
||
| 1811 | infinite loop if the device detaches. |
||
| 1812 | FALSE - The transfer queue is full. |
||
| 1813 | |||
| 1814 | Example: |
||
| 1815 | <code> |
||
| 1816 | if (USBHostPrinterCommandReady( address )) |
||
| 1817 | { |
||
| 1818 | USBHostPrinterCommand( address, USB_PRINTER_JOB_START, USB_NULL, 0, 0 ); |
||
| 1819 | } |
||
| 1820 | </code> |
||
| 1821 | |||
| 1822 | Remarks: |
||
| 1823 | Use the definitions USB_DATA_POINTER_RAM() and USB_DATA_POINTER_ROM() |
||
| 1824 | to cast data pointers. For example: |
||
| 1825 | <code> |
||
| 1826 | USBHostPrinterCommand( address, USB_PRINTER_TEXT, USB_DATA_POINTER_RAM(buffer), strlen(buffer), 0 ); |
||
| 1827 | </code> |
||
| 1828 | |||
| 1829 | This routine will return TRUE if a single transfer can be enqueued. Since |
||
| 1830 | this routine is the check to see if USBHostPrinterCommand() can be called, |
||
| 1831 | every command can generate at most one transfer. |
||
| 1832 | ***************************************************************************/ |
||
| 1833 | |||
| 1834 | BOOL USBHostPrinterCommandReady( BYTE deviceAddress ); |
||
| 1835 | |||
| 1836 | |||
| 1837 | /**************************************************************************** |
||
| 1838 | Function: |
||
| 1839 | BYTE USBHostPrinterCommandWithReadyWait( BYTE &returnCode, |
||
| 1840 | BYTE deviceAddress, USB_PRINTER_COMMAND command, |
||
| 1841 | USB_DATA_POINTER data, DWORD size, BYTE flags ) |
||
| 1842 | |||
| 1843 | Description: |
||
| 1844 | This function is intended to be a short-cut to perform blocking calls to |
||
| 1845 | USBHostPrinterCommand(). While there is no space available in the |
||
| 1846 | printer queue (USBHostPrinterCommandReady() returns FALSE), USBTasks() is |
||
| 1847 | called. When space becomes available, USBHostPrinterCommand() is called. |
||
| 1848 | The return value from USBHostPrinterCommand() is returned in the |
||
| 1849 | returnCode parameter. |
||
| 1850 | |||
| 1851 | Preconditions: |
||
| 1852 | None |
||
| 1853 | |||
| 1854 | Parameters: |
||
| 1855 | BYTE address - Device's address on the bus |
||
| 1856 | USB_PRINTER_COMMAND command - Command to execute. See the enumeration |
||
| 1857 | USB_PRINTER_COMMAND for the list of |
||
| 1858 | valid commands and their requirements. |
||
| 1859 | USB_DATA_POINTER data - Pointer to the required data. Note that |
||
| 1860 | the caller must set transferFlags |
||
| 1861 | appropriately to indicate if the pointer is |
||
| 1862 | a RAM pointer or a ROM pointer. |
||
| 1863 | DWORD size - Size of the data. For some commands, this |
||
| 1864 | parameter is used to hold the data itself. |
||
| 1865 | BYTE transferFlags - Flags that indicate details about the |
||
| 1866 | transfer operation. Refer to these flags |
||
| 1867 | * USB_PRINTER_TRANSFER_COPY_DATA |
||
| 1868 | * USB_PRINTER_TRANSFER_STATIC_DATA |
||
| 1869 | * USB_PRINTER_TRANSFER_NOTIFY |
||
| 1870 | * USB_PRINTER_TRANSFER_FROM_ROM |
||
| 1871 | * USB_PRINTER_TRANSFER_FROM_RAM |
||
| 1872 | |||
| 1873 | Returns: |
||
| 1874 | See the USB_PRINTER_ERRORS enumeration. Also, refer to the printer |
||
| 1875 | language command handler function, such as |
||
| 1876 | USBHostPrinterLanguagePostScript(). |
||
| 1877 | |||
| 1878 | Remarks: |
||
| 1879 | Use the definitions USB_DATA_POINTER_RAM() and USB_DATA_POINTER_ROM() |
||
| 1880 | to cast data pointers. For example: |
||
| 1881 | <code> |
||
| 1882 | USBHostPrinterCommandWithReadyWait( &rc, address, USB_PRINTER_TEXT, USB_DATA_POINTER_RAM(buffer), strlen(buffer), 0 ); |
||
| 1883 | </code> |
||
| 1884 | |||
| 1885 | In the event that the device detaches during this routine, |
||
| 1886 | USBHostPrinterCommandReady() will return TRUE, and this function will |
||
| 1887 | return USB_PRINTER_UNKNOWN_DEVICE. |
||
| 1888 | ***************************************************************************/ |
||
| 1889 | #ifdef DEBUG_MODE |
||
| 1890 | #define USBHostPrinterCommandWithReadyWait( returnCode, deviceAddress, command, data, size, flags ) \ |
||
| 1891 | { \ |
||
| 1892 | while (!USBHostPrinterCommandReady( deviceAddress )) USBTasks(); \ |
||
| 1893 | *(returnCode) = USBHostPrinterCommand( deviceAddress, command, data, size, flags ); \ |
||
| 1894 | if (*(returnCode)) \ |
||
| 1895 | { \ |
||
| 1896 | UART2PrintString( "APP: Printer Command Error " ); \ |
||
| 1897 | UART2PutHex( *(returnCode) ); \ |
||
| 1898 | UART2PrintString( "\r\n" ); \ |
||
| 1899 | } \ |
||
| 1900 | else \ |
||
| 1901 | { \ |
||
| 1902 | UART2PrintString( "APP: Printer Command successful\r\n" ); \ |
||
| 1903 | } \ |
||
| 1904 | } |
||
| 1905 | #else |
||
| 1906 | #define USBHostPrinterCommandWithReadyWait( returnCode, deviceAddress, command, data, size, flags ) \ |
||
| 1907 | { \ |
||
| 1908 | while (!USBHostPrinterCommandReady( deviceAddress )) USBTasks(); \ |
||
| 1909 | *(returnCode) = USBHostPrinterCommand( deviceAddress, command, data, size, flags ); \ |
||
| 1910 | } |
||
| 1911 | #endif |
||
| 1912 | |||
| 1913 | /**************************************************************************** |
||
| 1914 | Function: |
||
| 1915 | BOOL USBHostPrinterDeviceDetached( BYTE deviceAddress ) |
||
| 1916 | |||
| 1917 | Description: |
||
| 1918 | This interface is used to check if the device has been detached from the |
||
| 1919 | bus. |
||
| 1920 | |||
| 1921 | Preconditions: |
||
| 1922 | None |
||
| 1923 | |||
| 1924 | Parameters: |
||
| 1925 | BYTE deviceAddress - USB Address of the device. |
||
| 1926 | |||
| 1927 | Return Values: |
||
| 1928 | TRUE - The device has been detached, or an invalid deviceAddress is given. |
||
| 1929 | FALSE - The device is attached |
||
| 1930 | |||
| 1931 | Example: |
||
| 1932 | <code> |
||
| 1933 | if (USBHostPrinterDeviceDetached( deviceAddress )) |
||
| 1934 | { |
||
| 1935 | // Handle detach |
||
| 1936 | } |
||
| 1937 | </code> |
||
| 1938 | |||
| 1939 | Remarks: |
||
| 1940 | The event EVENT_PRINTER_DETACH can also be used to detect a detach. |
||
| 1941 | ***************************************************************************/ |
||
| 1942 | |||
| 1943 | BOOL USBHostPrinterDeviceDetached( BYTE deviceAddress ); |
||
| 1944 | |||
| 1945 | |||
| 1946 | /**************************************************************************** |
||
| 1947 | Function: |
||
| 1948 | DWORD USBHostPrinterGetRxLength( BYTE deviceAddress ) |
||
| 1949 | |||
| 1950 | Description: |
||
| 1951 | This function retrieves the number of bytes copied to user's buffer by |
||
| 1952 | the most recent call to the USBHostPrinterRead() function. |
||
| 1953 | |||
| 1954 | Preconditions: |
||
| 1955 | The device must be connected and enumerated. |
||
| 1956 | |||
| 1957 | Parameters: |
||
| 1958 | BYTE deviceAddress - USB Address of the device |
||
| 1959 | |||
| 1960 | Returns: |
||
| 1961 | Returns the number of bytes most recently received from the Printer |
||
| 1962 | device with address deviceAddress. |
||
| 1963 | |||
| 1964 | Remarks: |
||
| 1965 | None |
||
| 1966 | ***************************************************************************/ |
||
| 1967 | |||
| 1968 | DWORD USBHostPrinterGetRxLength( BYTE deviceAddress ); |
||
| 1969 | |||
| 1970 | |||
| 1971 | /**************************************************************************** |
||
| 1972 | Function: |
||
| 1973 | BYTE USBHostPrinterGetStatus( BYTE deviceAddress, BYTE *status ) |
||
| 1974 | |||
| 1975 | Summary: |
||
| 1976 | This function issues the Printer class-specific Device Request to |
||
| 1977 | obtain the printer status. |
||
| 1978 | |||
| 1979 | Description: |
||
| 1980 | This function issues the Printer class-specific Device Request to |
||
| 1981 | obtain the printer status. The returned status should have the following |
||
| 1982 | format, per the USB specification. Any deviation will be due to the |
||
| 1983 | specific printer implementation. |
||
| 1984 | * Bit 5 - Paper Empty; 1 = paper empty, 0 = paper not empty |
||
| 1985 | * Bit 4 - Select; 1 = selected, 0 = not selected |
||
| 1986 | * Bit 3 - Not Error; 1 = no error, 0 = error |
||
| 1987 | * All other bits are reserved. |
||
| 1988 | |||
| 1989 | The *status parameter is not updated until the EVENT_PRINTER_REQUEST_DONE |
||
| 1990 | event is thrown. Until that point the value of *status is unknown. |
||
| 1991 | |||
| 1992 | The *status parameter will only be updated if this function returns |
||
| 1993 | USB_SUCCESS. If this function returns with any other error code then the |
||
| 1994 | EVENT_PRINTER_REQUEST_DONE event will not be thrown and the status field |
||
| 1995 | will not be updated. |
||
| 1996 | |||
| 1997 | Preconditions: |
||
| 1998 | The device must be connected and enumerated. |
||
| 1999 | |||
| 2000 | Parameters: |
||
| 2001 | deviceAddress - USB Address of the device |
||
| 2002 | *status - pointer to the returned status byte |
||
| 2003 | |||
| 2004 | Returns: |
||
| 2005 | See the return values for the USBHostIssueDeviceRequest() function. |
||
| 2006 | |||
| 2007 | Remarks: |
||
| 2008 | None |
||
| 2009 | ***************************************************************************/ |
||
| 2010 | |||
| 2011 | BYTE USBHostPrinterGetStatus( BYTE deviceAddress, BYTE *status ); |
||
| 2012 | |||
| 2013 | |||
| 2014 | /**************************************************************************** |
||
| 2015 | Function: |
||
| 2016 | DWORD USBHostPrinterPosition( WORD X, WORD Y ) |
||
| 2017 | |||
| 2018 | Summary: |
||
| 2019 | This function is used to simplify the call to the printer command |
||
| 2020 | USB_PRINTER_SET_POSITION by generating the value needed for the specified |
||
| 2021 | (X,Y) coordinate. |
||
| 2022 | |||
| 2023 | Description: |
||
| 2024 | This function is used to simplify the call to the printer command |
||
| 2025 | USB_PRINTER_SET_POSITION by generating the value needed for the specified |
||
| 2026 | (X,Y) coordinate. The USB_PRINTER_SET_POSITION command requires that the |
||
| 2027 | (X,Y) coordinate be passed in the (DWORD) size parameter of the |
||
| 2028 | USBHostPrinterCommand() function. This function takes the specified |
||
| 2029 | coordinate and packs it in the DWORD as required. |
||
| 2030 | |||
| 2031 | Preconditions: |
||
| 2032 | None |
||
| 2033 | |||
| 2034 | Parameters: |
||
| 2035 | X - X coordinate (horizontal) |
||
| 2036 | Y - Y coordinate (vertical) |
||
| 2037 | |||
| 2038 | Returns: |
||
| 2039 | DWORD value that can be used in the USBHostPrinterCommand() function |
||
| 2040 | call with the command USB_PRINTER_SET_POSITION. |
||
| 2041 | |||
| 2042 | Example: |
||
| 2043 | <code> |
||
| 2044 | USBHostPrinterCommand( printer, USB_PRINTER_SET_POSITION, USB_NULL, |
||
| 2045 | USBHostPrinterPosition( 100, 100 ), 0 ); |
||
| 2046 | </code> |
||
| 2047 | |||
| 2048 | Remarks: |
||
| 2049 | None |
||
| 2050 | ***************************************************************************/ |
||
| 2051 | |||
| 2052 | #define USBHostPrinterPosition( X, Y ) (((DWORD)(X) << 16) | ((DWORD)(Y) & 0xFFFF)) |
||
| 2053 | |||
| 2054 | |||
| 2055 | /**************************************************************************** |
||
| 2056 | Function: |
||
| 2057 | DWORD USBHostPrinterPositionRelative( SHORT dX, SHORT dY ) |
||
| 2058 | |||
| 2059 | Summary: |
||
| 2060 | This function is used to simplify the call to some of the printer |
||
| 2061 | graphics commands by generating the value needed for the specified |
||
| 2062 | change in X and change in Y coordinates. |
||
| 2063 | |||
| 2064 | Description: |
||
| 2065 | This function is used to simplify the call to some of the printer |
||
| 2066 | graphics commands by generating the value needed for the specified |
||
| 2067 | change in X and change in Y coordinates. The |
||
| 2068 | USB_PRINTER_GRAPHICS_MOVE_RELATIVE and the |
||
| 2069 | USB_PRINTER_GRAPHICS_LINE_TO_RELATIVE commands requires that the |
||
| 2070 | change in the (X,Y) coordinates be passed in the (DWORD) size parameter |
||
| 2071 | of the USBHostPrinterCommand() function. This function takes the |
||
| 2072 | specified coordinate changes and packs them in the DWORD as required. |
||
| 2073 | |||
| 2074 | Preconditions: |
||
| 2075 | None |
||
| 2076 | |||
| 2077 | Parameters: |
||
| 2078 | dX - Change in the X coordinate (horizontal) |
||
| 2079 | dY - Change in the Y coordinate (vertical) |
||
| 2080 | |||
| 2081 | Returns: |
||
| 2082 | DWORD value that can be used in the USBHostPrinterCommand() function |
||
| 2083 | call with the commands USB_PRINTER_GRAPHICS_MOVE_RELATIVE and |
||
| 2084 | USB_PRINTER_GRAPHICS_LINE_TO_RELATIVE. |
||
| 2085 | |||
| 2086 | Example: |
||
| 2087 | <code> |
||
| 2088 | USBHostPrinterCommand( printer, USB_PRINTER_GRAPHICS_LINE_TO_RELATIVE, USB_NULL, |
||
| 2089 | USBHostPrinterPositionRelative( 0, -100 ), 0 ); |
||
| 2090 | </code> |
||
| 2091 | |||
| 2092 | Remarks: |
||
| 2093 | None |
||
| 2094 | ***************************************************************************/ |
||
| 2095 | |||
| 2096 | #define USBHostPrinterPositionRelative( dX, dY ) (((DWORD)(dX) << 16) | ((DWORD)(dY) & 0xFFFF)) |
||
| 2097 | |||
| 2098 | |||
| 2099 | /**************************************************************************** |
||
| 2100 | Function: |
||
| 2101 | BYTE USBHostPrinterRead( BYTE deviceAddress, BYTE *buffer, DWORD length, |
||
| 2102 | BYTE transferFlags ) |
||
| 2103 | |||
| 2104 | Description: |
||
| 2105 | Use this routine to receive from the device and store it into memory. |
||
| 2106 | |||
| 2107 | Preconditions: |
||
| 2108 | The device must be connected and enumerated. |
||
| 2109 | |||
| 2110 | Parameters: |
||
| 2111 | deviceAddress - USB Address of the device. |
||
| 2112 | buffer - Pointer to the data buffer |
||
| 2113 | length - Number of bytes to be transferred |
||
| 2114 | transferFlags - Flags for how to perform the operation |
||
| 2115 | |||
| 2116 | Return Values: |
||
| 2117 | USB_SUCCESS - The Read was started successfully |
||
| 2118 | (USB error code) - The Read was not started. See USBHostRead() for |
||
| 2119 | a list of errors. |
||
| 2120 | |||
| 2121 | Example: |
||
| 2122 | <code> |
||
| 2123 | if (!USBHostPrinterRxIsBusy( deviceAddress )) |
||
| 2124 | { |
||
| 2125 | USBHostPrinterRead( deviceAddress, &buffer, sizeof(buffer), 0 ); |
||
| 2126 | } |
||
| 2127 | </code> |
||
| 2128 | |||
| 2129 | Remarks: |
||
| 2130 | None |
||
| 2131 | ***************************************************************************/ |
||
| 2132 | |||
| 2133 | BYTE USBHostPrinterRead( BYTE deviceAddress, void *buffer, DWORD length, |
||
| 2134 | BYTE transferFlags ); |
||
| 2135 | |||
| 2136 | |||
| 2137 | /**************************************************************************** |
||
| 2138 | Function: |
||
| 2139 | BYTE USBHostPrinterReset( BYTE deviceAddress ) |
||
| 2140 | |||
| 2141 | Description: |
||
| 2142 | This function issues the Printer class-specific Device Request to |
||
| 2143 | perform a soft reset. |
||
| 2144 | |||
| 2145 | Preconditions: |
||
| 2146 | The device must be connected and enumerated. |
||
| 2147 | |||
| 2148 | Parameters: |
||
| 2149 | BYTE deviceAddress - USB Address of the device |
||
| 2150 | |||
| 2151 | Returns: |
||
| 2152 | See the return values for the USBHostIssueDeviceRequest() function. |
||
| 2153 | |||
| 2154 | Remarks: |
||
| 2155 | Not all printers support this command. |
||
| 2156 | ***************************************************************************/ |
||
| 2157 | |||
| 2158 | BYTE USBHostPrinterReset( BYTE deviceAddress ); |
||
| 2159 | |||
| 2160 | /**************************************************************************** |
||
| 2161 | Function: |
||
| 2162 | BOOL USBHostPrinterRxIsBusy( BYTE deviceAddress ) |
||
| 2163 | |||
| 2164 | Summary: |
||
| 2165 | This interface is used to check if the client driver is currently busy |
||
| 2166 | receiving data from the device. |
||
| 2167 | |||
| 2168 | Description: |
||
| 2169 | This interface is used to check if the client driver is currently busy |
||
| 2170 | receiving data from the device. |
||
| 2171 | |||
| 2172 | Preconditions: |
||
| 2173 | None |
||
| 2174 | |||
| 2175 | Parameters: |
||
| 2176 | deviceAddress - USB Address of the device |
||
| 2177 | |||
| 2178 | Return Values: |
||
| 2179 | TRUE - The device is receiving data or an invalid deviceAddress is |
||
| 2180 | given. |
||
| 2181 | FALSE - The device is not receiving data |
||
| 2182 | |||
| 2183 | Example: |
||
| 2184 | <code> |
||
| 2185 | if (!USBHostPrinterRxIsBusy( deviceAddress )) |
||
| 2186 | { |
||
| 2187 | USBHostPrinterRead( deviceAddress, &buffer, sizeof( buffer ) ); |
||
| 2188 | } |
||
| 2189 | </code> |
||
| 2190 | |||
| 2191 | Remarks: |
||
| 2192 | None |
||
| 2193 | ***************************************************************************/ |
||
| 2194 | |||
| 2195 | BOOL USBHostPrinterRxIsBusy( BYTE deviceAddress ); |
||
| 2196 | |||
| 2197 | |||
| 2198 | /**************************************************************************** |
||
| 2199 | Function: |
||
| 2200 | BYTE USBHostPrinterWrite( BYTE deviceAddress, void *buffer, DWORD length, |
||
| 2201 | BYTE transferFlags ) |
||
| 2202 | |||
| 2203 | Description: |
||
| 2204 | Use this routine to transmit data from memory to the device. This |
||
| 2205 | routine will not usually be called by the application directly. The |
||
| 2206 | application will use the USBHostPrinterCommand() function, which will |
||
| 2207 | call the appropriate printer language support function, which will |
||
| 2208 | utilize this routine. |
||
| 2209 | |||
| 2210 | Preconditions: |
||
| 2211 | The device must be connected and enumerated. |
||
| 2212 | |||
| 2213 | Parameters: |
||
| 2214 | BYTE deviceAddress - USB Address of the device. |
||
| 2215 | void *buffer - Pointer to the data buffer |
||
| 2216 | DWORD length - Number of bytes to be transferred |
||
| 2217 | BYTE transferFlags - Flags for how to perform the operation |
||
| 2218 | |||
| 2219 | Return Values: |
||
| 2220 | USB_SUCCESS - The Write was started successfully. |
||
| 2221 | USB_PRINTER_UNKNOWN_DEVICE - Device not found or has not been initialized. |
||
| 2222 | USB_PRINTER_BUSY - The printer's output queue is full. |
||
| 2223 | (USB error code) - The Write was not started. See USBHostWrite() for |
||
| 2224 | a list of errors. |
||
| 2225 | |||
| 2226 | Remarks: |
||
| 2227 | None |
||
| 2228 | ***************************************************************************/ |
||
| 2229 | |||
| 2230 | BYTE USBHostPrinterWrite( BYTE deviceAddress, void *buffer, DWORD length, |
||
| 2231 | BYTE flags); |
||
| 2232 | |||
| 2233 | |||
| 2234 | /**************************************************************************** |
||
| 2235 | Function: |
||
| 2236 | BOOL USBHostPrinterWriteComplete( BYTE deviceAddress ) |
||
| 2237 | |||
| 2238 | Description: |
||
| 2239 | This interface is used to check if the client driver is currently |
||
| 2240 | transmitting data to the printer, or if it is between transfers but still |
||
| 2241 | has transfers queued. |
||
| 2242 | |||
| 2243 | Preconditions: |
||
| 2244 | None |
||
| 2245 | |||
| 2246 | Parameters: |
||
| 2247 | deviceAddress - USB Address of the device |
||
| 2248 | |||
| 2249 | Return Values: |
||
| 2250 | TRUE - The device is done transmitting data or an invalid deviceAddress |
||
| 2251 | is given. |
||
| 2252 | FALSE - The device is transmitting data or has a transfer in the queue. |
||
| 2253 | |||
| 2254 | Remarks: |
||
| 2255 | None |
||
| 2256 | ***************************************************************************/ |
||
| 2257 | |||
| 2258 | BOOL USBHostPrinterWriteComplete( BYTE deviceAddress ); |
||
| 2259 | |||
| 2260 | |||
| 2261 | |||
| 2262 | /************************************************************************* |
||
| 2263 | * EOF usb_client_generic.h |
||
| 2264 | */ |
||
| 2265 | |||
| 2266 | #endif |
Powered by WebSVN v2.8.3