usb.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /* Full Speed Max Packet Size */
  12. #define USB_FS_MPS 64
  13. /* Class-specific callback hooks */
  14. struct usb_class_ops {
  15. void (*reset)(void);
  16. void (*configure)(void);
  17. };
  18. extern const struct usb_class_ops usb_cdc_acm_ops;
  19. /* USB Endpoints for CDC ACM communications. */
  20. #define EP_RX 2
  21. #define EP_TX 3
  22. /* Main entry points for USB processing. */
  23. void usb_init(void);
  24. void usb_process(void);
  25. /* Does OUT endpoint have data ready? If so return packet length, else -1. */
  26. int ep_rx_ready(uint8_t ep);
  27. /* Consume the next OUT packet, returning @len bytes.
  28. * REQUIRES: ep_rx_ready(@ep) >= @len */
  29. void usb_read(uint8_t ep, void *buf, uint32_t len);
  30. /* Is IN endpoint ready for next packet? */
  31. bool_t ep_tx_ready(uint8_t ep);
  32. /* Queue the next IN packet, with the given payload data.
  33. * REQUIRES: ep_tx_ready(@ep) == TRUE */
  34. void usb_write(uint8_t ep, const void *buf, uint32_t len);
  35. /*
  36. * Local variables:
  37. * mode: C
  38. * c-file-style: "Linux"
  39. * c-basic-offset: 4
  40. * tab-width: 4
  41. * indent-tabs-mode: nil
  42. * End:
  43. */