how to use interrupt out transfer in vusb

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
dagakshay
Posts: 1
Joined: Sat Jan 29, 2011 2:30 pm

how to use interrupt out transfer in vusb

Post by dagakshay » Wed Feb 16, 2011 7:56 am

I HAD UNDERSTOOD THE INTERRUPT IN TRANSFER IN VUSB... PLEASE TELL ME HOW TO USE HOW TO USE INTERRUPT OUT TRANSFER IN VUSB... ANY EXAMPLE OR LINK FOR THAT... HOW TO DECLARE INTERRUPT OUT ENDPOINT
I HAD WENT THROUGH THE LINK:
http://vusb.wikidot.com/driver-api

BUT HERE THEY HAD NOT SHOWN HOW TO DECLARE INTERRUPT OUT ENDPOINT....

Augend
Posts: 3
Joined: Sat Feb 26, 2011 9:32 am

Re: how to use interrupt out transfer in vusb

Post by Augend » Sat Feb 26, 2011 10:13 am

first you need to declare in usb configuration . follow these steps:
1- go to usbdrv.c
2- find this line: PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */

3- add seven bites to the length of descriptor as followed in this line:
18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + (USB_CFG_DESCR_PROPS_HID & 0xff) +7, 0, //I added las +7

4-now you need to add one ondpoint . find this line and add 1:
USB_CFG_HAVE_INTRIN_ENDPOINT + 1 , /* endpoints excl 0: number of endpoint descriptors to follow */ // I added last +1

5-now at the end of descriptor add these codes to make a new OUT endpoint:
7, /* sizeof(usbDescrEndpoint) */
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
(char)0x01, /* OUT endpoint number 1 */ //instead of 81
0x03, /* attrib: Interrupt endpoint */
8, 0, /* maximum packet size */
USB_CFG_INTR_POLL_INTERVAL, /* in ms */

You need also to configure your driver to use this interrupt-OUT no-1

6- now go to usbconfig.h and set USB_CFG_IMPLEMENT_FN_WRITEOUT to 1

7- find this line:
#if USB_CFG_IMPLEMENT_FN_WRITEOUT
if(usbRxToken < 0x10){ /* endpoint number in usbRxToken */
and change it to this:
if(usbRxToken == USBPID_OUT){ /* endpoint number in usbRxToken *///*
8-every time device receives Interrupt-out, goes into usbFunctionWriteOut()
tell me if it works for you

12oclocker
Posts: 3
Joined: Thu Feb 14, 2013 5:47 pm

Re: how to use interrupt out transfer in vusb

Post by 12oclocker » Thu Feb 14, 2013 5:57 pm

Is their not an easier way to do this?

In step #4 I cannot find which USB_CFG_HAVE_INTRIN_ENDPOINT you are talking about, because it appears multiple times in the file.

Also these steps look like they are modifying the driver, which documentation says not to do, so I assume their is a way to do this without modifying the driver files?

Also why would the "USB_CFG_IMPLEMENT_FN_WRITEOUT" define not just add what is needed to the usbDescriptorConfiguration so that at least 1 output report would be added, I assumed this is how everything worked, but after testing discovered this is not the case.

Is their anyone that has got Interrupt-Out to work and can assist?
My usbHidReportDescriptor is below, many thanks!

Code: Select all

PROGMEM const char usbHidReportDescriptor[] = /* USB report descriptor */
{   
   //[Endpoint 0]
   0x06, 0xa0, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
   0x09, 0x01,       // USAGE (Vendor Usage 1)
   0xa1, 0x01,       // COLLECTION (Application)

   //[Endpoint 1] Interrupt-In (used to send data to the host spontaneously)
   // Input Report
   0x09, 0x02,       // Usage ID - vendor defined usage2
   0x15, 0x00,       // Logical Minimum (0)
   0x26, 0xFF, 0x00, // Logical Maximum (255)
   0x75, 0x08,       // Report Size (8 bits)
   0x95, 0x08,       // Report Count (8 fields)
   0x81, 0x02,       // Input (Data, Variable, Absolute)

   //[Endpoint 2] Interrupt-Out ***DOES NOT WORK YET***
   // Output Report (we get data from PC)
   //0x09, 0x03,       // Usage ID - vendor defined usage3
   //0x15, 0x00,       // Logical Minimum (0)
   //0x26, 0xFF, 0x00, // Logical Maximum (255)
   //0x75, 0x08,       // Report Size (8 bits)
   //0x95, 0x08,       // Report Count (8 fields)
   //0x91, 0x02,       // Output (Data, Variable, Absolute)

   0xc0              // END_COLLECTION
};

12oclocker
Posts: 3
Joined: Thu Feb 14, 2013 5:47 pm

Re: how to use interrupt out transfer in vusb

Post by 12oclocker » Thu Feb 14, 2013 7:35 pm

I figured it out, you have to create a custom "usbDescriptorConfiguration" and custom "usbDescriptorHidReport", then the Interrupt-Out transfers work fine, no need to modify the driver in any way ;-)

Post Reply