示例#1
0
文件: Host.c 项目: jjturn/lb-boards
void GetIntIn(BYTE* BufferPtr, WORD BufferLength) {
    usbhost_xfer_t xfer;
    BYTE Status;
    vos_memset(&xfer, 0, sizeof(usbhost_xfer_t));
    xfer.s = &IntTransferComplete;
    xfer.ep = IntIn;
    xfer.buf = BufferPtr;
    xfer.len = BufferLength;
// Wait for a response packet from X10 controller
    Status = vos_dev_read(hDevice[Host], (BYTE*)&xfer, sizeof(usbhost_xfer_t), NULL);
    if (Status != USBHOST_OK) dprint("Get X10 packet Error (%d)\n", &Status);
    }
示例#2
0
文件: Host.c 项目: jjturn/lb-boards
void SendIntOut(BYTE* BufferPtr, WORD BufferLength) {
    usbhost_xfer_t xfer;
    BYTE Status;
    vos_memset(&xfer, 0, sizeof(usbhost_xfer_t));
    xfer.s = &IntTransferComplete;
    xfer.ep = IntOut;
    xfer.buf = BufferPtr;
    xfer.len = BufferLength;
// Send packet to X10 controller
    Status = vos_dev_write(hDevice[Host], (BYTE*)&xfer, sizeof(usbhost_xfer_t), NULL);
    if (Status != USBHOST_OK) dprint("Send X10 packet Error (%d)\n", &Status);
    }
示例#3
0
void global_array_init()
{
	vos_memset(TMC_TO_BRI_controul_buffer,0,16);
	vos_memset(BRI_TO_TMC_controul_buffer,0,16);

	vos_memset(mark_array,0,31);

	vos_memset(BRI_buffer,0,1024);
	vos_memset(TMC_buffer,0,1024);

	TMC_read_length = 0;
	BRI_read_length = 0;

	TMC_bulk_write_done = 0;
	BRI_bulk_write_done = 0;
	TMC_bulk_read_done  = 0;
	BRI_bulk_read_done  = 0;

	TMC_request_read_enable = 0;
	BRI_request_read_enable = 0;
}
// USBHOSTBoms read function
unsigned char usbhostBoms_read(char *buf,
								  unsigned short num_to_read,
								  unsigned short *num_read,
								  usbhostBoms_context_t *ctx)
{
	unsigned short actual_read = 0;
	unsigned char status = USBHOSTBOMS_NOT_FOUND;
	usbhost_xfer_t xfer;
	vos_semaphore_t s;

	if (ctx->hc)
	{
		vos_init_semaphore(&s, 0);

		vos_memset(&xfer, 0, sizeof(usbhost_xfer_t));
		xfer.buf = buf;
		xfer.len = num_to_read;
		xfer.ep = ctx->epBulkIn;
		xfer.s = &s;
		xfer.cond_code = USBHOST_CC_NOTACCESSED;
		xfer.flags = USBHOST_XFER_FLAG_START_BULK_ENDPOINT_LIST | USBHOST_XFER_FLAG_ROUNDING;

		status = vos_dev_read(ctx->hc, (unsigned char *) &xfer, sizeof(usbhost_xfer_t), NULL);

		if (status == USBHOST_OK)
		{
			status = (unsigned char)USBHOSTBOMS_OK;
			actual_read = xfer.len;
		}
		else
		{
			status |= (unsigned char)USBHOSTBOMS_USBHOST_ERROR;
		}
	}

	if (num_read)
	{
		*num_read = actual_read;
	}

	return status;
}
示例#5
0
//////////////////////////////////////////////////////////////////////
//
//     MM    MM  IIII  DDDDD   IIII
//    MMM  MMM   II   DD  DD   II
//   MM MM MM   II   DD  DD   II
//  MM    MM   II   DD  DD   II
// MM    MM  IIII  DDDDD   IIII
//
void run_midi_class_host(VOS_HANDLE usb_handle) 
{
	unsigned char state;
	int status;
	usbhost_device_handle_ex interface_handle;
	usbhost_ep_handle_ex tx_endpoint;
	usbhost_ep_handle_ex rx_endpoint;
	usbhost_ep_handle_ex ctrl_endpoint;
	vos_semaphore_t read_completion_event;
	usbhost_ioctl_cb_t usbhost_cmd;
	usbhost_ioctl_cb_class_t device_class;
	usbhost_ioctl_cb_vid_pid_t vid_pid;
	
	usbhost_xfer_t transfer_block;
	usb_deviceRequest_t device_request;
	usbhost_ioctl_cb_ep_info_t endpoint_descriptor;
	
	vos_init_semaphore(&read_completion_event, 0);
	
	device_class.dev_class = USB_CLASS_AUDIO;
	device_class.dev_subclass = USB_SUBCLASS_AUDIO_MIDISTREAMING;
	device_class.dev_protocol = USB_PROTOCOL_ANY;

	usbhost_cmd.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_FIND_HANDLE_BY_CLASS;
	usbhost_cmd.handle.dif = NULL;
	usbhost_cmd.set = &device_class;
	usbhost_cmd.get = &interface_handle;
	status = vos_dev_ioctl(usb_handle, &usbhost_cmd);
	if(USBHOST_OK != status) {
		return;
	}
		

	usbhost_cmd.ioctl_code = VOS_IOCTL_USBHOST_GET_USB_STATE;
	usbhost_cmd.handle.dif = interface_handle;
	usbhost_cmd.get = &state;
	usbhost_cmd.set = NULL;
	status = vos_dev_ioctl(usb_handle, &usbhost_cmd);
	if(USBHOST_OK != status) {
		return;
	}

	usbhost_cmd.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_GET_VID_PID;
	usbhost_cmd.handle.dif = interface_handle;
	usbhost_cmd.get = &vid_pid;
	usbhost_cmd.set = NULL;
	status = vos_dev_ioctl(usb_handle, &usbhost_cmd);
	if(USBHOST_OK != status) {
		return;
	}
	
	usbhost_cmd.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_GET_BULK_OUT_ENDPOINT_HANDLE;
	usbhost_cmd.handle.dif = interface_handle;
	usbhost_cmd.get = &tx_endpoint;
	usbhost_cmd.set = NULL;
	status = vos_dev_ioctl(usb_handle, &usbhost_cmd);
	if(USBHOST_OK != status) {
		return;
	}

	usbhost_cmd.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_GET_BULK_IN_ENDPOINT_HANDLE;
	usbhost_cmd.handle.dif = interface_handle;
	usbhost_cmd.get = &rx_endpoint;
	usbhost_cmd.set = NULL;
	status = vos_dev_ioctl(usb_handle, &usbhost_cmd);
	if(USBHOST_OK != status) {
		return;
	}

	usbhost_cmd.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_GET_CONTROL_ENDPOINT_HANDLE;
	usbhost_cmd.handle.dif = interface_handle;
	usbhost_cmd.get = &ctrl_endpoint;
	usbhost_cmd.set = NULL;
	status = vos_dev_ioctl(usb_handle, &usbhost_cmd);
	if(USBHOST_OK != status) {
		return;
	}

	// send a SetIdle to the device
	device_request.bmRequestType = USB_BMREQUESTTYPE_HOST_TO_DEV |
		USB_BMREQUESTTYPE_CLASS |
		USB_BMREQUESTTYPE_INTERFACE;
	device_request.bRequest = 0x0a;
	device_request.wValue = 0;
	device_request.wIndex = 0;
	device_request.wLength = 0;

	usbhost_cmd.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_SETUP_TRANSFER;
	usbhost_cmd.handle.ep = ctrl_endpoint;
	usbhost_cmd.set = &device_request;
	status = vos_dev_ioctl(usb_handle, &usbhost_cmd);

	while (1)
	{
		vos_memset(&transfer_block, 0, sizeof(transfer_block));
		transfer_block.cond_code = USBHOST_CC_NOTACCESSED;
		transfer_block.flags = USBHOST_XFER_FLAG_START_BULK_ENDPOINT_LIST|USBHOST_XFER_FLAG_ROUNDING;
		transfer_block.s = &read_completion_event;
		transfer_block.ep = rx_endpoint;
		transfer_block.buf = usb_rx_data;
		transfer_block.len = SZ_USB_RX_DATA;

		status =  vos_dev_read(usb_handle, (byte*)&transfer_block, sizeof(transfer_block), NULL);
		if(status != USBHOST_OK) {
			break;
		}
		send_output(usb_rx_data, transfer_block.len);		
	}
}