hi Mr.Jan
i am developing an HID Device using PIC18f4550 and i used the usb framework of the Microchip but in some modification..
The Pic is enumerated successfully and i send information from the PC and the PIC read it successfully using this function :
// Read up to len bytes from HID output buffer. Actual number of bytes put into
// buffer is returned. If there are fewer than len bytes, then only the available
// bytes will be returned. Any bytes in the buffer beyond len will be discarded.
byte HIDRxReport(byte *buffer, byte len)
{
hidRxLen = 0;
// If the SIE doesn't own the output buffer descriptor, then it is safe to
// pull data from it.
if(!(ep1Bo.Stat & UOWN))
{
// See if the host sent fewer bytes that we asked for.
if(len > ep1Bo.Cnt)
len = ep1Bo.Cnt;
// Copy data from dual-ram buffer to user's buffer
for(hidRxLen = 0; hidRxLen < len; hidRxLen++)
{
buffer[hidRxLen] = HIDRxBuffer[hidRxLen];
}
// Reset the HID output buffer descriptor so the host
// can send more data.
ep1Bo.Cnt = sizeof(HIDRxBuffer);
if(ep1Bo.Stat & DTS)
ep1Bo.Stat = UOWN | DTSEN;
else
ep1Bo.Stat = UOWN | DTS | DTSEN;
}
return hidRxLen;
}
that return number of bytes got from the host and i could read the buffer successfully
the problem is when using Write function to write some information to the pc i used this function:
byte HIDTxReport(byte *buffer, byte len)
{
byte i;
// If the CPU still owns the SIE, then don't try to send anything.
if (ep1Bi.Stat & UOWN)
return 0;
// Truncate requests that are too large. TBD: send
if(len > HID_INPUT_REPORT_BYTES)
len = HID_INPUT_REPORT_BYTES;
// Copy data from user's buffer to dual-ram buffer
for (i = 0; i < len; i++)
HIDTxBuffer[i] = buffer[i];
// Toggle the data bit and give control to the SIE
ep1Bi.Cnt = len;
if(ep1Bi.Stat & DTS)
ep1Bi.Stat = UOWN | DTSEN;
else
ep1Bi.Stat = UOWN | DTS | DTSEN;
return len;
}
and it return the number of bytes supposed to be written but when check the buffer there is nothing
when i used USB Analyzer
i discovered that it doesn't sense that there is IN transaction but it sense OUT transaction successfully