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


C++ USBD_Write函数代码示例

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


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

示例1: SetInterface

/**
 * Sets the active setting of the given interface if the configuration supports
 * it; otherwise, the control pipe is STALLed. If the setting of an interface
 * changes.
 * \parma pDriver  Pointer to a USBDDriver instance.
 * \parma infnum  Interface number.
 * \parma setting  New active setting for the interface.
 */
static void SetInterface(
    USBDDriver *pDriver,
    uint8_t infnum,
    uint8_t setting)
{
    /* Make sure alternate settings are supported */

    if (!pDriver->pInterfaces) {

        USBD_Stall(0);
    }
    else {

        /* Change the current setting of the interface and trigger the callback */
        /* if necessary */
        if (pDriver->pInterfaces[infnum] != setting) {

            pDriver->pInterfaces[infnum] = setting;
            USBDDriverCallbacks_InterfaceSettingChanged(infnum, setting);
        }

        /* Acknowledge the request */

        USBD_Write(0, 0, 0, 0, 0);
    }
}
开发者ID:cxjlante,项目名称:at91sam3s,代码行数:34,代码来源:USBDDriver.c

示例2: SendCsw

/**************************************************************************//**
 * @brief
 *   Start a USB bulk-in transfer to send a CSW back to host.
 *****************************************************************************/
__STATIC_INLINE void SendCsw(void)
{
  if ( ledPort != -1 )
    GPIO_PinOutToggle((GPIO_Port_TypeDef)ledPort, ledPin);

  USBD_Write(BULK_IN, (void*) &csw, CSW_LEN, NULL);
}
开发者ID:EnergyMicro,项目名称:kit_common,代码行数:11,代码来源:msdd.c

示例3: GetDeviceStatus

//------------------------------------------------------------------------------
/// Sends the current status of the device to the host.
/// \param pDriver  Pointer to a USBDDriver instance.
//------------------------------------------------------------------------------
static void GetDeviceStatus(const USBDDriver *pDriver)
{
    static unsigned short data;
    const USBConfigurationDescriptor *pConfiguration;

    data = 0;
    // Use different configuration depending on device speed
    if (USBD_IsHighSpeed()) {

        pConfiguration = pDriver->pDescriptors->pHsConfiguration;
    }
    else {

        pConfiguration = pDriver->pDescriptors->pFsConfiguration;
    }

    // Check current configuration for power mode (if device is configured)
    if (pDriver->cfgnum != 0) {

        if (USBConfigurationDescriptor_IsSelfPowered(pConfiguration)) {

            data |= 1;
        }
    }

    // Check if remote wake-up is enabled
    if (pDriver->isRemoteWakeUpEnabled) {

        data |= 2;
    }

    // Send the device status
    USBD_Write(0, &data, 2, 0, 0);
}
开发者ID:PrabathGalz,项目名称:openhm,代码行数:38,代码来源:USBDDriver.c

示例4: usb_send

inline uint16_t usb_send(const void *data, const uint16_t length) {
	if((send_status & (USB_IN_FUNCTION))) {
		return 0;
	}

	if(!(send_status & USB_CALLBACK)) {
		send_status |= USB_IN_FUNCTION;
		if(USBD_Write(IN_EP, data, length, usb_send_callback, 0) != USBD_STATUS_SUCCESS) {
			send_status &= ~USB_IN_FUNCTION;
			return 0;
		}
	} else {
		return 0;
	}

	uint16_t num_tries = 0;
	while(~send_status & USB_CALLBACK) {
		taskYIELD();
		num_tries++;
		// USBD_Write does not always call callback when USBD_STATUS_SUCCESS
		// Wait for NUM_SEND_TRIES
		if(num_tries > NUM_SEND_TRIES) {
			send_status = 0;
			return 0;
		}
	}

	send_status = 0;

	return usb_send_transferred;
}
开发者ID:copterpilot,项目名称:bricklib,代码行数:31,代码来源:usb.c

示例5: SetConfiguration

//------------------------------------------------------------------------------
/// Configures the device by setting it into the Configured state and
/// initializing all endpoints.
/// \param pDriver  Pointer to a USBDDriver instance.
/// \param cfgnum  Configuration number to set.
//------------------------------------------------------------------------------
static void SetConfiguration(USBDDriver *pDriver, unsigned char cfgnum)
{
    USBEndpointDescriptor *pEndpoints[BOARD_USB_NUMENDPOINTS+1];
    const USBConfigurationDescriptor *pConfiguration;

	pConfiguration = pDriver->pDescriptors->pFsConfiguration;

    // Set & save the desired configuration
    USBD_SetConfiguration(cfgnum);
    pDriver->cfgnum = cfgnum;

    // If the configuration is not 0, configure endpoints
    if (cfgnum != 0) {
    
        // Parse configuration to get endpoint descriptors
        USBConfigurationDescriptor_Parse(pConfiguration, 0, pEndpoints, 0);
    
        // Configure endpoints
        int i = 0;
        while (pEndpoints[i] != 0) {
    
            USBD_ConfigureEndpoint(pEndpoints[i]);
            i++;
        }
    }
    // Should be done before send the ZLP
    USBDDriverCallbacks_ConfigurationChanged(cfgnum);

    // Acknowledge the request
    USBD_Write(0, // Endpoint #0
               0, // No data buffer
               0, // No data buffer
               (TransferCallback) 0,
               (void *)  0);
}
开发者ID:Edwinem,项目名称:robocup-software,代码行数:41,代码来源:USBDDriver.c

示例6: GPIO_EVEN_IRQHandler

/**********************************************************
 * Interrupt handler for push button 1
 **********************************************************/
void GPIO_EVEN_IRQHandler(void)
{
  /* Clear the interrupt flag */
  GPIO->IFC = 1 << 10;
  
  /* Send message */
  USBD_Write(EP_IN, button1message, sizeof(button1message), dataSentCallback);
}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:11,代码来源:main_stk.c

示例7: write

/**
  Write data to a USB host.
  @param buffer The data to send.
  @param length How many bytes to send.
  @return The number of bytes successfully written.
  
  \b Example
  \code
  UsbSerial* usb = UsbSerial::get(); // get a reference to the usb system
  int written = usb->write( "hi hi", 5 );
  \endcode
*/
int UsbSerial::write( const char *buffer, int length )
{
  int rv = 0;
  if( USBD_GetState() == USBD_STATE_CONFIGURED ) {
    if( USBD_Write(CDCDSerialDriverDescriptors_DATAIN, buffer, length, 0, 0) == USBD_STATUS_SUCCESS )
      rv = length;
  }
  return rv;
}
开发者ID:ArakniD,项目名称:dynawa,代码行数:21,代码来源:usb_serial.cpp

示例8: HIDDTransferDriver_ReportReceived

/**
 * Callback function when SetReport request data received from host
 * \param pArg Pointer to additional argument struct
 * \param status Result status
 * \param transferred Number of bytes transferred
 * \param remaining Number of bytes that are not transferred yet
 */
static void HIDDTransferDriver_ReportReceived(void *pArg,
                                              uint8_t status,
                                              uint32_t transferred,
                                              uint32_t remaining)
{
    HIDDTransferDriver *pDrv = &hiddTransferDriver;
    pDrv->iReportLen = transferred;
    USBD_Write(0, 0, 0, 0, 0);
}
开发者ID:cxjlante,项目名称:at91sam3s,代码行数:16,代码来源:HIDDTransferDriver.c

示例9: fastsource_get_feat_cur_val

static void fastsource_get_feat_cur_val(uint8_t entity, uint8_t channel,
				   uint8_t control, uint8_t length)
{
	TRACE_INFO("get_feat(E%u, CN%u, CS%u, L%u) ", entity, channel, control, length);
	if (channel == 0 && control == AUDFeatureUnitDescriptor_MUTE && length == 1)
		USBD_Write(0, &usb_state.muted, sizeof(usb_state.muted), 0, 0);
	else
		USBD_Stall(0);
}
开发者ID:JiaoXianjun,项目名称:osmo-sdr,代码行数:9,代码来源:fast_source.c

示例10: firmware_get

static int firmware_get(const USB_Setup_TypeDef *setup)
{
    int res = USB_STATUS_REQ_ERR;

    CHECK_SETUP_IN(USBTHING_FIRMWARE_MAX_SIZE);

    res = USBD_Write(0, firmware_version, sizeof(firmware_version), NULL);

    return res;
}
开发者ID:stiege,项目名称:USB-Thing,代码行数:10,代码来源:base_svc.c

示例11: CDCDSerialDriver_GetLineCoding

//------------------------------------------------------------------------------
/// Sends the current line coding information to the host through Control
/// endpoint 0.
//------------------------------------------------------------------------------
static void CDCDSerialDriver_GetLineCoding(void)
{
    TRACE_INFO_WP("gLineCoding ");

    USBD_Write(0,
               (void *) &(cdcdSerialDriver.lineCoding),
               sizeof(CDCLineCoding),
               0,
               0);
}
开发者ID:mknapik,项目名称:avr-MAC,代码行数:14,代码来源:CDCDSerialDriver.c

示例12: _GetLineCoding

/**
 * Sends the current line coding information to the host through Control
 * endpoint 0.
 * \param pCdcd Pointer to CDCDSerialPort instance.
 */
static void _GetLineCoding(CDCDSerialPort * pCdcd)
{
    TRACE_INFO_WP("gLineCoding ");

    USBD_Write(0,
               (void *) &(pCdcd->lineCoding),
               sizeof(CDCLineCoding),
               0,
               0);
}
开发者ID:modul,项目名称:iris,代码行数:15,代码来源:CDCDSerialPort.c

示例13: CDCDSerialDriver_Write

//------------------------------------------------------------------------------
/// Sends a data buffer through the virtual COM port created by the CDC
/// device serial driver. This function behaves exactly like USBD_Write.
/// \param data Pointer to the data buffer to send.
/// \param size Size of the data buffer in bytes.
/// \param callback Optional callback function to invoke when the transfer
///                 finishes.
/// \param argument Optional argument to the callback function.
/// \return USBD_STATUS_SUCCESS if the read operation has been started normally;
///         otherwise, the corresponding error code.
//------------------------------------------------------------------------------
unsigned char CDCDSerialDriver_Write(void *data,
                                     unsigned int size,
                                     TransferCallback callback,
                                     void *argument)
{
    return USBD_Write(CDCDSerialDriverDescriptors_DATAIN,
                      data,
                      size,
                      callback,
                      argument);
}
开发者ID:mknapik,项目名称:avr-MAC,代码行数:22,代码来源:CDCDSerialDriver.c

示例14: GetConfiguration

/**
 * Sends the current configuration number to the host.
 * \param pDriver  Pointer to a USBDDriver instance.
 */
static void GetConfiguration(const USBDDriver *pDriver)
{
    unsigned long tmp;   // Coud be unsigned char : unsigned long has been chose to avoid any potential alignment issue with DMA 
  
    if( USBD_GetState() <  USBD_STATE_CONFIGURED) 
        tmp = 0;    // If device is unconfigured, returned configuration must be 0 
    else 
        tmp = pDriver->cfgnum; 

    USBD_Write(0, &tmp, 1, 0, 0); 
}
开发者ID:BlueSkyGjj,项目名称:SAMV71_softpack,代码行数:15,代码来源:USBDDriver.c

示例15: TerminateCtrlInWithNull

/**
 * Send a NULL packet
 */
static void TerminateCtrlInWithNull(void *pArg,
                                    uint8_t status,
                                    uint32_t transferred,
                                    uint32_t remaining)
{
    USBD_Write(0, /* Endpoint #0 */
               0, /* No data buffer */
               0, /* No data buffer */
               (TransferCallback) 0,
               (void *)  0);
}
开发者ID:cxjlante,项目名称:at91sam3s,代码行数:14,代码来源:USBDDriver.c


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