usb.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_deinit(void);
  25. void usb_process(void);
  26. /* Does OUT endpoint have data ready? If so return packet length, else -1. */
  27. int ep_rx_ready(uint8_t ep);
  28. /* Consume the next OUT packet, returning @len bytes.
  29. * REQUIRES: ep_rx_ready(@ep) >= @len */
  30. void usb_read(uint8_t ep, void *buf, uint32_t len);
  31. /* Is IN endpoint ready for next packet? */
  32. bool_t ep_tx_ready(uint8_t ep);
  33. /* Queue the next IN packet, with the given payload data.
  34. * REQUIRES: ep_tx_ready(@ep) == TRUE */
  35. void usb_write(uint8_t ep, const void *buf, uint32_t len);
  36. /*
  37. * Local variables:
  38. * mode: C
  39. * c-file-style: "Linux"
  40. * c-basic-offset: 4
  41. * tab-width: 4
  42. * indent-tabs-mode: nil
  43. * End:
  44. */