当前位置: 首页>>代码示例>>C++>>正文


C++ USB_SendControl函数代码示例

本文整理汇总了C++中USB_SendControl函数的典型用法代码示例。如果您正苦于以下问题:C++ USB_SendControl函数的具体用法?C++ USB_SendControl怎么用?C++ USB_SendControl使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了USB_SendControl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CDC_Setup

bool WEAK CDC_Setup(Setup& setup)
{
	u8 r = setup.bRequest;
	u8 requestType = setup.bmRequestType;

	if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
	{
		if (CDC_GET_LINE_CODING == r)
		{
			USB_SendControl(0,(void*)&_usbLineInfo,7);
			return true;
		}
	}

	if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
	{
		if (CDC_SET_LINE_CODING == r)
		{
			USB_RecvControl((void*)&_usbLineInfo,7);
			return true;
		}

		if (CDC_SET_CONTROL_LINE_STATE == r)
		{
                  _usbLineInfo.lineState = setup.wValueL;
                  if(1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0) {
                    // auto-reset is triggered when the port, already open at 1200 bps, is closed
                    Reboot();
                  }
                  return true;
		}
	}
	return false;
}
开发者ID:BalazsGabor92,项目名称:arduino,代码行数:34,代码来源:CDC.cpp

示例2: CDC_SendDeviceDescriptor

bool WEAK CDC_SendDeviceDescriptor(uint8_t nLen)
{
  if(nLen < sizeof(_cdcDeviceDescriptor))
  {
    nLen = sizeof(_cdcDeviceDescriptor);
  }

  return 0 != USB_SendControl(TRANSFER_PGM | TRANSFER_RELEASE, &_cdcDeviceDescriptor, nLen);
}
开发者ID:XMegaForArduino,项目名称:arduino,代码行数:9,代码来源:CDC.cpp

示例3: CDC_Setup

bool CDC_Setup(USBSetup& setup)
{
	u8 r = setup.bRequest;
	u8 requestType = setup.bmRequestType;

	if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
	{
		if (CDC_GET_LINE_CODING == r)
		{
			USB_SendControl(0,(void*)&_usbLineInfo,7);
			return true;
		}
	}

	if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
	{
		if (CDC_SET_LINE_CODING == r)
		{
			USB_RecvControl((void*)&_usbLineInfo,7);
		}

		if (CDC_SET_CONTROL_LINE_STATE == r)
		{
			_usbLineInfo.lineState = setup.wValueL;
		}

		if (CDC_SET_LINE_CODING == r || CDC_SET_CONTROL_LINE_STATE == r)
		{
			// auto-reset into the bootloader is triggered when the port, already 
			// open at 1200 bps, is closed.  this is the signal to start the watchdog
			// with a relatively long period so it can finish housekeeping tasks
			// like servicing endpoints before the sketch ends

			// We check DTR state to determine if host port is open (bit 0 of lineState).
			if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0)
			{
				*(uint16_t *)(RAMEND-1) = *(uint16_t *)0x0800;
				*(uint16_t *)0x0800 = 0x7777;
				wdt_enable(WDTO_120MS);
			}
			else
			{
				// Most OSs do some intermediate steps when configuring ports and DTR can
				// twiggle more than once before stabilizing.
				// To avoid spurious resets we set the watchdog to 250ms and eventually
				// cancel if DTR goes back high.

				wdt_disable();
				wdt_reset();
				*(uint16_t *)0x0800 = *(uint16_t *)(RAMEND-1);
			}
		}
		return true;
	}
	return false;
}
开发者ID:enurseitov,项目名称:robotrack-working-copy,代码行数:56,代码来源:CDC.cpp

示例4: D_INTERFACE

int SingleAbsoluteMouse_::getInterface(uint8_t* interfaceCount)
{
	*interfaceCount += 1; // uses 1
	HIDDescriptor hidInterface = {
		D_INTERFACE(pluggedInterface, 1, USB_DEVICE_CLASS_HUMAN_INTERFACE, HID_SUBCLASS_NONE, HID_PROTOCOL_NONE),
		D_HIDREPORT(sizeof(_hidSingleReportDescriptorAbsoluteMouse)),
		D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01)
	};
	return USB_SendControl(0, &hidInterface, sizeof(hidInterface));
}
开发者ID:Arksine,项目名称:HID,代码行数:10,代码来源:SingleAbsoluteMouse.cpp

示例5: SendConfiguration

static bool 
SendConfiguration(int maxlen)
{
  InitControl(0);	
  uint8_t interfaces = SendInterfaces();
  ConfigDescriptor config = D_CONFIG(_cmark + sizeof(ConfigDescriptor), interfaces);

  InitControl(maxlen);
  USB_SendControl(0,&config,sizeof(ConfigDescriptor));
  SendInterfaces();
  return (true);
}
开发者ID:Dzenik,项目名称:Cosa,代码行数:12,代码来源:Core.cpp

示例6: SendDescriptor

static
bool SendDescriptor(USBSetup& setup)
{
	int ret;
	u8 t = setup.wValueH;
	if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
		return SendConfiguration(setup.wLength);

	InitControl(setup.wLength);
#ifdef PLUGGABLE_USB_ENABLED
	ret = PluggableUSB().getDescriptor(setup);
	if (ret != 0) {
		return (ret > 0 ? true : false);
	}
#endif

	const u8* desc_addr = 0;
	if (USB_DEVICE_DESCRIPTOR_TYPE == t)
	{
		if (setup.wLength == 8)
			_cdcComposite = 1;
		desc_addr = _cdcComposite ?  (const u8*)&USB_DeviceDescriptorB : (const u8*)&USB_DeviceDescriptor;
	}
	else if (USB_STRING_DESCRIPTOR_TYPE == t)
	{
		if (setup.wValueL == 0) {
			desc_addr = (const u8*)&STRING_LANGUAGE;
		}
		else if (setup.wValueL == IPRODUCT) {
			return USB_SendStringDescriptor(STRING_PRODUCT, strlen(USB_PRODUCT), TRANSFER_PGM);
		}
		else if (setup.wValueL == IMANUFACTURER) {
			return USB_SendStringDescriptor(STRING_MANUFACTURER, strlen(USB_MANUFACTURER), TRANSFER_PGM);
		}
		else if (setup.wValueL == ISERIAL) {
#ifdef PLUGGABLE_USB_ENABLED
			char name[ISERIAL_MAX_LEN];
			PluggableUSB().getShortName(name);
			return USB_SendStringDescriptor((uint8_t*)name, strlen(name), 0);
#endif
		}
		else
			return false;
	}

	if (desc_addr == 0)
		return false;
	u8 desc_length = pgm_read_byte(desc_addr);

	USB_SendControl(TRANSFER_PGM,desc_addr,desc_length);
	return true;
}
开发者ID:CANBus-Triple,项目名称:CANBus-Triple,代码行数:52,代码来源:USBCore.cpp

示例7: SendConfiguration

//	Construct a dynamic configuration descriptor
//	This really needs dynamic endpoint allocation etc
//	TODO
static
bool SendConfiguration(int maxlen)
{
	//	Count and measure interfaces
	InitControl(0);	
	int interfaces = SendInterfaces();
	ConfigDescriptor config = D_CONFIG(_cmark + sizeof(ConfigDescriptor),interfaces);

	//	Now send them
	InitControl(maxlen);
	USB_SendControl(0,&config,sizeof(ConfigDescriptor));
	SendInterfaces();
	return true;
}
开发者ID:stefania11,项目名称:digital_chimes,代码行数:17,代码来源:USBCore.cpp

示例8: USB_SendControl

int SingleAbsoluteMouse_::getDescriptor(USBSetup& setup)
{
	// Check if this is a HID Class Descriptor request
	if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
	if (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) { return 0; }

	// In a HID Class Descriptor wIndex cointains the interface number
	if (setup.wIndex != pluggedInterface) { return 0; }

	// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
	// due to the USB specs, but Windows and Linux just assumes its in report mode.
	protocol = HID_REPORT_PROTOCOL;

	return USB_SendControl(TRANSFER_PGM, _hidSingleReportDescriptorAbsoluteMouse, sizeof(_hidSingleReportDescriptorAbsoluteMouse));
}
开发者ID:Arksine,项目名称:HID,代码行数:15,代码来源:SingleAbsoluteMouse.cpp

示例9: SendDescriptor

static
bool SendDescriptor(Setup& setup)
{
//  DEBUG_OUT(F("USB SendDescriptor\r\n"));

#ifdef LED_SIGNAL1
  digitalWrite(LED_SIGNAL1,digitalRead(LED_SIGNAL1) == LOW ? HIGH : LOW);
#endif // LED_SIGNAL1

  u8 t = setup.wValueH;
  if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
    return SendConfiguration(setup.wLength);

  InitControl(setup.wLength);
#ifdef HID_ENABLED
  if (HID_REPORT_DESCRIPTOR_TYPE == t)
    return HID_GetDescriptor(t);
#endif

  u8 desc_length = 0;
  const u8* desc_addr = 0;
  if (USB_DEVICE_DESCRIPTOR_TYPE == t)
  {
    if (setup.wLength == 8)
      _cdcComposite = 1;
    desc_addr = _cdcComposite ?  (const u8*)&USB_DeviceDescriptorA : (const u8*)&USB_DeviceDescriptor;
  }
  else if (USB_STRING_DESCRIPTOR_TYPE == t)
  {
    if (setup.wValueL == 0)
      desc_addr = (const u8*)&STRING_LANGUAGE;
    else if (setup.wValueL == IPRODUCT) 
      desc_addr = (const u8*)&STRING_IPRODUCT;
    else if (setup.wValueL == IMANUFACTURER)
      desc_addr = (const u8*)&STRING_IMANUFACTURER;
    else
      return false;
  }

  if (desc_addr == 0)
    return false;
  if (desc_length == 0)
    desc_length = pgm_read_byte(desc_addr);

  USB_SendControl(TRANSFER_PGM,desc_addr,desc_length);
  return true;
}
开发者ID:Sonnenhans,项目名称:arduino,代码行数:47,代码来源:USBCore.cpp

示例10: SendDescriptor

static
bool SendDescriptor(Setup& setup)
{
	u8 t = setup.wValueH;
	if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
		return SendConfiguration(setup.wLength);

	InitControl(setup.wLength);
#ifdef HID_ENABLED
	if (HID_REPORT_DESCRIPTOR_TYPE == t)
		return HID_GetDescriptor(t);
#endif

	const u8* desc_addr = 0;
	if (USB_DEVICE_DESCRIPTOR_TYPE == t)
	{
		if (setup.wLength == 8)
			_cdcComposite = 1;
		desc_addr = _cdcComposite ?  (const u8*)&USB_DeviceDescriptorA : (const u8*)&USB_DeviceDescriptor;
	}
	else if (USB_STRING_DESCRIPTOR_TYPE == t)
	{
		if (setup.wValueL == 0) {
			desc_addr = (const u8*)&STRING_LANGUAGE;
		}
		else if (setup.wValueL == IPRODUCT) {
			return USB_SendStringDescriptor(STRING_PRODUCT, strlen(USB_PRODUCT));
		}
		else if (setup.wValueL == IMANUFACTURER) {
			return USB_SendStringDescriptor(STRING_MANUFACTURER, strlen(USB_MANUFACTURER));
		}
		else
			return false;
	}

	if (desc_addr == 0)
		return false;
	u8 desc_length = pgm_read_byte(desc_addr);

	USB_SendControl(TRANSFER_PGM,desc_addr,desc_length);
	return true;
}
开发者ID:Lahorde,项目名称:arduino_avr_template_avr_plugin,代码行数:42,代码来源:USBCore.cpp

示例11: D_AUDIO_CONTROL_INTERFACE

int UsbMidiModule::getInterface(uint8_t *interfaceCount)
{
	*interfaceCount += 2;

	u8 desc[] =
	{
		D_AUDIO_CONTROL_INTERFACE(pluggedInterface),
		D_AUDIO_CONTROL_INTERFACE_SPC(0x03),
		D_AUDIO_STREAM_INTERFACE(pluggedInterface + 1),
		D_AUDIO_STREAM_INTERFACE_SPC(0x41),
		D_MIDI_IN_JACK(D_JACK_TYPE_EMBEDDED, 0x01),
		D_MIDI_IN_JACK(D_JACK_TYPE_EXTERNAL, 0x02),
		D_MIDI_OUT_JACK(D_JACK_TYPE_EMBEDDED, 0x03, 0x02, 0x01),
		D_MIDI_OUT_JACK(D_JACK_TYPE_EXTERNAL, 0x04, 0x01, 0x01),
		D_MIDI_JACK_EP(D_ENDPOINT_OUT | getOutEndpointId()),
		D_MIDI_JACK_EP_SPC(0x01),
		D_MIDI_JACK_EP(D_ENDPOINT_IN | getInEndpointId()),
		D_MIDI_JACK_EP_SPC(0x03),
	};

	return USB_SendControl(0, desc, sizeof(desc));
}
开发者ID:BlokasLabs,项目名称:usbmidi,代码行数:22,代码来源:usbmidi.cpp

示例12: SendDescriptor

static bool 
SendDescriptor(Setup& setup)
{
  uint8_t t = setup.wValueH;
  if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
    return (SendConfiguration(setup.wLength));

  InitControl(setup.wLength);
#ifdef HID_ENABLED
  if (HID_REPORT_DESCRIPTOR_TYPE == t)
    return (HID_GetDescriptor(t));
#endif

  uint8_t desc_length = 0;
  const uint8_t* desc_addr = 0;
  if (USB_DEVICE_DESCRIPTOR_TYPE == t) {
    if (setup.wLength == 8)
      _cdcComposite = 1;
    desc_addr = _cdcComposite ?  (const uint8_t*)&USB_DeviceDescriptorA : (const uint8_t*)&USB_DeviceDescriptor;
  }
  else if (USB_STRING_DESCRIPTOR_TYPE == t) {
    if (setup.wValueL == 0)
      desc_addr = (const uint8_t*)&STRING_LANGUAGE;
    else if (setup.wValueL == IPRODUCT) 
      desc_addr = (const uint8_t*)&STRING_IPRODUCT;
    else if (setup.wValueL == IMANUFACTURER)
      desc_addr = (const uint8_t*)&STRING_IMANUFACTURER;
    else
      return (false);
  }

  if (desc_addr == 0) return (false);
  if (desc_length == 0)
    desc_length = pgm_read_byte(desc_addr);
  
  USB_SendControl(TRANSFER_PGM,desc_addr,desc_length);
  return (true);
}
开发者ID:Dzenik,项目名称:Cosa,代码行数:38,代码来源:Core.cpp

示例13: USB_SendControl

int HID_::getDescriptor(USBSetup& setup)
{
	// Check if this is a HID Class Descriptor request
	if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
	if (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) { return 0; }

	// In a HID Class Descriptor wIndex cointains the interface number
	if (setup.wIndex != pluggedInterface) { return 0; }

	int total = 0;
	HIDSubDescriptor* node;
	for (node = rootNode; node; node = node->next) {
		int res = USB_SendControl(TRANSFER_PGM, node->data, node->length);
		if (res == -1)
			return -1;
		total += res;
	}
	
	// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
	// due to the USB specs, but Windows and Linux just assumes its in report mode.
	protocol = HID_REPORT_PROTOCOL;
	
	return total;
}
开发者ID:nick198205,项目名称:Arduino,代码行数:24,代码来源:HID.cpp

示例14: CDC_SendIAD

bool WEAK CDC_SendIAD(void)
{
  return USB_SendControl(TRANSFER_PGM, &_cdcIADDesc, sizeof(_cdcIADDesc))
         != 0;
}
开发者ID:cjsatuforc,项目名称:DIY-Multiprotocol-TX-Module-Boards,代码行数:5,代码来源:CDC.cpp

示例15: MIDI_GetInterface

int WEAK MIDI_GetInterface(u8* interfaceNum)
{
	interfaceNum[0] += 1;	// uses 1
	return USB_SendControl(TRANSFER_PGM,&_midiInterface,sizeof(_midiInterface));
}
开发者ID:JackDesBwa,项目名称:Leoke,代码行数:5,代码来源:MIDIUSB.cpp


注:本文中的USB_SendControl函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。