GithubHelp home page GithubHelp logo

benedekkupper / stm32-i2c-hid Goto Github PK

View Code? Open in Web Editor NEW
34.0 2.0 3.0 167 KB

HID over I2C demonstration

License: Mozilla Public License 2.0

C++ 19.17% C 63.73% Assembly 10.75% CMake 6.35%
stm32 i2c i2c-slave hid-over-i2c hid-device hid-keyboard

stm32-i2c-hid's Introduction

HID over I2C demonstration

This project demonstrates how HID over I2C can be used as a flexible protocol between a Linux SoC and an STM32 MCU. When enumerated by the kernel, the MCU will be treated as 3 separate virtual devices: a keyboard, a mouse and a raw HID device. The number and purpose of the virtual devices is defined by the descriptors sent by the MCU. The demo code sends CAPS_LOCK key events when the button on the development board is pressed, and lights up an LED when the CAPS_LOCK LED is activated from the host.

Portability

This code is built for and tested on an 32F072BDISCOVERY kit, as this is a low cost MCU line, and the board has a separate connector for I2C communication.

Porting this code within the STM32 product line is guaranteed to be minimal effort, since the implementation interacts with the hardware via the HAL library. All you need to do is replace the current STM32CubeMX configuration with your choice and generate the new cmake project with it.

Porting this code to another MCU type will require porting hal_i2c_slave.cpp to interact with the I2C and GPIO FW of your choice of silicon.

Customizing the HID application

You can easily extend the HID functionality by modifying the report descriptor and adapting the app code. Either find the existing application and usages in the HID usage tables, or define your own vendor-specific usage page(s) - even by adding them to your hid-usage-tables fork. The hid-rp library allows you to perform compile-time verification of the report descriptor, helping you avoid some mistakes. This verification isn't all-encompassing, and it relies on C++ exceptions. That's why there is a separate cmake target, that compiles the related source file for verification with exceptions enabled. Exceptions are disabled in the firmware to be flashed itself.

Host configuration

This project is tested with a Raspberry Pi 400, please refer to this guide on how to configure a Linux kernel to use HID over I2C.

stm32-i2c-hid's People

Contributors

benedekkupper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stm32-i2c-hid's Issues

Unable to import the project into STM32CubeIDE

I tried importing this project into STM32CubeIDE 1.12.1 but none of the following methods worked:

  • "Existing projects into workspace": Could only find a project located at Drivers/CMSIS/Core/DSP/DSP_Lib_TestSuite/DspLibTest_FVP_A5/.project which is clearly not this project
  • "Import an Existing STM32CubeMX Configuration File (.ioc)": Import ended up without any i2c code, end up with a main.c file without the i2c hid code

I believe the problem is that the .project file is in the .gitignore but is necessary for a proper import into eclipse and/or STM32CubeIDE .

Add support for HID over SPI

Microsoft has released final specification for HID over SPI. There is already patches created for Linux kernel, but better wait for it to be mainlined before starting to implement the device side. Another prerequisite to check is that the Raspberry Pi has SPI broken out on the 40-pin header for testing it.

Add demo for temperature sensor device

HID has a very detailed design for sensor devices, with wide support from Microsoft, and some support on Linux. The MCU's internal temperature sensor can be used to create an HID temperature sensor application. The Raspberry Pi kernel needs to be rebuilt to add support for this, need to investigate which components are required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.