HI.
I runned 2 projects for Kinetis K40 from Freescale USB Stack v3.1.1 exmples: HID mouse device and HID keyboard device. After this I tried to change code for define into one system 'Composite device' with HID mouse and Keyboard definitions as in the both projects. I changed code in 'usb_descriptor.c' file :
uint_8 USB_DESC_CONST g_config_descriptor[CONFIG_DESC_SIZE] =
{
CONFIG_ONLY_DESC_SIZE, // bLength - Configuration Descriptor Size - always 9 bytes
USB_CONFIG_DESCRIPTOR, // bDescriptorType - "Configuration" type of descriptor
CONFIG_DESC_SIZE, 0x00, // bTotalLength - Total length of the Configuration descriptor
2, // bNumInterfaces
1, // bConfigurationValue - Configuration Value
0, // iConfiguration - Configuration Description String Index
BUS_POWERED|SELF_POWERED|(REMOTE_WAKEUP_SUPPORT<<REMOTE_WAKEUP_SHIFT),
// bmAttributes - Attributes.support RemoteWakeup and self power
// S08/CFv1 are both self powered (its compulsory to set bus powered)
0x32, // bMaxPower(mA) - 50 mA - Current draw from bus
// <= 100mA: Low power
// <= 500mA: High power
// Keyboard descriptors
/* ----------- Interface 0 Descriptor ----------- */
IFACE_ONLY_DESC_SIZE, // bLength
USB_IFACE_DESCRIPTOR, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
HID_DESC_ENDPOINT_COUNT, // bNumEndpoints
0x03, // bInterfaceClass (HID)
0x01, // bInterfaceSubClass
0x01, /* 0x01 for keyboard */ // bInterfaceProcotol
0x00,// iInterface
/* ----------- HID 0 descriptor ----------------- */
HID_ONLY_DESC_SIZE, // bLength
USB_HID_DESCRIPTOR, // bDescriptorType
0x00,0x01, // bcdHID (ver1.00)
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
0x3F,0x00, // wDescriptorLength - report descriptor size to follow
/* ----------- Endpoint 0 descriptor ------------ */
ENDP_ONLY_DESC_SIZE, // bLength
USB_ENDPOINT_DESCRIPTOR, // bDescriptorType
HID_ENDPOINT|(USB_SEND << 7), // bEndpointAddress
USB_INTERRUPT_PIPE, // bmAttributes
HID_ENDPOINT_PACKET_SIZE, 0x00, // MaxPacketSize
0x0A, // bInterval
#endif
#if (defined HID_MOUSE) || (defined HID_KEYBOARD_MOUSE)
// Mouse descriptors
/* ----------- Interface 1 Descriptor ----------- */
IFACE_ONLY_DESC_SIZE, // bLength
USB_IFACE_DESCRIPTOR, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
HID_DESC_ENDPOINT_COUNT, // bNumEndpoints
0x03, // bInterfaceClass (HID)
0x01, // bInterfaceSubClass
0x02, /* 0x02 for mouse */ // bInterfaceProcotol
0x00, // iInterface
/* ----------- HID 1 descriptor ----------------- */
HID_ONLY_DESC_SIZE, // bLength
USB_HID_DESCRIPTOR, // bDescriptorType
0x00,0x01, // bcdHID (ver1.00)
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
0x34,0x00, // wDescriptorLength - report descriptor size to follow
/* ----------- Endpoint 1 descriptor ------------ */
ENDP_ONLY_DESC_SIZE, // bLength
USB_ENDPOINT_DESCRIPTOR, // bDescriptorType
HID_ENDPOINT|(USB_SEND << 7), // bEndpointAddress
USB_INTERRUPT_PIPE, // bmAttributes
HID_ENDPOINT_PACKET_SIZE, 0x00, // MaxPacketSize
0x0A // bInterval
#endif
};
uint_8 USB_DESC_CONST g_report_descriptor[REPORT_DESC_SIZE] =
{
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x06, // Usage (Keyboard)
0xa1, 0x01, // Collection (Application)
0x05, 0x07, // Usage Page (Keyboard)
0x19, 0xe0, // Usage Minimun (Keyboard LeftControl)
0x29, 0xe7, // Usage Maximum (Keyboard Right GUI)
0x15, 0x00, // logical Minimun (0)
0x25, 0x01, // logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x08, // Report count (8)
0x81, 0x02, // Input (Data,Var,Abs) modifier keys (CTRL, ALT, etc...
0x95, 0x01, // Report count (1)
0x75, 0x08, // Report Size (8)
0x81, 0x01, // Input (Cnst,Var,Abs) filupp to byte boundary
0x95, 0x05, // Report count (5)
0x75, 0x01, // Report Size (1)
0x05, 0x08, // Usage Page (LEDs)
0x19, 0x01, // Usage Minimun (Num Lock)
0x29, 0x05, // Usage Maximum (Kana)
0x91, 0x02, // Output (Data,Var,Abs) pc->kbd
0x95, 0x01, // Report count (1)
0x75, 0x03, // Report Size (3
0x91, 0x01, // Output (Cnst,Var,Abs) filupp to byte boundary
0x95, 0x06, // Report count (6)
0x75, 0x08, // Report Size (8)
0x15, 0x00, // logical Minimun (0)
0x25, 0x65, // logical Maximum (101)
0x05, 0x07, // Usage Page (Keyboard)
0x19, 0x00, // Usage Minimun (Reserved (no event indicated))
0x29, 0x65, // Usage Maximum (Keyboard Application)
0x81, 0x00, // Input (Data,Ary,Abs) array for pressed keys
0xc0, // End collection
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x09, // Usage Page (Buttons)
0x19, 0x01, // Usage Minimun (01)
0x29, 0x03, // Usage Maximum (03)
0x15, 0x00, // logical Minimun (0)
0x25, 0x01, // logical Maximum (1)
0x95, 0x03, // Report Count (3)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input(Data, Variable, Absolute) 3 button bits
0x95, 0x01, // Report count (1)
0x75, 0x05, // Report Size (5)
0x81, 0x01, // Input (Constant), 5 bit padding
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x38, // Usage (Z)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x03, // Report Count (2)
0x81, 0x06, // Input(Data, Variable, Relative), 2 position bytes (X & Y)
0xC0, // End collection
0xC0 // End collection
};
How programm shall call to Endpoint0 or to Endpoin1? What I need additional to change?
Thanks.
Evgeni Kosakovski.
R&D Engineer
evgenik@highseclabs.com
Solved! Go to Solution.
I resolved my problem: only correct configuration.
evgenik - what did you change to fix the issue? I'm running into the same issue in MQX.