summaryrefslogtreecommitdiff
path: root/src/class/printer/printer.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-03-06 15:11:59 +0700
committerhathach <[email protected]>2026-03-06 15:11:59 +0700
commit5838c7f09dda8921fe6f350871211f8bd5a97208 (patch)
treecb2df6d43128316051842860e3ef1468fbbc489c /src/class/printer/printer.h
parent558abb93af64eda51420d5bfe03355c89e4b421a (diff)
update printer class: enhance descriptors, buffer sizes, and callbacks
Diffstat (limited to 'src/class/printer/printer.h')
-rw-r--r--src/class/printer/printer.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/class/printer/printer.h b/src/class/printer/printer.h
index c9ed3cebc..b32543077 100644
--- a/src/class/printer/printer.h
+++ b/src/class/printer/printer.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_PRINTER_H_
-#define _TUSB_PRINTER_H_
+#ifndef TUSB_PRINTER_H_
+#define TUSB_PRINTER_H_
#include "common/tusb_common.h"
@@ -35,13 +35,28 @@ extern "C" {
/// Printer Class Specific Control Request
typedef enum {
- PRINTER_REQ_CONTROL_GET_DEVICE_ID = 0x01, ///< Get device ID
- PRINTER_REQ_CONTROL_GET_PORT_STATUS = 0x02, ///< Get port status
- PRINTER_REQ_CONTROL_SOFT_RESET = 0x03, ///< Soft reset
-} printer_request_enum_t;
+ TUSB_PRINTER_REQUEST_GET_DEVICE_ID = 0x01, ///< Get device ID
+ TUSB_PRINTER_REQUEST_GET_PORT_STATUS = 0x02, ///< Get port status
+ TUSB_PRINTER_REQUEST_SOFT_RESET = 0x03, ///< Soft reset
+} tusb_printer_request_type_t;
+
+/// Printer Port Status (returned by GET_PORT_STATUS request)
+/// USB Printer Class spec 1.1, Section 4.2
+typedef union TU_ATTR_PACKED {
+ uint8_t status;
+ struct TU_ATTR_PACKED {
+ uint8_t reserved0 : 3; ///< Reserved (bits 0-2)
+ uint8_t not_error : 1; ///< 1 = no error, 0 = error
+ uint8_t selected : 1; ///< 1 = selected (online), 0 = not selected
+ uint8_t paper_empty : 1; ///< 1 = paper empty, 0 = paper not empty
+ uint8_t reserved6 : 2; ///< Reserved (bits 6-7)
+ } status_bm;
+} tusb_printer_port_status_t;
+
+TU_VERIFY_STATIC(sizeof(tusb_printer_port_status_t) == 1, "size is not correct");
#ifdef __cplusplus
}
#endif
-#endif /* _TUSB_PRINTER_H__ */
+#endif