Вы находитесь на странице: 1из 4

USB

DIY *

,

, 21- , USB .

USB
image

..

-
1.
2.
3.
4.
5.
6.

USB ,
, Windows ,
, , Windows
.
Windows ,
.

. ,
1. RTX_Memory OLIMEX LPC-P2148
RTX_Memory KEIL.

ARM\Boards\Keil\MCB2140\RL\USB\.

, KEIL .
, .
, MCB2140
MCB2140 3.3, LPC-P2148
www.olimex.com www.keil.com .

, ,
USB_Init() CONNECT USB .

, MCB2140. -
LED_CFG LED_SUSP
. , ,
.
2. USB .

usbdesc.c US

USB_DEVICE_CLASS_VENDOR_SPECIFIC, .
, Windows ,

. , Windows VID PID


3. .

, USB .
, ,

, Microsoft . Win

, , . ,

, , Checked Free
, .

x86 Checked Build Environment windows XP.


, .

OSR USB-FX2 learning kit.

, .
, Windows NT
. x86 Checked Build Environment

cd

build -ceZ.

, objchk_wxp_x86(
, : SYS, INF, WdfCoInstaller01009.dll.

, Windows


, , .

, KdPrint(). ,
4. .

, ( ),
, .

, , callback EvtDevicePr
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);

. WdfDeviceCreate

, , , ,
typedef struct _DEVICE_CONTEXT {
WDFUSBDEVICE UsbDevice;
WDFUSBINTERFACE UsbInterface;
WDFUSBPIPE BulkReadPipe;
WDFUSBPIPE BulkWritePipe;

} DEVICE_CONTEXT, *PDEVICE_CONTEXT;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, GetDeviceContext)
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

. ,
DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, // Generated using guidgen.exe
0x573e8c73, 0xcb4, 0x4471, 0xa1, 0xbf, 0xfa, 0xb2, 0x6c, 0x31, 0xd3, 0x84);
// {573E8C73-0CB4-4471-A1BF-FAB26C31D384}
status = WdfDeviceCreateDeviceInterface(device,
(LPGUID) &GUID_DEVINTERFACE_OSRUSBFX2,
NULL);// Reference String

. , EvtDevicePre
, , .
5. .

, , ,
. , .

, EvtDevicePrepareHardware. callback
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQueueConfig,
WdfIoQueueDispatchParallel);
ioQueueConfig.EvtIoRead = EvtIoRead;
ioQueueConfig.EvtIoWrite = EvtIoWrite;
status = WdfIoQueueCreate(device,
&ioQueueConfig,
WDF_NO_OBJECT_ATTRIBUTES,
WDF_NO_HANDLE);
, .
6. .

, .
PC ,

,
void MSC_BulkOut (void) {
BulkLen = USB_ReadEP(MSC_EP_OUT, BulkBuf);
LED_Off( LED_RD | LED_WR );

if( BulkBuf[ 0 ] == 0x01 )


{
USB_WriteEP( MSC_EP_IN, (unsigned char*)aBuff_1, sizeof( aBuff_1 ) );
LED_On( LED_RD );
}
else
if( BulkBuf[ 0 ] == 0x02 )
{
USB_WriteEP( MSC_EP_IN, (unsigned char*)aBuff_2, sizeof( aBuff_1 ) );
LED_On( LED_WR );
}
}
MSC_BulkIn() , .
.
.
.
250- .

, ,

.
, ,

, -