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; }
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; }
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_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 /* Initialize mass storage support */ 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 UNUSED(ret); /* Then get an instance of the USB host interface */ syslog(LOG_INFO, "Initialize USB host\n"); g_usbconn = lpc17_usbhost_initialize(0); if (g_usbconn) { /* Start a thread to handle device connection. */ syslog(LOG_ERR, "ERROR: Start nsh_waiter\n"); pid = task_create("usbhost", CONFIG_LPC1766STK_USBHOST_PRIO, CONFIG_LPC1766STK_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } return -ENODEV; }
int stm32_usbhost_initialize(void) { int rv; #ifdef CONFIG_USBHOST_MSC uinfo("INFO: Initializing USB MSC class\n"); if ((rv = usbhost_msc_initialize()) < 0) { uerr("ERROR: Failed to register mass storage class: %d\n", rv); } #endif #ifdef CONFIG_USBHOST_CDACM uinfo("INFO: Initializing CDCACM usb class\n"); if ((rv = usbhost_cdacm_initialize()) < 0) { uerr("ERROR: Failed to register CDC/ACM serial class: %d\n", rv); } #endif #ifdef CONFIG_USBHOST_HIDKBD uinfo("INFO: Initializing HID Keyboard usb class\n"); if ((rv = usbhost_kbdinit()) < 0) { uerr("ERROR: Failed to register the KBD class: %d\n", rv); } #endif #ifdef CONFIG_USBHOST_HIDMOUSE uinfo("INFO: Initializing HID Mouse usb class\n"); if ((rv = usbhost_mouse_init()) < 0) { uerr("ERROR: Failed to register the mouse class: %d\n", rv); } #endif #ifdef CONFIG_USBHOST_HUB uinfo("INFO: Initializing USB HUB class\n"); if ((rv = usbhost_hub_initialize()) < 0) { uerr("ERROR: Failed to register hub class: %d\n", rv); } #endif if ((g_usbconn = stm32_otgfshost_initialize(0))) { pthread_attr_t pattr; struct sched_param schparam; pthread_attr_init(&pattr); pthread_attr_setstacksize(&pattr, 2048); schparam.sched_priority = 50; pthread_attr_setschedparam(&pattr, &schparam); return pthread_create(NULL, &pattr, usbhost_detect, NULL); } return -ENODEV; }