usb.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * usb.h
  3. *
  4. * USB stack entry points and callbacks.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. /* Max Packet Size */
  12. #define USB_FS_MPS 64
  13. #define USB_HS_MPS 512
  14. extern unsigned int usb_bulk_mps;
  15. /* Class-specific callback hooks */
  16. struct usb_class_ops {
  17. void (*reset)(void);
  18. void (*configure)(void);
  19. };
  20. extern const struct usb_class_ops usb_cdc_acm_ops;
  21. /* USB Endpoints for CDC ACM communications. */
  22. #define EP_RX 2
  23. #define EP_TX 3
  24. /* Main entry points for USB processing. */
  25. void usb_init(void);
  26. void usb_deinit(void);
  27. void usb_process(void);
  28. /* Does OUT endpoint have data ready? If so return packet length, else -1. */
  29. int ep_rx_ready(uint8_t ep);
  30. /* Consume the next OUT packet, returning @len bytes.
  31. * REQUIRES: ep_rx_ready(@ep) >= @len */
  32. void usb_read(uint8_t ep, void *buf, uint32_t len);
  33. /* Is IN endpoint ready for next packet? */
  34. bool_t ep_tx_ready(uint8_t ep);
  35. /* Queue the next IN packet, with the given payload data.
  36. * REQUIRES: ep_tx_ready(@ep) == TRUE */
  37. void usb_write(uint8_t ep, const void *buf, uint32_t len);
  38. /* Is the USB enumerated at High Speed? */
  39. bool_t usb_is_highspeed(void);
  40. /*
  41. * Local variables:
  42. * mode: C
  43. * c-file-style: "Linux"
  44. * c-basic-offset: 4
  45. * tab-width: 4
  46. * indent-tabs-mode: nil
  47. * End:
  48. */