Coder Social home page Coder Social logo

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. You just need to make sure to configure equivalent STM32Cube setup for the MCU as it is done in this example project.

Porting this code to another hardware will require changing i2c_slave.c to interact with the I2C and GPIO FW of your choice of silicon.

Usage pages

To successfully build the software, the HID usage pages must be generated into the hid-rdf/hid-rp/hid/page/ path, using the hid-usage-tables project.

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-rdf 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 Compile build configuration with exceptions enabled, which is only meant to be compiled, but not flashed.

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

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.