⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winrtusbctl.h

📁 蓝牙芯片ZV4301的调试工具源码.做蓝牙产品时很有参考价值内部有串口的编程序源码,对有串口编成需求的同志有参考价值.
💻 H
📖 第 1 页 / 共 2 页
字号:
////////////////////////////////////////////////////////////
//  WinRTUsbCtl.h - shared definitions and typedefs
//  Copyright (c) 2000, BSquare Corporation
////////////////////////////////////////////////////////////

#ifndef _WINRTUSB_CTL_H_
#define _WINRTUSB_CTL_H_

#include "WinDKDevNotification.h"

    // set the packing to no padding
#pragma pack(push, 1)

    // structure for device descriptors - per USB spec
typedef struct _WINRTUSB_DEVICE_DESCRIPTOR {
    UCHAR   bLength;            // the size of the descriptor in bytes
    UCHAR   bDescriptorType;    // fixed as DESCRIPTOR_TYPE_DEVICE
    USHORT  bcdUSB;             // the USB version number supported by the device
    UCHAR   bDeviceClass;       // the class code; 0xFF is vendor specific
    UCHAR   bDeviceSubClass;    // subclass code; if device class is 0, this must be 0
    UCHAR   bDeviceProtocol;    // protocol code, modified by class and subclass
    UCHAR   bMaxPacketSize0;    // the size of packets on the default endpoint
    USHORT  idVendor;           // vendor ID
    USHORT  idProduct;          // product ID
    USHORT  bcdDevice;          // the device release number in bcd format
    UCHAR   iManufacturer;      // index of string describing the manufacturer
    UCHAR   iProduct;           // index of string describing the product
    UCHAR   iSerialNumber;      // index of string containing the device serial number
    UCHAR   bNumConfigurations; // the number of configurations for the device
} WINRTUSB_DEVICE_DESCRIPTOR, *PWINRTUSB_DEVICE_DESCRIPTOR;

    // structure for configuration descriptors - per USB spec
typedef struct _WINRTUSB_CONFIGURATION_DESCRIPTOR {
    UCHAR   bLength;                // the size of the descriptor in bytes
    UCHAR   bDescriptorType;        // fixed as DESCRIPTOR_TYPE_CONFIGURATION
    USHORT  wTotalLength;           // the total length - config + interfaces + endpoints + etc.
    UCHAR   bNumInterfaces;         // how many interfaces are in this descriptor
    UCHAR   bConfigurationValue;    // Value used during set configurations for this config
    UCHAR   iConfiguration;         // index of string describing this interface
    UCHAR   bmAttributes;           // D7 - Bus Powered, D6 - Self Powered, D5 - Remote Wakeup
    UCHAR   MaxPower;               // max power consumption, expressed in mA
} WINRTUSB_CONFIGURATION_DESCRIPTOR, *PWINRTUSB_CONFIGURATION_DESCRIPTOR;

    // structure for interface descriptors - per USB spec
typedef struct _WINRTUSB_INTERFACE_DESCRIPTOR {
    UCHAR   bLength;                // the size of the descriptor in bytes
    UCHAR   bDescriptorType;        // fixed as DESCRIPTOR_TYPE_INTERFACE
    UCHAR   bInterfaceNumber;       // zero based value identifying this interface in the configuration
    UCHAR   bAlternateSetting;      // the alternate setting for this interface
    UCHAR   bNumEndpoints;          // the number of endpoints for this device (excluding the default)
    UCHAR   bInterfaceClass;        // the class this interface supports
    UCHAR   bInterfaceSubClass;     // the subclass this interface supports
    UCHAR   bInterfaceProtocol;     // the protocol this interface supports
    UCHAR   iInterface;             // the index of the string describing this interface
} WINRTUSB_INTERFACE_DESCRIPTOR, *PWINRTUSB_INTERFACE_DESCRIPTOR;

    // used for determining the direction of an endpoint
#define ENDPOINT_DIRECTION_MASK     0x80

    // the endpoint types - per 9.6.4 of USB spec
#define ENDPOINT_TYPE_CONTROL           0x00
#define ENDPOINT_TYPE_ISOCHRONOUS       0x01
#define ENDPOINT_TYPE_BULK              0x02
#define ENDPOINT_TYPE_INTERRUPT         0x03

    // structure for endpoint descriptors - per USB spec
typedef struct _WINRTUSB_ENDPOINT_DESCRIPTOR {
    UCHAR   bLength;                // the size of the descriptor in bytes
    UCHAR   bDescriptorType;        // fixed as DESCRIPTOR_TYPE_ENDPOINT
    UCHAR   bEndpointAddress;       // D7 == 0, OUT, D7 == 1, IN; D3-0 == endpoint address
    UCHAR   bmAttributes;           // 0 == Control, 1 == Isoch, 2 == Bulk, 3 == Interrupt
    USHORT  wMaxPacketSize;         // the size of packets on this endpoint
    UCHAR   bInterval;              // the polling interval for interrupt endpoints
} WINRTUSB_ENDPOINT_DESCRIPTOR, *PWINRTUSB_ENDPOINT_DESCRIPTOR;

    // structure for isochronous transfers
typedef struct _WINRTUSB_ISOCH_TRANSFER_PACKET {
    ULONG   Size;       // size of the struct
    ULONG   Length;     // number of bytes transferred in this packet
    ULONG   Status;     // status for this packet
    PUCHAR  pData;      // pointer to the data for this packet.
                        //  only needed for isochronous IN transfers
} WINRTUSB_ISOCH_TRANSFER_PACKET, *PWINRTUSB_ISOCH_TRANSFER_PACKET;

    // reset the packing
#pragma pack(pop)

    // standard request type values - per Table 9-2 and 11-12.2 of USB spec
#define REQUEST_TYPE_VENDOR                 0x40
#define REQUEST_TYPE_CLASS                  0x20
#define REQUEST_TYPE_DEVICE                 0x00
#define REQUEST_TYPE_INTERFACE              0x01
#define REQUEST_TYPE_ENDPOINT               0x02
#define REQUEST_TYPE_OTHER                  0x03

#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
#ifndef WINRTUSB_INTERNAL

/////////////////////////////////////////////////////////////////////////////
// WinRTOpenHandle - opens a handle to an winrt for usb device
// Parameters:
//   pLinkName - the symbolic link name for the device
//   DeviceNumber - the device number
//   Exclusive - TRUE to open an exclusive handle to the device,
//               FALSE to open a non-exclusive handle
// Notes: returns a handle to the device, or INVALID_HANDLE_VALUE on failure
/////////////////////////////////////////////////////////////////////////////
HANDLE WinRTOpenHandle(LPCTSTR   pLinkName,
                       ULONG     DeviceNumber,
                       BOOLEAN   Exclusive);


/////////////////////////////////////////////////////////////////////////////
// WinRTCloseHandle - close a handle to a WinRT for USB device
// Parameters:
//   hDevice - the driver handle to close
// Notes: returns TRUE on success, FALSE on failure
/////////////////////////////////////////////////////////////////////////////
BOOLEAN WinRTCloseHandle(HANDLE hDevice);


/////////////////////////////////////////////////////////////////////////////
// WinRTBulkTransfer - Performs a synchronous bulk transfer
// Parameters:
//   hDevice - handle to the device perform the transfer
//   Endpoint - the endpoint to transfer on
//   Length - the length, in bytes, of the transfer
//   pBuffer - the buffer to transfer
//   pReturnLength - return length from the call
// Notes: returns a Win32 status code
/////////////////////////////////////////////////////////////////////////////
LONG WinRTBulkTransfer(HANDLE    hDevice,
                       UCHAR     Endpoint,
                       ULONG     Length,
                       PUCHAR    pBuffer,
                       PULONG    pReturnLength);

/////////////////////////////////////////////////////////////////////////////
// WinRTControlTransfer - Performs a synchronous control transfer
// Parameters:
//   hDevice - handle to the device to perform the transfer
//   RequestType - request type code
//   Request - request code
//   Value - request type
//   Index - request index
//   HostToDevice - transfer direction.  TRUE means transfer from the host 
//                  to the device
//   Length - length of the transfer
//   pBuffer - the buffer to transfer
//   pReturnLength - the number of bytes returned by this function
// Notes: returns a Win32 status code
/////////////////////////////////////////////////////////////////////////////
LONG WinRTControlTransfer(HANDLE  hDevice,
                          UCHAR   RequestType,
                          UCHAR   Request,
                          USHORT  Value,
                          USHORT  Index,
                          BOOLEAN HostToDevice,
                          ULONG   Length,
                          PUCHAR  pBuffer,
                          PULONG  pReturnLength);

/////////////////////////////////////////////////////////////////////////////
// WinRTInterruptTransfer - Perform a synchronous interrupt transfer
// Parameters:
//   hDevice - handle of the device to perform the transfer
//   Endpoint - the endpoint to transfer on
//   Length - the length of the transfer
//   pBuffer - the buffer to transfer
//   pReturnLength - the number of bytes return from the function
// Notes: returns a Win32 status code
/////////////////////////////////////////////////////////////////////////////
LONG WinRTInterruptTransfer(HANDLE    hDevice,
                            UCHAR     Endpoint,
                            ULONG     Length,
                            PUCHAR    pBuffer,
                            PULONG    pReturnLength);

/////////////////////////////////////////////////////////////////////////////
// WinRTIsochronousTransfer - Perform a synchronous isochronous transfer
// Parameters:
//   hDevice - handle of the device to perform the transfer
//   Endpoint - the endpoint to transfer on
//   NumberOfPackets - the number of packets to transfer
//   PacketSize - the size of the packets
//   Length - the length of the transfer buffer
//   pBuffer - the buffer to transfer
//   pReturnLength - the number of bytes returned by the driver
// Notes: returns a Win32 status code
/////////////////////////////////////////////////////////////////////////////
LONG WinRTIsochronousTransfer(HANDLE hDevice,
                              UCHAR  Endpoint,
                              ULONG  NumberOfPackets,
                              ULONG  PacketSize,
                              ULONG  Length,
                              PUCHAR pBuffer,
                              PULONG pReturnLength);

/////////////////////////////////////////////////////////////////////////////
// WinRTAsynchBulkTransfer - Performs an asynchronous bulk transfer
// Parameters:
//   hDevice - handle to the device perform the transfer
//   Endpoint - the endpoint to transfer on
//   Length - the length, in bytes, of the transfer
//   pBuffer - the buffer to transfer
//   pReturnLength - return length from the call
//   pOverlapped - the overlapped structure
// Notes: returns a Win32 status code
/////////////////////////////////////////////////////////////////////////////
LONG WinRTAsynchBulkTransfer(HANDLE       hDevice,
                             UCHAR        Endpoint,
                             ULONG        Length,
                             PUCHAR       pBuffer,
                             PULONG       pReturnLength,
                             LPOVERLAPPED pOverlapped);

/////////////////////////////////////////////////////////////////////////////
// WinRTAsynchControlTransfer - Performs an asynchronous control transfer
// Parameters:
//   hDevice - handle to the device to perform the transfer
//   RequestType - request type code
//   Request - request code
//   Value - request type
//   Index - request index
//   HostToDevice - transfer direction.  TRUE means transfer from the host 
//                  to the device
//   Length - length of the transfer
//   pBuffer - the buffer to transfer
//   pReturnLength - the number of bytes returned by this function
//   pOverlapped - the overlapped structure
// Notes: returns a Win32 status code
/////////////////////////////////////////////////////////////////////////////
LONG WinRTAsynchControlTransfer(HANDLE       hDevice,
                                UCHAR        RequestType,
                                UCHAR        Request,
                                USHORT       Value,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -