usbd_printer.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2022, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "usbd_core.h"
  7. #include "usbd_printer.h"
  8. struct printer_cfg_priv {
  9. uint8_t *device_id;
  10. uint8_t port_status;
  11. } usbd_printer_cfg;
  12. static int printer_class_interface_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
  13. {
  14. USB_LOG_DBG("Printer Class request: "
  15. "bRequest 0x%02x\r\n",
  16. setup->bRequest);
  17. switch (setup->bRequest) {
  18. case PRINTER_REQUEST_GET_DEVICE_ID:
  19. break;
  20. case PRINTER_REQUEST_GET_PORT_SATTUS:
  21. break;
  22. case PRINTER_REQUEST_SOFT_RESET:
  23. break;
  24. default:
  25. USB_LOG_WRN("Unhandled Printer Class bRequest 0x%02x\r\n", setup->bRequest);
  26. return -1;
  27. }
  28. return 0;
  29. }
  30. static void printer_notify_handler(uint8_t event, void *arg)
  31. {
  32. switch (event) {
  33. case USBD_EVENT_RESET:
  34. break;
  35. default:
  36. break;
  37. }
  38. }
  39. struct usbd_interface *usbd_printer_alloc_intf(void)
  40. {
  41. struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
  42. if (intf == NULL) {
  43. USB_LOG_ERR("no mem to alloc intf\r\n");
  44. return NULL;
  45. }
  46. intf->class_interface_handler = printer_class_interface_request_handler;
  47. intf->class_endpoint_handler = NULL;
  48. intf->vendor_handler = NULL;
  49. intf->notify_handler = printer_notify_handler;
  50. return intf;
  51. }