Added TARGET_DISCO_F469NI in USBHOST\USBHost\TARGET_STM\USBHALHost_STM_TARGET.h
Dependents: DISCO-F469NI_USB_Disk STM32F4xx_USB_Memory
Fork of USBHOST by
Diff: USBHostHID/USBHostKeyboard.cpp
- Revision:
- 5:fc157e6bd5a5
- Parent:
- 1:ab240722d7ef
- Child:
- 8:3e7a33f81048
--- a/USBHostHID/USBHostKeyboard.cpp Fri Feb 17 12:40:57 2017 +0100 +++ b/USBHostHID/USBHostKeyboard.cpp Wed Apr 26 18:11:37 2017 +0200 @@ -99,7 +99,8 @@ } -bool USBHostKeyboard::connect() { +bool USBHostKeyboard::connect() +{ if (dev_connected) { return true; @@ -112,16 +113,23 @@ break; if (keyboard_device_found) { - int_in = dev->getEndpoint(keyboard_intf, INTERRUPT_ENDPOINT, IN); + { + /* As this is done in a specific thread + * this lock is taken to avoid to process the device + * disconnect in usb process during the device registering */ + USBHost::Lock Lock(host); - if (!int_in) - break; + int_in = dev->getEndpoint(keyboard_intf, INTERRUPT_ENDPOINT, IN); - USB_INFO("New Keyboard device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, keyboard_intf); - dev->setName("Keyboard", keyboard_intf); - host->registerDriver(dev, keyboard_intf, this, &USBHostKeyboard::init); + if (!int_in) + break; - int_in->attach(this, &USBHostKeyboard::rxHandler); + USB_INFO("New Keyboard device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, keyboard_intf); + dev->setName("Keyboard", keyboard_intf); + host->registerDriver(dev, keyboard_intf, this, &USBHostKeyboard::init); + + int_in->attach(this, &USBHostKeyboard::rxHandler); + } host->interruptRead(dev, int_in, report, int_in->getSize(), false); dev_connected = true;