Example program of using USB mouse with STM32F407VET6 boards (compatible with Seed Arch Max). This is a fork of https://os.mbed.com/users/va009039/code/F446RE-USBHostMouse_HelloWorld/
Dependencies: mbed FATFileSystem USBHost-STM32F4
Example program of using USB mouse with STM32F407VET6 black board (compatible with Seed Arch Max).
Revision 0:9fe634115b66, committed 2019-02-19
- Comitter:
- hudakz
- Date:
- Tue Feb 19 21:48:44 2019 +0000
- Commit message:
- Example program of using USB mouse with STM32F407VET6 boards (compatible with Seed Arch Max). This is a fork of https://os.mbed.com/users/va009039/code/F446RE-USBHostMouse_HelloWorld/
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FATFileSystem.lib Tue Feb 19 21:48:44 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/mbed-official/code/FATFileSystem/#28e685e5ff7f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBHost-STM32F4.lib Tue Feb 19 21:48:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/hudakz/code/USBHost-STM32F4/#458bf947f46f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 19 21:48:44 2019 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" +#include "USBHostMouse.h" + +#define LED1 PA_6 + +DigitalOut led(LED1); + +/** + * @brief + * @note + * @param + * @retval + */ +void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) +{ + printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z); +} + +/** + * @brief + * @note + * @param + * @retval + */ +int main() +{ + USBHostMouse mouse; + + // connect a USB mouse + if (!mouse.connect()) { + printf("USB mouse not found.\n"); + return -1; + } + + printf("Mouse connected\r\n"); + // when connected, attach handler called on mouse event + mouse.attachEvent(onMouseEvent); + + Timer t; + t.start(); + while(1) { + if (t.read_ms() > 500) { + led = !led; + t.reset(); + } + + USBHost::poll(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 19 21:48:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file