Simple Mouse Emulator based on STM32F407G-DISC1 board, LIS3DSH accelerometer placed on board is used. MCU USB is configured in FS-Mode as a HID-Class Device sending Mouse report each 5 ms. Report is based on data from accelerometer transmitted via SPI and state of User Button used as Mouse Left-Button (can be reconfigured to Right or Middle button), state is changed in EXTI IRQHandler. Changing roll angle of board makes cursor move horizontally (negative - left, positive - right). Changing pitch angle of board makes cursor move vertically (negative - down, positive - up). Some threshold is set for cursor to not move while board is on the flat surface.
electronicsworks / usb-hid-mouse-emulator Goto Github PK
View Code? Open in Web Editor NEWSTM32 MCU Project with USB-HID, SPI and EXTI.