usbhost.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * File : usbhost.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-12-12 Yi Qiu first version
  13. */
  14. #include <rtthread.h>
  15. #include <drivers/usb_host.h>
  16. #if defined(RT_USB_HID_KEYBOARD) || defined(RT_USB_HID_MOUSE)
  17. #include <hid.h>
  18. #endif
  19. /**
  20. * This function will initialize the usb host stack, all the usb class driver and
  21. * host controller driver are also be initialized here.
  22. *
  23. * @return none.
  24. */
  25. void rt_usb_host_init(void)
  26. {
  27. ucd_t drv;
  28. #ifdef RT_USB_CLASS_HID
  29. uprotocal_t protocal;
  30. #endif
  31. /* initialize usb hub thread */
  32. rt_usb_hub_thread();
  33. /* initialize class driver */
  34. rt_usb_class_driver_init();
  35. #ifdef RT_USB_CLASS_MASS_STORAGE
  36. /* register mass storage class driver */
  37. drv = rt_usb_class_driver_storage();
  38. rt_usb_class_driver_register(drv);
  39. #endif
  40. #ifdef RT_USB_CLASS_HID
  41. /* register hid class driver */
  42. drv = rt_usb_class_driver_hid();
  43. rt_usb_class_driver_register(drv);
  44. #ifdef RT_USB_HID_KEYBOARD
  45. /* register hid keyboard protocal */
  46. protocal = rt_usb_hid_protocal_kbd();
  47. rt_usb_hid_protocal_register(protocal);
  48. #endif
  49. #ifdef RT_USB_HID_MOUSE
  50. /* register hid mouse protocal */
  51. protocal = rt_usb_hid_protocal_mouse();
  52. rt_usb_hid_protocal_register(protocal);
  53. #endif
  54. #endif
  55. #ifdef RT_USB_CLASS_ADK
  56. /* register adk class driver */
  57. drv = rt_usb_class_driver_adk();
  58. rt_usb_class_driver_register(drv);
  59. #endif
  60. /* register hub class driver */
  61. drv = rt_usb_class_driver_hub();
  62. rt_usb_class_driver_register(drv);
  63. }
  64. INIT_COMPONENT_EXPORT(rt_usb_host_init);