Example program of using USB keyboard with STM32F407VET6 boards (compatible with Seed Arch Max).

Dependencies:   mbed FATFileSystem USBHost-STM32F4

Example program of using USB keyboard with STM32F407VET6 black board (compatible with Seed Arch Max).

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Tue Feb 19 21:52:55 2019 +0000
Commit message:
Example program of using USB keyboard with STM32F407VET6 boards (compatible with Seed Arch Max).

Changed in this revision

FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
USBHost-STM32F4.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5637087657f5 FATFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FATFileSystem.lib	Tue Feb 19 21:52:55 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/mbed-official/code/FATFileSystem/#28e685e5ff7f
diff -r 000000000000 -r 5637087657f5 USBHost-STM32F4.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost-STM32F4.lib	Tue Feb 19 21:52:55 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/hudakz/code/USBHost-STM32F4/#458bf947f46f
diff -r 000000000000 -r 5637087657f5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Feb 19 21:52:55 2019 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "USBHostKeyboard.h"
+
+#define LED1    PA_6
+
+DigitalOut  led(LED1);
+
+/**
+ * @brief
+ * @note
+ * @param
+ * @retval
+ */
+void onKeyboardEvent(uint8_t keyCode, uint8_t modifier)
+{
+    printf("keyCode: %d, modifier: %d\r\n", keyCode, modifier);
+}
+
+/**
+ * @brief
+ * @note
+ * @param
+ * @retval
+ */
+int main()
+{
+    USBHostKeyboard    keyboard;
+
+    // connect a USB keyboard
+    if (!keyboard.connect()) {
+        printf("USB keyboard not found.\n");
+        return -1;
+    }
+
+    printf("Keyboard connected\r\n");
+    // when connected, attach handler called on keyboard event
+    keyboard.attach(onKeyboardEvent);
+
+    Timer   t;
+    t.start();
+    while(1) {
+        if (t.read_ms() > 500) {
+            led = !led;
+            t.reset();
+        }
+
+        USBHost::poll();
+    }
+}
diff -r 000000000000 -r 5637087657f5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Feb 19 21:52:55 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file