Beispiel #1
0
int usb_device_create_ddf(ddf_dev_t *ddf_dev,
    const usb_endpoint_description_t **desc, const char **err)
{
	assert(ddf_dev);
	assert(err);

	devman_handle_t h = 0;
	int iface_no = -1;

	async_sess_t *sess = devman_parent_device_connect(
	    ddf_dev_get_handle(ddf_dev), IPC_FLAG_BLOCKING);
	if (sess == NULL)
		return ENOMEM;
	const int ret = usb_device_get_info(sess, &h, &iface_no);
	async_hangup(sess);
	if (ret != EOK)
		return ret;

	usb_device_t *usb_dev =
	    ddf_dev_data_alloc(ddf_dev, sizeof(usb_device_t));
	if (usb_dev == NULL) {
		*err = "DDF data alloc";
		return ENOMEM;
	}
	
	return usb_device_init(usb_dev, ddf_dev, desc, err, h, iface_no);
}
Beispiel #2
0
/*
M0 Core Manage USB 
*/
int main(void)
{
  iap_cmd_res_t iap_cmd_res;
  usb_descriptor_serial_number_t serial_number;
  airspy_usb_req_init();

  usb_set_configuration_changed_cb(usb_configuration_changed);
  usb_peripheral_reset();
  
  usb_device_init(0, &usb_device);
  
  usb_queue_init(&usb_endpoint_control_out_queue);
  usb_queue_init(&usb_endpoint_control_in_queue);
  usb_queue_init(&usb_endpoint_bulk_out_queue);
  usb_queue_init(&usb_endpoint_bulk_in_queue);

  usb_endpoint_init(&usb_endpoint_control_out);
  usb_endpoint_init(&usb_endpoint_control_in);

  /* Read IAP Serial Number Identification */
  iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_SERIAL_NO;
  iap_cmd_call(&iap_cmd_res);
  if(iap_cmd_res.status_res.status_ret == CMD_SUCCESS)
  { 
    /* Only retrieve 2 last 32bits for Serial Number */
    serial_number.sn_32b[0] = iap_cmd_res.status_res.iap_result[2];
    serial_number.sn_32b[1] = iap_cmd_res.status_res.iap_result[3];
    usb_descriptor_fill_string_serial_number(serial_number);
  }

  nvic_set_priority(NVIC_USB0_IRQ, 255);
  
  nvic_set_priority(NVIC_M4CORE_IRQ, 1);
  nvic_enable_irq(NVIC_M4CORE_IRQ);

  usb_run(&usb_device);

  while(true)
  {
    signal_wfe();

    if( (get_usb_buffer_offset() >= 16384) && 
        (phase == 1) )
    {
      usb_transfer_schedule_block(&usb_endpoint_bulk_in, &usb_bulk_buffer[0x0000], 0x4000, NULL, NULL);
      phase = 0;
    }

    if( (get_usb_buffer_offset() < 16384) && 
        (phase == 0) )
    {
      usb_transfer_schedule_block(&usb_endpoint_bulk_in, &usb_bulk_buffer[0x4000], 0x4000, NULL, NULL);
      phase = 1;  
    }
  }
}
Beispiel #3
0
/*
 * Initialize USB module SFRs and firmware variables to known state.
 * Enable interrupts.
 */
void usbinit()
{
    usb_device_init();
    IECSET(1) = 1 << (PIC32_IRQ_USB - 32);

#if !defined(USB_AUTOBOOT)
    /* Wait for any user input. */
    while (! cdc_consume(0))
#endif
        usb_device_tasks();
}
void usb_initialization(){
	printf("USB Initialization\n");
	alt_up_usb_dev * usb_dev;
	usb_dev = alt_up_usb_open_dev(USB_0_NAME);
	assert(usb_dev);
	usb_device_init(usb_dev, USB_0_IRQ);

	printf("Polling USB device.  Run middleman now!\n");
	alt_timestamp_start();
	int clocks = 0;
	while (clocks < 50000000 * 10) {
		clocks = alt_timestamp();
		usb_device_poll();
	}
	printf("Done polling USB\n");
}
Beispiel #5
0
void usb_init(void)
{
        usb_queue_init(&usb_endpoint_control_in_queue);
        usb_queue_init(&usb_endpoint_control_out_queue);
        usb_queue_init(&usb_endpoint_bulk_cmd_in_queue);
        usb_queue_init(&usb_endpoint_bulk_cmd_out_queue);
        usb_queue_init(&usb_endpoint_bulk_data_in_queue);

        usb_set_configuration_changed_cb(usb_configuration_changed);
        usb_peripheral_reset();
        usb_device_init(0, &usb_device);
        usb_endpoint_init(&usb_endpoint_control_out);
        usb_endpoint_init(&usb_endpoint_control_in);
        nvic_set_priority(NVIC_USB0_IRQ, 255);
        usb_run(&usb_device);
}
Beispiel #6
0
int console_init(void)
{
    /* Initialize the CDC driver object. */
    usb_device_class_cdc_init(&module.console.cdc,
                              0,
                              2,
                              3,
                              module.console.rxbuf,
                              sizeof(module.console.rxbuf));
    module.console.drivers[0] = &module.console.cdc.base;

    /* Initialize the USB device driver. */
    usb_device_init(&module.console.usb,
                    &usb_device[0],
                    module.console.drivers,
                    membersof(module.console.drivers),
                    usb_device_descriptors);

    return (0);
}
Beispiel #7
0
usb_device_t * usb_device_create(devman_handle_t handle)
{
	devman_handle_t h = 0;
	int iface_no = -1;

	async_sess_t *sess = devman_device_connect(handle, IPC_FLAG_BLOCKING);
	int ret = usb_device_get_info(sess, &h, &iface_no);
	if (sess)
		async_hangup(sess);
	if (ret != EOK)
		return NULL;

	usb_device_t *usb_dev = malloc(sizeof(usb_device_t));
	if (!usb_dev)
		return NULL;

	const char* dummy = NULL;
	ret = usb_device_init(usb_dev, NULL, NULL, &dummy, handle, iface_no);
	if (ret != EOK) {
		free(usb_dev);
		usb_dev = NULL;
	}
	return usb_dev;
}
Beispiel #8
0
void task_usb_device()
{
	deg_Printf("enter usb device mode\n");
	g_SystemState = SYSTEM_USB_CONNECT;
	reset_powerSaveChk();
	csi_Stop();
	DIS_OSD1();								//use pull into USB ,no show osd icon
	DIS_OSD3();
	Delay_MS(20);

	while(delResult != FR_OK) {		//wait for finish deleting procedure
		delResult = f_unlink_removeChain(&delFS, &work_fatfs,&delCLST,1);
		deg_Printf("m");				
	}

	if(light_sta)		//if night light open just close it
	{
		CLOSE_NIGHT_LIGHT();
	}

	usb_enum_type = 0;
//====check key into mode====

	u32 key_cnt = 0;
	u32 i = 0;
	while(i < 50)
	{
		if(T_KEY_MENU == GetIOKeyTpye())			//menu key
		{
			key_cnt++;
		}
		i++;
		Delay_MS(1);
	}


	if(key_cnt > 45)
	{
		usb_enum_type = 1;
		deg_Printf("enter pc cam mode\n");
	}
//=====end check key =========
#if (LCD_USE != LCD_NO_DISPLAY)	
	if(0 == usb_enum_type)
	{
		 sys_show_jpeg(RES_USB_DEV_ICON);
	}
	else if(1 == usb_enum_type)
	{
 		sys_show_jpeg(RES_USB_DEV_ICON);
	}
#endif
	usb_enum_type = 1;
	usb_device_init();
	if(usb_enum_type)
	{
		csi_Stop();
		csi_camera_init();
	}

	deg_Printf("into usb while task_ctl.work_sta = %d\n",task_ctl.work_sta);
	while (task_ctl.work_sta == TASK_USB_DEVICE)
	{
		if(!(device_online&BIT(B_USB_DEV_ONLINE)))
		{
//			task_ctl.work_sta = task_ctl.work_backup_sta;
			g_stcJpegInfo.bPowerOffFlag = 1;
			task_ctl.work_sta = TASK_POWER_OFF;
			deg_Printf("usb out poweroff\n");
			break;
		}


		u8 msg = get_msg();
		task_usb_device_deal_msg(msg);
//		if(!usb_enum_type)
//		if(!uvc_on)				//if the usb vedio on, the mass store stop
//		if(Ep1Deal > 0)
//		{
//			if(0 == rbc_process())
			rbc_process();
//			if(Ep1Deal > 0)
//			{
//				Ep1Deal--;
//			}
//			if(Ep1Deal > 1)
//			{
//				deg_Printf("Ep1Deal %u\r\n",Ep1Deal);
//			}
//			if(Ep1Deal <= 0)
//			{
//				Ep1Deal = 0;
//			}
//		}
	}

	deg_Printf("exit usb device mode\n");
}