![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
TEAMUSB_SLAVE
Fork of USBHostKeyboard_HelloWorld by
main.cpp
- Committer:
- wlangenkamp
- Date:
- 2015-03-27
- Revision:
- 7:be82ac3c4821
- Parent:
- 1:2063e3713a99
- Child:
- 8:f8122ca2f58f
File content as of revision 7:be82ac3c4821:
#include "mbed.h" #include "USBHostKeyboard.h" #include "rtos.h" DigitalOut led(LED1); void onKey(uint8_t key) { printf("Key: %c\r\n", key); } void keyboard_task(void const *) { USBHostKeyboard keyboard; while(1) { // try to connect a USB keyboard while(!keyboard.connect()) Thread::wait(500); // when connected, attach handler called on keyboard event keyboard.attach(onKey); // wait until the keyboard is disconnected while(keyboard.connected()) Thread::wait(500); } } int main() { Thread keyboardTask(keyboard_task, NULL, osPriorityNormal, 256 * 4); while(1) { led=!led; Thread::wait(500); } }