We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I am useing a AT91SAM7 microcontroller with Keil Realview compiler and USB HID. My code is based on the example code of the Atmel SAM7-EK Board.
Does anybody know what to do, when the uController has no data to send and get's a request from the host to send something. When the PC has noting to send I do not get an SAM7-uC USB interrupt for the Interrupt In Endpoint. However for the HID Interrupt Out Endpoint I get interrupts all the time. If I do not send any data when I get the interrupt the communication Device to Host doesn't work properly because if I reply a few times with some data and then stop to reply and then read the data from the host input buffer of the PC using the visual C++ V6 HID USB api it reports some error. If I send the same data all the time on a request it works. I could send some dummy data if I have nothing to send but that fills the PCs HID report input buffer and if it doesn't respond quickly enough data gets lost.
So now what to do?
"I managed to get it working by disableing the interrupt Out Pipes endpoint handler in the uC."
I think it's IN pipe. You are still mixing up IN and OUT :-) "useing REPORTSIZE as the reportsize corresponding to the ReportID which is smaller size than the largest Report ID (max is Capabilities.OutputReportByteLength)
I get a message - the referenced User Buffer is not allowed ... Can't write to device"
For HID device I/O, use always Capabilities.OutputReportByteLength for nNumberOfBytesToWrite parameter of WriteFile. The OutputReportByteLength holds the greatest length of the output report. Also the buffer handed to WriteFile should have this size. But you don't need to fill the buffer with padding bytes. Just fill it with the size determined by the report ID.
It's Windows HID feature. I don't know the reason why MS have designed the API like this.
They may consider to write multiple reports at a time using an OUT buffer on the device driver, though it is not implemented so far.
Tsuneo