/*
 * Init
 */
static int __init usb_init(void)
{
	int retval;
	if (nousb) {
		pr_info ("%s: USB support disabled\n", usbcore_name);
		return 0;
	}
	//总线对象注册
	retval = bus_register(&usb_bus_type);
	if (retval) 
		goto out;
	//usb-host
	retval = usb_host_init();
	if (retval)
		goto host_init_failed;
	retval = usb_major_init();
	if (retval)
		goto major_init_failed;
	//usbfs注册
	retval = usb_register(&usbfs_driver);
	if (retval)
		goto driver_register_failed;
	retval = usbdev_init();
	if (retval)
		goto usbdevice_init_failed;
	retval = usbfs_init();
	if (retval)
		goto fs_init_failed;
	//初始化hub模块:注册hub驱动、创建hub端口检测线程
	retval = usb_hub_init();
	if (retval)
		goto hub_init_failed;
	retval = driver_register(&usb_generic_driver);
	if (!retval)
		goto out;

	usb_hub_cleanup();
hub_init_failed:
	usbfs_cleanup();
fs_init_failed:
	usbdev_cleanup();
usbdevice_init_failed:
	usb_deregister(&usbfs_driver);
driver_register_failed:
	usb_major_cleanup();
major_init_failed:
	usb_host_cleanup();
host_init_failed:
	bus_unregister(&usb_bus_type);
out:
	return retval;
}
Example #2
0
int main(void)
{
    /* Bring up processor */
	cpu_init();
    watchdog_init();

#ifdef CONFIG_HW_LED_ALIVE_CHECK
    /* Bring up low level LED */
    hw_led_init();
#endif
#ifdef CONFIG_HW_UART
    /* Bring up low level hardware UART */
    hw_uart_init();
#endif
    /* Setup timer for tick counting */
    tick_init();

    /* Bring up high level LED */
    led_init();

    /* Bring up console */
    console_init();

#ifdef CONFIG_DEBUG_RESET_REASON
    /* Report reason for last reset */
    console_puts_P(PSTR("Reset cause:"));
    console_puthex8(MCUSR);
    console_newline();
#endif

    /* Set default LED pattern */
    led_set_seq(LED_SEQ_SINE);

#ifdef CONFIG_USBDEV
    usbdev_init(USBMODE_DEFAULT);
#endif

    /* HiZ bus mode selected by default */
    bus_init(&bus_hiz);

    /* Enable interrupts */
    cpu_enable_int();

    while(1)
	{
        driver_tick();
	}
}
Example #3
0
void uos_init (void)
{
    extern unsigned __bss_end[], _estack[];

    debug_printf ("=============== TEST-HID ================\n");	
	
    mem_init (&pool, (unsigned) __bss_end, (unsigned) _estack - 256);
	
    timer_init (&timer, KHZ, 128);

    usbdev_init (&usb, &pool, &device_descriptor);
    usbdev_add_config_desc (&usb, &config_descriptor);
    usbdev_set_string_table (&usb, usb_strings);
    
    hiddev_init (&hid, &usb, 0, config_descriptor.ep.bEndpointAddress, &pool, &usb_lock);
    hiddev_set_report_desc (&hid, 0, mouse_report, sizeof (mouse_report), 3, 0, 0);
    //hiddev_output_report (&hid, 0, out_rep);
    
    mldr_usbdev_init (&usb, 10, &pool, &usb_lock);
    task_create (task, "task", "task", 1, task_space, sizeof (task_space));
}
Example #4
0
void uos_init (void)
{
    extern unsigned __bss_end[], _estack[];

    debug_printf ("=============== TEST-HID ================\n");	
	
    mem_init (&pool, (unsigned) __bss_end, (unsigned) _estack - 256);
	
    timer_init (&timer, KHZ, 128);

    usbdev_init (&usb, &pool, &device_descriptor);
    usbdev_add_config_desc (&usb, &config_descriptor);
    usbdev_set_string_table (&usb, usb_strings);
    
    hiddev_init (&hid, &usb, 0, config_descriptor.ep.bEndpointAddress, &pool, &usb_lock);
    hiddev_set_report_desc (&hid, 0, mouse_report, sizeof (mouse_report), 3, 0, 0);
    //hiddev_output_report (&hid, 0, out_rep);
    
    spim_init(&spi, SPI_NUM, SPI_MOSI_OUT | SPI_SS0_OUT | SPI_SS1_OUT | SPI_SS0_OUT | SPI_TSCK_OUT);
    max3421e_usbdev_init(&usb, (spimif_t *)&spi, SPI_FREQUENCY, SPI_CS, USB_IRQ, 10, &pool, &usb_lock);
    
    task_create (task, "task", "task", 1, task_space, sizeof (task_space));
}