[CLOSED] How to get HID-data working with interrupt-in?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
CaCO3
Posts: 13
Joined: Thu Jun 30, 2011 12:52 am

[CLOSED] How to get HID-data working with interrupt-in?

Post by CaCO3 » Sun Jul 03, 2011 9:50 pm

After quite some trial and errors I was able to modify HID-data so it works for my purpose.
What I does:
It reads in serial data and stores them in a buffer.
For now, the PC has to do polling to fetch the data.
During the fetching time, all incoming serial data is lost.
Because of that I would like to switch to interrupt-in instead polling.
This way, the serial data could let the device know when there is the right time to send the data to the PC.

AFAIK there is no real "sending to PC", the PC still has to fetch it itself. But the device could send an interrupt, so the PC knows when it is a good time for fetching.

There are other project which seem to do it that way, like RemoteSensor, but I am not able to adapt it for my purpose.
If somebody could guide me how to implement HID-data to use interrupt-in, that would help me a lot.
Last edited by CaCO3 on Mon Jul 25, 2011 6:16 pm, edited 2 times in total.

Micha

Re: How to get HID-data working with interrupt-in?

Post by Micha » Mon Jul 11, 2011 7:12 am

Try something like this:

while (!usbInterruptIsReady()) usbPoll(); // check if USB int is ready
usbSetInterrupt(&buffer[0], sizeof(data) + sizeof(uint8_t)); // send ReportID & data

where buffer is an array that holds the data including the report ID, sizeof(data) gives the length of the data and sizeof(uint8_t) the length of the report ID.

CaCO3
Posts: 13
Joined: Thu Jun 30, 2011 12:52 am

Re: How to get HID-data working with interrupt-in?

Post by CaCO3 » Sat Jul 23, 2011 1:31 pm

Hi Micha

Thank you for your tip.
I added this already to the firmware side, how ever my struggles are with the PC side.
I don't understand how to make the PC application to wait and respond to an interrupt.
There is a code fragment at http://vusb.wikidot.com/host-software , also the remotesensor sensor applications uses interrupt-in.
But I just am not able to adapt it into my HID-data example.
How would I have to do that?
Is it even possible to have interrupt-in with HID?

I really would appreciate any tips or even working examples.

CaCO3
Posts: 13
Joined: Thu Jun 30, 2011 12:52 am

Re: How to get HID-data working with interrupt-in?

Post by CaCO3 » Mon Jul 25, 2011 6:15 pm

I spent another few hours to get it working, but finally gave up.
How ever I now gave the Remote Sensor project another try and successed.
I could merge it with the latest v-usb source and got it working on an attiny85.
If anybody is interested in a stripped down version let me know.
Currently the host (PC) waits for an interrupt from the USB client and then fetches all available data.

Micha

Re: [CLOSED] How to get HID-data working with interrupt-in?

Post by Micha » Tue Jul 26, 2011 12:41 am

Depending on the programming language you want to use there are several possible pieces of software you could use: http://www.mikrocontroller.net/articles ... ternativen
I tried all of them more or less detailed, at last I'm using the HidLib from jj-jabb as it is his improvement of the HidLibrary (originally from Mike O'Brien) and fits my needs very well.

The "perfect" solution concerning USB standards is probably GenericHID from Jan Axelson, but it supports no interrupts out of the box. The HidLibrary (from Mike O'Brien as well as from jj-jabb) works with interrupts and so does the HID USB Library from Florian Leitner.

Post Reply