LPC1768 usb OTG + external hid keyboard - problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1768 usb OTG + external hid keyboard - problem

2,091 Views
olegle
Contributor I

Hello, Freinds!
The problem with enumerating HID keyboard on the LPC1768. I connect the keyboard to the USB LPC1768 host. I am using the code library from Keil. At power LCP1768 start working with the keyboard correctly. But if I extract the keyboard and connect keyboard again - its doesnt work. Maybe its impossible to hot connection of keyboard to MCU?
My code below:

void USBH_Thread (void const *arg) {
char con = 0; /* Connection status of keyboard */
char con_ex = 40; /* Previous connection status + initial time in 100 ms intervals for initial display */
uint8_t out[64]; /* Output to keyboard LEDs */
out[0]=1;
USBH_Initialize (0); /* Initialize USB Host 0 */

while (1) {
   con = USBH_HID_GetDeviceStatus(0) == usbOK; /* Get kbd connection status */

   if ((con ^ con_ex) & 1) { /* If connection status changed */
   if (con) {
      USBH_HID_Write (0,(uint8_t *)&out,1);/* Turn on NUM LED */
      printf ("\nKeyboard connected\n");
   } else {
      printf ("\nKeyboard disconnected ...\n");
   }
   con_ex = con;
   } else if (con_ex > 1) {
   con_ex -= 2; /* Decrement initial time */
   if ((con_ex <= 1) && (!con)) { 
      printf ("\nNo keyboard connected ... \n");
      con_ex = con;
   } else {
      osDelay(200);
   }
   }
   osDelay(100);
   }
}
osThreadDef(USBH_Thread, osPriorityNormal, 1, NULL);

Labels (1)
4 Replies

1,202 Views
elavarasanselvaraj
Contributor I

hi,

i am using lpc1768 based custom board with hid keyboard application.

it works well normally. but not working when pc returns from sleep. 

can someone help to fix this...is it problem with windows driver/settings? or can we fix at embedded side?

thanks in advance,

elavarasan.s 

0 Kudos
Reply

1,435 Views
承王
Contributor I

Hi:

  I have the same problem with you. do you have solve this problem?

0 Kudos
Reply

1,435 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Oleg Le,

I'm not familiar with the Keil Library, I would recommend you to contact the Keil Support team:

Keil Product Support 


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos
Reply

1,435 Views
olegle
Contributor I

Hi, Carlos!

Ok, thanks a lot, i'll ask Keil support!

>Четверг, 19 января 2017, 0:03 +03:00 от Carlos_Mendoza <admin@community.nxp.com>:

>NXP Community

>Re: LPC1768 usb OTG + external hid keyboard  - problem

>reply from Carlos_Mendoza in LPC - View the full discussion