int sam_usbhost_initialize(void) { pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers * that we care about: */ ret = usbhost_storageinit(); if (ret != OK) { udbg("ERROR: Failed to register the mass storage class: %d\n", ret); } #ifdef CONFIG_SAMA5_OHCI /* Get an instance of the USB OHCI interface */ g_ohciconn = sam_ohci_initialize(0); if (!g_ohciconn) { udbg("ERROR: sam_ohci_initialize failed\n"); return -ENODEV; } /* Start a thread to handle device connection. */ pid = TASK_CREATE("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { udbg("ERROR: Failed to create ohci_waiter task: %d\n", ret); return -ENODEV; } #endif #ifdef CONFIG_SAMA5_EHCI /* Get an instance of the USB EHCI interface */ g_ehciconn = sam_ehci_initialize(0); if (!g_ehciconn) { udbg("ERROR: sam_ehci_initialize failed\n"); return -ENODEV; } /* Start a thread to handle device connection. */ pid = TASK_CREATE("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { udbg("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; } #endif return OK; }
int sam_usbhost_initialize(void) { pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers * that we care about */ #ifdef CONFIG_USBHOST_HUB /* Initialize USB hub class support */ ret = usbhost_hub_initialize(); if (ret < 0) { uerr("ERROR: usbhost_hub_initialize failed: %d\n", ret); } #endif #ifdef CONFIG_USBHOST_MSC /* Register theUSB host Mass Storage Class */ ret = usbhost_msc_initialize(); if (ret != OK) { uerr("ERROR: Failed to register the mass storage class: %d\n", ret); } #endif #ifdef CONFIG_USBHOST_CDCACM /* Register the CDC/ACM serial class */ ret = usbhost_cdcacm_initialize(); if (ret != OK) { uerr("ERROR: Failed to register the CDC/ACM serial class: %d\n", ret); } #endif #ifdef CONFIG_USBHOST_HIDKBD /* Register the USB host HID keyboard class driver */ ret = usbhost_kbdinit(); if (ret != OK) { uerr("ERROR: Failed to register the KBD class\n"); } #endif /* Then get an instance of the USB host interface. */ #ifdef CONFIG_SAMA5_OHCI /* Get an instance of the USB OHCI interface */ g_ohciconn = sam_ohci_initialize(0); if (!g_ohciconn) { uerr("ERROR: sam_ohci_initialize failed\n"); return -ENODEV; } /* Start a thread to handle device connection. */ pid = task_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); return -ENODEV; } #endif #ifdef CONFIG_SAMA5_EHCI /* Get an instance of the USB EHCI interface */ g_ehciconn = sam_ehci_initialize(0); if (!g_ehciconn) { uerr("ERROR: sam_ehci_initialize failed\n"); return -ENODEV; } /* Start a thread to handle device connection. */ pid = task_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; } #endif return OK; }