Using Out endpoint on a HID joystick

106 views
Skip to first unread message

Uri_ba

unread,
Mar 20, 2017, 5:32:33 AM3/20/17
to LUFA Library Support List
I've been playing around with LUFA for Joysticks for a while, And I've got pretty good at modifiying the basic joystick templates to do what I want,

However, in my current project, I'm trying to use the OUT endpoint in order to change settings on the fly from a software (which I'll write).

I've ended up with this HID descriptor (Using Low-level template as base).

const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
{
.Config =
{
.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},

.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
.TotalInterfaces        = 1,

.ConfigurationNumber    = 1,
.ConfigurationStrIndex  = NO_DESCRIPTOR,
.ConfigAttributes       = (USB_CONFIG_ATTR_RESERVED ),

.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100)
},

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

.InterfaceNumber        = INTERFACE_ID_Joystick,
.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,1,1),
.CountryCode            = 0x00,
.TotalReportDescriptors = 1,
.HIDReportType          = HID_DTYPE_Report,
.HIDReportLength        = sizeof(JoystickReport)
},

.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      = 0x04
},

.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      = 0x04
}
};



when using "USB live" I can see the device and on paper it looks OK

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     Full
Device Address:       0x0D
Open Pipes:              2

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0008 (8)
bInterval:            0x04

Endpoint Descriptor:
bEndpointAddress:     0x01  OUT
Transfer Type:   Interrupt
wMaxPacketSize:     0x0008 (8)
bInterval:            0x04

Configuration Descriptor:
wTotalLength:       0x0029
bNumInterfaces:       0x01
bConfigurationValue:  0x01
iConfiguration:       0x00
bmAttributes:         0x80 (Bus Powered )
MaxPower:             0x32 (100 Ma)

Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x02
bInterfaceClass:      0x03 (HID)
bInterfaceSubClass:   0x00
bInterfaceProtocol:   0x00
iInterface:           0x00

HID Descriptor:
bcdHID:             0x0111
bCountryCode:         0x00
bNumDescriptors:      0x01
bDescriptorType:      0x22
wDescriptorLength:  0x004B

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0008 (8)
bInterval:            0x04



However, When I try to actually send data to the device. it seems that windows from some reason sees the device with 0 byte "output" endpoint, and will not send the data I want to send.
Can anyone point me to what I am missing? 

Ive added this chunk to the "HID_task" function

/* Select the Joystick Report Endpoint */
Endpoint_SelectEndpoint(JOYSTICK_OUT_EPADDR);

if (Endpoint_IsOUTReceived()) {
/* Check to see if the packet contains data */
if (Endpoint_IsReadWriteAllowed())
{
processStickOut(Endpoint_Read_8(),Endpoint_Read_16_LE());
}
Endpoint_ClearOUT();
}


Thanks In advance,
Uri

Bartosz Szymański

unread,
Nov 15, 2019, 5:50:42 PM11/15/19
to LUFA Library Support List
I know it was a long time ago, but did you manage to solve the problem?

sean

unread,
Nov 17, 2019, 4:38:02 PM11/17/19
to lufa-s...@googlegroups.com
Honestly I have not found time to drive in to it yet but plan to. 

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/lufa-support/f4521a32-5cba-4b4a-b1b0-88c3336b8fd9%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages