Hi Jan,
I was trying to create a hid device using my Silabs F320 development board. The purpose is just to toggle a single LED on P0.0.
I have an application running in my PC to send the data.
1. If 0x31 was sent from PC to my development board, LED = ON.
2. If 0x30 is sent from PC to my development board, LED = OFF.
This was successful though. My problem was the variable (OUT_PACKET[8]) that holds the data (0x31 or 0x32).
This is how I declare it:
unsigned char OUT_PACKET[8] = {0,0,0,0,0,0,0,0};
When I send 0x31 to my board, OUT_PACKET gets filled with 8 1's. Same thing happens when I send 0x30.
I was expecting like this:
OUT_PACKET[0] = 49 //This index should only be filled with 0x31.
OUT_PACKET[1] = 48
OUT_PACKET[2] = 48
OUT_PACKET[3] = 48
OUT_PACKET[4] = 48
OUT_PACKET[5] = 48
OUT_PACKET[6] = 48
OUT_PACKET[7] = 48
This is how I call the reading process:
//USB ISR call this function
void Handle_Out1 ()
{
.....
Fifo_Read(FIFO_EP1, OUT_BUFFER.Length, (unsigned char*)OUT_PACKET);
......
}
//The Fifo_Read function
void Fifo_Read (unsigned char addr, unsigned int uNumBytes, unsigned char * pData)
{
int i;
if (uNumBytes) // Check if >0 bytes requested,
{
USB0ADR = (addr); // Set address
USB0ADR |= 0xC0; // Set auto-read and initiate
// first read
// Unload <NumBytes> from the selected FIFO
for(i=0;i< (uNumBytes);i++)
{
while (USB0ADR & 0x80); // Wait for BUSY->'0' (data ready)
pData[i] = USB0DAT; // Copy data byte
}
//while(USB0ADR & 0x80); // Wait for BUSY->'0' (data ready)
USB0ADR = 0; // Clear auto-read
}
}
This is my HID Report Descriptor:
code const hid_report_descriptor HIDREPORTDESC =
{
0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
0x0a, 0x00, 0xaa, // USAGE (Vendor Usage 1)
0xa1, 0x01, // COLLECTION (Application)
0x0a, 0x01, 0xaa, // Usage (Vendor Usage 1)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0x0a, 0x02, 0xaa, // USAGE (Vendor Usage 1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xC0 // Collection End
};
I really appreciate your help on this.
thanks in advance
gi