does EVENT_USB_Device_ControlRequest listen to all endpoints?

84 views
Skip to first unread message

ulao

unread,
Jan 19, 2019, 12:38:39 PM1/19/19
to LUFA Library Support List
I'm trying to get some data from endpoint 2 but I don't see it.  Will all endpoint call EVENT_USB_Device_ControlRequest

my set up, but I dont see anything coming in on my out endpoint 2.


typedef struct
       
{
            USB_Descriptor_Configuration_Header_t
Config;

           
// Joystick HID Interface
            USB_Descriptor_Interface_t            HID_Interface
;
            USB_HID_Descriptor_HID_t              HID_JoystickHID
;
            USB_Descriptor_Endpoint_t             HID_ReportOUTEndpoint
;            
            USB_Descriptor_Endpoint_t             HID_ReportINEndpoint
;
       
} USB_Descriptor_Configuration_t;

   
/* Macros: */
       
/** Endpoint number of the Generic HID reporting OUT endpoint. */
       
#define JOYSTICK_OUT_EPADDR       (ENDPOINT_DIR_OUT | 2)
       
       
/** Endpoint address of the Joystick HID reporting IN endpoint. */
       
#define JOYSTICK_EPADDR           (ENDPOINT_DIR_IN | 1)
       
       
/** Size in bytes of the Joystick HID reporting IN endpoint. */
       
#define JOYSTICK_EPSIZE           64

       
/** Descriptor header type value, to indicate a HID class HID descriptor. */
       
#define DTYPE_HID                 0x21

       
/** Descriptor header type value, to indicate a HID class HID report descriptor. */
       
#define DTYPE_Report              0x22



and

.HID_Interface =
       
{
           
.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},

           
.InterfaceNumber        = 0x00,
           
.AlternateSetting       = 0x00,

           
.TotalEndpoints         = 2,

           
.Class                  = HID_CSCP_HIDClass,
           
.SubClass               = HID_CSCP_NonBootSubclass,
           
.Protocol               = HID_CSCP_NonBootProtocol,

           
.InterfaceStrIndex      = NO_DESCRIPTOR
       
},

   
.HID_JoystickHID =
       
{
           
.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},

           
.HIDSpec                = VERSION_BCD(1.11),
           
.CountryCode            = 0x00,
           
.TotalReportDescriptors = 1,
           
.HIDReportType          = HID_DTYPE_Report,
           
.HIDReportLength        = sizeof(JoystickReport)
       
},
   
.HID_ReportOUTEndpoint =
       
{
           
.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},

           
.EndpointAddress        = JOYSTICK_OUT_EPADDR,
           
.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
           
.EndpointSize           = JOYSTICK_EPSIZE,
           
.PollingIntervalMS      = 0x05
       
},
   
.HID_ReportINEndpoint =
       
{
           
.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},

           
.EndpointAddress        = JOYSTICK_EPADDR,
           
.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
           
.EndpointSize           = JOYSTICK_EPSIZE,
           
.PollingIntervalMS      = 0x05
       
}




Message has been deleted
Message has been deleted

ulao

unread,
Jan 21, 2019, 7:28:57 AM1/21/19
to LUFA Library Support List
 Ok, I see what I was doing wrong, these are  interrupt OUT/in's

I was looking over the LUFA docs and could not figure out how to set up an  interrupt OUT, how is this done?

ulao

unread,
Jan 22, 2019, 9:04:47 AM1/22/19
to LUFA Library Support List
per author its not possible with the current driver.  Says "You could bodge them in yourself easily, just take care to save/restore the selected endpoint number." Though that is not within my understanding so I'm not sure how to do that.

ulao

unread,
Jan 23, 2019, 7:21:48 AM1/23/19
to LUFA Library Support List
 Ok, I think I get he idea a bit.

save USB register config
select my endpoint with UENUM
do what I need to do
restore config.

At least that is the idea. Being these are interrupt transfers, id have to wait some time to catch or look for an interrupt. Don't see that jiving with LUFA.

Dean Camera

unread,
Jan 30, 2019, 5:30:52 AM1/30/19
to lufa-s...@googlegroups.com

(Writing this a second time - Thunderbird crashed while sending it before, and I couldn't recover the draft...)

Yes, that's the general idea. You need to select each of the endpoints you want to enable interrupts for, and set the appropriate enable bits in the EPIENX register. To handle the interrupts, define the handler in your application code similar to the following:

ISR(USB_COM_vect, ISR_BLOCK)
{
    uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();

    // Handle endpoints here

    Endpoint_SelectEndpoint(PrevSelectedEndpoint);
}

In the handler, you would check UEINT to see if your endpoint was the one that caused the interrupt. If it was, select it, acknowledge the interrupt and perform whatever handler code you need to process the endpoint data or schedule more data to be sent back to the host. The LUFA core task handler function is fairly forgiving in how often you call it, as it's ultimately just checking for and responding to any host requests, which typically have long timeouts specified in the USB specs. As long as you switch back to the previously selected endpoint at the end of the handler, it shouldn't upset any of the existing code. Note that this is incompatible with the USE_INTERRUPT_CONTROL_ENDPOINT compile time option, and don't enable your own interrupts on endpoints managed by a LUFA class driver.

Cheers!

- Dean

--
You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lufa-support...@googlegroups.com.
To post to this group, send email to lufa-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/lufa-support.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages