Cypress Semiconductor SL811HS Bedienungsanleitung Seite 32

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 43
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 31
Cypress Semiconductor Corporation
SL811HS and SL811HST: Application Notes
©2001 Cypress Semiconductor Corporation. All rights reserved. The information
and specifications contained in this document are subject to change without
notice.
Date: 07/26/01
Revision: 1.21
Page: 32
if (usbXfer(Dev, PID_SETUP, 0, payload, 8, (BYTE*)setup)== if (usbXfer(Dev, PID_SETUP, 0, payload, 8, (BYTE*)setup)==--1) 1)
return FALSE; return FALSE;
if (wLen) if (wLen)
{ {
if (setup if (setup-->bmRequest & 0x80)>bmRequest & 0x80)
{ {
pid = PID_OUT; pid = PID_OUT;
wLen = (WORD)usbXfer(Dev, PID_IN, 0, payload, wLen, pDat wLen = (WORD)usbXfer(Dev, PID_IN, 0, payload, wLen, pData);a);
payload =0; payload =0;
} }
else else
wLen = (WORD)usbXfer(Dev, PID_OUT, 0, payload, wLen, pData); wLen = (WORD)usbXfer(Dev, PID_OUT, 0, payload, wLen, pData);
} }
usbXfer(Dev, pid, 0, payload, 0, NULL); usbXfer(Dev, pid, 0, payload, 0, NULL);
return wLen >= 0; return wLen >= 0; // return remainder // return remainder
}}
4.1.18 Device Enumeration
The function FindUsbDev () is used to enumerate full speed devices or Hub. The process of
Enumeration includes Get_Descriptor, Set_Address, Get_Configuration, and
Set_Configuration. This is standard USB Device enumeration for all full/low devices or Hubs.
Program Sample 18: Device Enumeration
The complete code is in the SL811HR.C Does this software exist and does it come standard
with the SL811HS DVK? Otherwise, it should either not be here at all or this software should
be made available for the SL811HS DVK.
Program Sample 19: Device Enumeration
////----------------------------------------------------------------------------------------------------------------------------------------
// Find Full Speed USB Device// Find Full Speed USB Device
////----------------------------------------------------------------------------------------------------------------------------------------
int FindUsbDev(short DevNum)int FindUsbDev(short DevNum)
{ {
pDevDesc pDev; pDevDesc pDev;
pConfDesc pConf; pConfDesc pConf;
pIntfDesc pIntf; pIntfDesc pIntf;
int i,j; int i,j;
BYTE *p, *ep; BYTE *p, *ep;
sEPDesc sEP; sEPDesc sEP;
if (DevNum==1) USBReset(); // root hub if (DevNum==1) USBReset(); // root hub
uDev.wEPxCRC[0] = crc5(0); // address = 0 uDev.wEPxCRC[0] = crc5(0); // address = 0, endpoint = 0, endpoint = 0
uDev.wPayLoad[0] = 8; uDev.wPayLoad[0] = 8;
printf("Get Device Descriptor: .. printf("Get Device Descriptor: .. \\n");n");
pDev = (pDevDesc)SCMD; pDev = (pDevDesc)SCMD;
if (!GetDesc(DEVICE<<8,0x40,(BYTE*)SCMD)) return FALSE; if (!GetDesc(DEVICE<<8,0x40,(BYTE*)SCMD)) return FALSE;
printf("Set Address: %x ", DevNum); printf("Set Address: %x ", DevNum);
if (!SetAddress(DevNum)) return FALSE; if (!SetAddress(DevNum)) return FALSE;
printf("len=%02x ep0Len=%d printf("len=%02x ep0Len=%d\\n", pDevn", pDev-->bLength, pDev>bLength, pDev-->bMaxPacketSize0);>bMaxPacketSize0);
uDev.wPayLoad[0] = (pDev uDev.wPayLoad[0] = (pDev-->bMaxPacketSize0&0xff)?pDev>bMaxPacketSize0&0xff)?pDev-->bMaxPacketSize0:8;>bMaxPacketSize0:8;
Seitenansicht 31
1 2 ... 27 28 29 30 31 32 33 34 35 36 37 ... 42 43

Kommentare zu diesen Handbüchern

Keine Kommentare