cancel
Showing results for 
Search instead for 
Did you mean: 

USB LIBRARY DOUBT

Posted on April 27, 2007 at 07:03

USB LIBRARY DOUBT

2 REPLIES 2
Posted on May 17, 2011 at 09:42

Hello,

I'm trying to use the STRUSB libs in my project.

In order to use some custom command I found that the

pInformation->USBwValue has the low and high bytes swapped.

so if I send 0x00001 from pc I obtain 0x1000 in fw.

I thought that in the libs the convention was big endian....

I cheched the project config in the examples and the

settings are little endian (like my config)

I modified the code of Setup0_Process() as following and

the code seem to work.

Any remarks ?

u8 Setup0_Process(void)

{

u16* pBuf;

pBuf= (u16 *)(GetEPRxAddr(ENDP0)+PMAAddr);

if (pInformation->ControlState != PAUSE)

{

pInformation->USBbmRequestType = (*pBuf)&0xFF; /* bmRequestType */

pInformation->USBbRequest = ((*pBuf)&0xFF00)>>8; /* bRequest */

pInformation->USBwValue = (*(pBuf+1)); /* wValue */

pInformation->USBwIndex = (*(pBuf+2)); /* wIndex */

// pInformation->USBwValue = ByteSwap(*(pBuf+1)); /* wValue */

// pInformation->USBwIndex = ByteSwap(*(pBuf+2)); /* wIndex */

pInformation->USBwLength = *(pBuf+3); /* wLength */

}

....

}

Posted on May 17, 2011 at 09:42

sorry.. a little mistake in previous post 🙂

In this way the code doesn work...

I modify also in usb_core.h

#define USBwValue0 USBwValues.bw.bb1

#define USBwValue1 USBwValues.bw.bb0

#define USBwIndex USBwIndexs.w

#define USBwIndex0 USBwIndexs.bw.bb1

#define USBwIndex1 USBwIndexs.bw.bb0

....

The code is workin now but I didn't udestand the byteswap....