usbhost.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * File : usbhost.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-12-12 Yi Qiu first version
  23. */
  24. #include <rtthread.h>
  25. #include <drivers/usb_host.h>
  26. #if defined(RT_USB_HID_KEYBOARD) || defined(RT_USB_HID_MOUSE)
  27. #include <hid.h>
  28. #endif
  29. /**
  30. * This function will initialize the usb host stack, all the usb class driver and
  31. * host controller driver are also be initialized here.
  32. *
  33. * @return none.
  34. */
  35. int rt_usb_host_init(void)
  36. {
  37. ucd_t drv;
  38. #ifdef RT_USB_CLASS_HID
  39. uprotocal_t protocal;
  40. #endif
  41. /* initialize usb hub thread */
  42. rt_usb_hub_thread();
  43. /* initialize class driver */
  44. rt_usb_class_driver_init();
  45. #ifdef RT_USB_CLASS_MASS_STORAGE
  46. /* register mass storage class driver */
  47. drv = rt_usb_class_driver_storage();
  48. rt_usb_class_driver_register(drv);
  49. #endif
  50. #ifdef RT_USB_CLASS_HID
  51. /* register hid class driver */
  52. drv = rt_usb_class_driver_hid();
  53. rt_usb_class_driver_register(drv);
  54. #ifdef RT_USB_HID_KEYBOARD
  55. /* register hid keyboard protocal */
  56. protocal = rt_usb_hid_protocal_kbd();
  57. rt_usb_hid_protocal_register(protocal);
  58. #endif
  59. #ifdef RT_USB_HID_MOUSE
  60. /* register hid mouse protocal */
  61. protocal = rt_usb_hid_protocal_mouse();
  62. rt_usb_hid_protocal_register(protocal);
  63. #endif
  64. #endif
  65. #ifdef RT_USB_CLASS_ADK
  66. /* register adk class driver */
  67. drv = rt_usb_class_driver_adk();
  68. rt_usb_class_driver_register(drv);
  69. #endif
  70. /* register hub class driver */
  71. drv = rt_usb_class_driver_hub();
  72. rt_usb_class_driver_register(drv);
  73. return 0;
  74. }
  75. INIT_COMPONENT_EXPORT(rt_usb_host_init);