close
close

STM32 and Linux coupling? Consider HID rather than I2C

STM32 and Linux coupling?  Consider HID rather than I2C

If you’re pairing a small Linux computer with a few peripherals (maybe you’re building a reasonably custom Pi-powered device), it’s quite tempting to use something like an STM32 for all your low-level tasks, from Power management when reading keyboard events.

Now in case you are wondering how to link the two, consider HID over I2C, it is a standardized protocol with broad software and device support, easily implemented and low power. Additionally, (benedekkupper) gives you an example STM32 project with a detailed explanation on how you can also benefit from the protocol.

There are several interesting things in this project. To begin with, its code is generic enough that it will be well ported across the entire STM32 range. Simply modify the pin definitions as needed, compile them, flash them to your dev board and experiment. Need to change descriptors? THE hid-rdf The library used allows you to define a custom descriptor very easily, without any of that building a descriptor from scratch, and it even does a descriptor check at compile time!

The project was tested with a Raspberry Pi 400 and (benedekkupper) links a tutorial on quickly adding your I2C-HID device on a Linux platform; all you need is DeviceTree support. Wondering what’s possible with HID? We’ve seen hackers playing with HID here, and hacking the HID standard isn’t just for creating keyboards. It can allow you to automate your smartphone, reuse a laptop’s touchpad or even a large Wacom input surface, free up additional buttons on gamepads, or create your own touchscreen.