usb.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2008 Travis Geiselbrecht
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files
  6. * (the "Software"), to deal in the Software without restriction,
  7. * including without limitation the rights to use, copy, modify, merge,
  8. * publish, distribute, sublicense, and/or sell copies of the Software,
  9. * and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef __DEV_USB_H
  24. #define __DEV_USB_H
  25. #include <sys/types.h>
  26. #include <compiler.h>
  27. /* top level initialization for usb client, abstracts away the interfaces */
  28. typedef struct {
  29. void *desc;
  30. size_t len;
  31. } usb_descriptor __ALIGNED(2);
  32. typedef struct {
  33. usb_descriptor string;
  34. uint8_t id;
  35. } usb_string;
  36. /* complete usb config struct, passed in to usb_setup() */
  37. typedef struct {
  38. struct usb_descriptor_speed {
  39. usb_descriptor device;
  40. usb_descriptor device_qual;
  41. usb_descriptor config;
  42. } lowspeed, highspeed;
  43. usb_descriptor langid;
  44. } usb_config;
  45. void usb_init(void);
  46. /* external code needs to set up the usb stack via the following calls */
  47. void usb_setup(usb_config *config);
  48. /* apped new interface descriptors to the existing config if desired */
  49. int usb_append_interface_highspeed(const uint8_t *int_descr, size_t len);
  50. int usb_append_interface_lowspeed(const uint8_t *int_descr, size_t len);
  51. void usb_add_string(const char *string, uint8_t id);
  52. void usb_start(void);
  53. void usb_stop(void);
  54. #endif