USB HID API + TDM32/64 + CodeBlocks + Windows 7

Developing embedded projects with USB requires host side software support.

Most of my projects use the USB HID (Human Interface Device) class driver. To be able to comunicate with the device in my C/C++ programs I use the hidapi developed by signal11.

You can find all of the files you need here: Github: hidapi

After you download the software, you can read the various instructions on how to build the shared libraries as necessary. However, if you don’t mind linking directly into your program (Making it larger) then the process is much simpler.

You only need the two files below!

hidapi.c (Windows version)
And add ‘setupapi’ to the linker settings.

After adding hidapi.h and hidapi.c to your project, your view should look similar to this:

Codeblocks project with hidapi files added
Codeblocks project with hidapi files added

The next thing to do is add setupapi library to your projects linker settings making sure to add the setting to both debug and release, as shown below:

Codeblocks hidapi linker settings
Codeblocks hidapi linker settings

And finally, add #include “hidapi.h” to you source code where necessary.

Codeblocks project calling hidapi.h
Codeblocks project calling hidapi.h

Job done!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.