printer_class.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. **************************************************************************
  3. * @file printer_class.h
  4. * @version v2.0.6
  5. * @date 2021-12-31
  6. * @brief usb printer class file
  7. **************************************************************************
  8. * Copyright notice & Disclaimer
  9. *
  10. * The software Board Support Package (BSP) that is made available to
  11. * download from Artery official website is the copyrighted work of Artery.
  12. * Artery authorizes customers to use, copy, and distribute the BSP
  13. * software and its related documentation for the purpose of design and
  14. * development in conjunction with Artery microcontrollers. Use of the
  15. * software is governed by this copyright notice and the following disclaimer.
  16. *
  17. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  18. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  19. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  20. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  21. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  23. *
  24. **************************************************************************
  25. */
  26. /* define to prevent recursive inclusion -------------------------------------*/
  27. #ifndef __PRINTER_CLASS_H
  28. #define __PRINTER_CLASS_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include "usb_std.h"
  33. #include "usbd_core.h"
  34. /** @addtogroup AT32F403A_407_middlewares_usbd_class
  35. * @{
  36. */
  37. /** @addtogroup USB_printer_class
  38. * @{
  39. */
  40. /** @defgroup USB_printer_class_definition
  41. * @{
  42. */
  43. #define USBD_PRINTER_BULK_IN_EPT 0x81
  44. #define USBD_PRINTER_BULK_OUT_EPT 0x01
  45. #define USBD_IN_MAXPACKET_SIZE 0x40
  46. #define USBD_OUT_MAXPACKET_SIZE 0x40
  47. #define PRINTER_DEVICE_ID_LEN 24
  48. typedef enum
  49. {
  50. PRINTER_REQ_GET_DEVICE_ID = 0x00,
  51. PRINTER_REQ_GET_PORT_STATUS = 0x01,
  52. PRINTER_REQ_GET_SOFT_RESET = 0x02
  53. }printer_req_type;
  54. #define SET_LINE_CODING 0x20
  55. #define GET_LINE_CODING 0x21
  56. typedef struct
  57. {
  58. uint32_t bitrate;
  59. uint8_t format;
  60. uint8_t parity;
  61. uint8_t data;
  62. }linecoding_type;
  63. extern usbd_class_handler printer_class_handler;
  64. uint16_t usb_printer_get_rxdata(void *udev, uint8_t *recv_data);
  65. error_status usb_printer_send_data(void *udev, uint8_t *send_data, uint16_t len);
  66. /**
  67. * @}
  68. */
  69. /**
  70. * @}
  71. */
  72. /**
  73. * @}
  74. */
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif