int stm32_usbhost_initialize(void) { int pid; int ret; /* First, register all of the class drivers needed to support the drivers * that we care about: */ uvdbg("Register class drivers\n"); #ifdef CONFIG_USBHOST_HUB /* Initialize USB hub class support */ ret = usbhost_hub_initialize(); if (ret < 0) { udbg("ERROR: usbhost_hub_initialize failed: %d\n", ret); } #endif #ifdef CONFIG_USBHOST_MSC /* Register the USB mass storage class class */ ret = usbhost_msc_initialize(); if (ret != OK) { udbg("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) { udbg("ERROR: Failed to register the CDC/ACM serial class: %d\n", ret); } #endif /* Then get an instance of the USB host interface */ uvdbg("Initialize USB host\n"); g_usbconn = stm32_otghshost_initialize(0); if (g_usbconn) { /* Start a thread to handle device connection. */ uvdbg("Start usbhost_waiter\n"); pid = task_create("usbhost", CONFIG_STM32F429IDISCO_USBHOST_PRIO, CONFIG_STM32F429IDISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } return -ENODEV; }
static int nsh_usbhostinitialize(void) { int pid; int ret; /* First, register all of the class drivers needed to support the drivers * that we care about: */ syslog(LOG_INFO, "Register class drivers\n"); #ifdef CONFIG_USBHOST_MSC /* Register the USB mass storage class class */ ret = usbhost_msc_initialize(); if (ret != OK) { syslog(LOG_ERR, "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) { syslog(LOG_ERR, "ERROR: Failed to register the CDC/ACM serial class: %d\n", ret); } #endif /* Then get an instance of the USB host interface */ syslog(LOG_INFO, "Initialize USB host\n"); g_usbconn = pic32_usbhost_initialize(0); if (g_usbconn) { /* Start a thread to handle device connection. */ syslog(LOG_INFO, "Start nsh_waiter\n"); pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } return -ENODEV; }
int lpc31_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 support */ ret = usbhost_hub_initialize(); if (ret < 0) { syslog(LOG_ERR, "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\n"); } #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 EHCI interface. */ g_ehciconn = lpc31_ehci_initialize(0); if (!g_ehciconn) { uerr("ERROR: lpc31_ehci_initialize failed\n"); return -ENODEV; } /* Start a thread to handle device connection. */ pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_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; } return OK; }