1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2011-12-12 Yi Qiu first version 9 */ 10 #include <rtthread.h> 11 #include <drivers/usb_host.h> 12 13 #define USB_HOST_CONTROLLER_NAME "usbh" 14 15 #if defined(RT_USBH_HID_KEYBOARD) || defined(RT_USBH_HID_MOUSE) 16 #include <hid.h> 17 #endif 18 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 */ rt_usb_host_init(void)25rt_err_t rt_usb_host_init(void) 26 { 27 ucd_t drv; 28 rt_device_t uhc; 29 30 uhc = rt_device_find(USB_HOST_CONTROLLER_NAME); 31 if(uhc == RT_NULL) 32 { 33 rt_kprintf("can't find usb host controller %s\n", USB_HOST_CONTROLLER_NAME); 34 return -RT_ERROR; 35 } 36 37 /* initialize usb hub */ 38 rt_usbh_hub_init((uhcd_t)uhc); 39 40 /* initialize class driver */ 41 rt_usbh_class_driver_init(); 42 43 #ifdef RT_USBH_MSTORAGE 44 /* register mass storage class driver */ 45 drv = rt_usbh_class_driver_storage(); 46 rt_usbh_class_driver_register(drv); 47 #endif 48 49 /* register hub class driver */ 50 drv = rt_usbh_class_driver_hub(); 51 rt_usbh_class_driver_register(drv); 52 53 /* initialize usb host controller */ 54 rt_device_init(uhc); 55 56 return RT_EOK; 57 } 58 59