Content originally posted in LPCWare by jmf75 on Thu Jan 10 07:20:07 MST 2013
Dear all,
Does any one has already tried to use led on usb keyboard (caps lock, num...) with
the keyboardhost example ?
**To try i insert the following code in the demo example :
in the KeyboardHost_Task of KeyboardHost.c:
<code>
if (PressedKey) putchar(PressedKey);
if (PressedKey==' ')
{//Led blink every time space is pressed
glbo_Led1 = ~glbo_Led1;
uint8_t locl_Led=glbo_Led1 ? HID_KEYBOARD_LED_NUMLOCK : 0;
HID_Host_SendReportByID(&Keyboard_HID_Interface,0,HID_REPORT_ITEM_Out,&locl_Led,1);
}
</code>
9 times on 10 it doesn't work (the keyboard led doesn't blink), sometimes it works.
**After enabling:
<code>
#define LPCUSBlib_DEBUG in LPCUCbLibConfig.h
</code>
I got the following error when HID_Host_SendReportByID is called:
<code>
Error on Endpoint 0x1 has HCD_STATUS code 4
HcdControlTransfer
../Drivers/USB/Core/LPC/HCD/OHCI/OHCI.c: 325
Evaluated HCD_STATUS = 4
</code>
**It seems to be a stall transfer.
I tried v098 and v098b libraries with lpcxpresso 5.0.14 and lpc1769 rev B board,
result was the same.
Did i miss something ?
**Below is the dump of the keyboard descriptors.
Connection Status Device connected
Current Configuration 1
Speed Low
Device Address 1
Number Of Open Pipes 2
Device Descriptor USB Keyboard
Offset Field Size Value Description
0 bLength 1 12h
1bDescriptorType 1 01h Device
2 bcdUSB2 0110h USB Spec 1.1
4 bDeviceClass1 00h Class info in Ifc Descriptors
5 bDeviceSubClass 1 00h
6 bDeviceProtocol 1 00h
7 bMaxPacketSize0 1 08h 8 bytes
8 idVendor 2 0603h Novatek Microelectronics Corp.
10idProduct 2 00F2h
12 bcdDevice 2 0112h 1.12
14 iManufacturer 1 01h "NOVATEK"
15 iProduct 1 02h "USB Keyboard"
16 iSerialNumber 1 00h
17 bNumConfigurations 1 01h
Configuration Descriptor 1 Bus Powered, 100 mA
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 02h Configuration
2 wTotalLength 2 003Bh
4 bNumInterfaces 1 02h
5 bConfigurationValue 1 01h
6 iConfiguration 1 00h
7 bmAttributes 1 A0h Bus Powered, Remote Wakeup
4..0: Reserved ...00000
5: Remote Wakeup ..1..... Yes
6: Self Powered .0...... No, Bus Powered
7: Reserved (set to one)
(bus-powered for 1.0) 1.......
8 bMaxPower 1 32h 100 mA
Interface Descriptor 0/0 HID, 1 Endpoint
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 00h
3 bAlternateSetting 1 00h
4 bNumEndpoints 1 01h
5 bInterfaceClass 1 03h HID
6 bInterfaceSubClass 1 01h Boot Interface
7 bInterfaceProtocol 1 01h Keyboard
8 iInterface 1 00h
HID Descriptor
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 21h HID
2 bcdHID 2 0110h 1.10
4bCountryCode 1 00h
5 bNumDescriptors 1 01h
6 bDescriptorType 1 22h Report
7 wDescriptorLength 2 0041h 65 bytes
Endpoint Descriptor 81 1 In, Interrupt, 10 ms
Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 81h 1 In
3 bmAttributes 1 03h Interrupt
1..0: Transfer Type ......11 Interrupt
7..2: Reserved 000000..
4 wMaxPacketSize 2 0008h 8 bytes
6 bInterval 1 0Ah 10 ms
Interface Descriptor 1/0 HID, 1 Endpoint
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 01h
3 bAlternateSetting 1 00h
4 bNumEndpoints 1 01h
5 bInterfaceClass 1 03h HID
6 bInterfaceSubClass 1 00h
7 bInterfaceProtocol 1 00h
8 iInterface 1 00h
HID Descriptor
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 21h HID
2 bcdHID 2 0110h 1.10
4 bCountryCode 1 00h
5 bNumDescriptors 1 01h
6 bDescriptorType 1 22h Report
7 wDescriptorLength 2 007Dh 125 bytes
Endpoint Descriptor 82 2 In, Interrupt, 10 ms
Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 82h 2 In
3 bmAttributes 1 03h Interrupt
1..0: Transfer Type ......11 Interrupt
7..2: Reserved 000000..
4 wMaxPacketSize 2 0008h 8 bytes
6 bInterval 1 0Ah 10 ms
Interface 0 HID Report Descriptor Keyboard
Item Tag (Value) Raw Data
Usage Page (Generic Desktop) 05 01
Usage (Keyboard) 09 06
Collection (Application) A1 01
Usage Page (Keyboard/Keypad) 05 07
Usage Minimum (Keyboard Left Control)19 E0
Usage Maximum (Keyboard Right GUI) 29 E7
Logical Minimum (0) 15 00
Logical Maximum (1) 25 01
Report Size (1) 75 01
Report Count (8) 95 08
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Report Count (1) 95 01
Report Size (8) 75 08
Input (Cnst,Ary,Abs) 81 01
Report Count (5) 95 05
Report Size (1) 75 01
Usage Page (LEDs) 05 08
Usage Minimum (Num Lock) 19 01
Usage Maximum (Kana) 29 05
Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 91 02
Report Count (3) 95 03
Report Size (1) 75 01
Output (Cnst,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 91 01
Report Count (6) 95 06
Report Size (8) 75 08
Logical Minimum (0) 15 00
Logical Maximum (255) 26 FF 00
Usage Page (Keyboard/Keypad) 05 07
Usage Minimum (Undefined) 19 00
Usage Maximum 2A FF 00
Input (Data,Ary,Abs) 81 00
End Collection C0
Interface 1 HID Report Descriptor System Control
Item Tag (Value) Raw Data
Usage Page (Generic Desktop) 05 01
Usage (System Control) 09 80
Collection (Application) A1 01
Report ID (2) 85 02
Logical Maximum (1) 25 01
Logical Minimum (0) 15 00
Report Size (1) 75 01
Usage (System Power Down) 09 81
Usage (System Sleep) 09 82
Usage (System Wake Up) 09 83
Report Count (3) 95 03
Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit) 81 06
Report Count (5)95 05
Input (Cnst,Ary,Abs) 81 01
End Collection C0
Usage Page (Consumer Devices) 05 0C
Usage (Consumer Control) 09 01
Collection (Application) A1 01
Report ID (3) 85 03
Logical Maximum (1) 25 01
Logical Minimum (0) 15 00
Report Size (1) 75 01
Usage (Scan Next Track)09 B5
Usage (Scan Previous Track) 09 B6
Usage (Stop) 09 B7
Usage (Play/Pause) 09 CD
Usage (Mute) 09 E2
Usage (Volume Increment) 09 E9
Usage (Volume Decrement) 09 EA
Usage (AL Email Reader) 0A 8A 01
Usage (AC Search)0A 21 02
Usage (AC Home) 0A 23 02
Usage (AC Back) 0A 24 02
Usage (AC Forward)0A 25 02
Usage (AC Stop) 0A 26 02
Usage (AC Refresh) 0A 27 02
Usage (AC Bookmarks) 0A 2A 02
Usage (AL Consumer Control Configuration) 0A 83 01
Usage (AL Calculator) 0A 92 01
Usage (AL Local Machine Browser) 0A 94 01
Report Count (18) 95 12
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Report Count (6) 95 06
Input (Cnst,Ary,Abs) 81 01
Usage Page (Vendor-Defined 1) 06 00 FF
Usage (Vendor-Defined 1) 09 01
Collection (Application) A1 01
Report ID (4) 85 04
Usage Page (Button) 05 09
Usage Minimum (Button 16) 19 10
Usage Maximum (Button 31) 29 1F
Logical Maximum (1)25 01
Logical Minimum (0) 15 00
Report Size (1) 75 01
Report Count (16) 95 10
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
End Collection C0
End Collection C0
Best regards