Tuesday, 17 March 2026

STM32 Build a basic USB host for HID keyboard decoder.

STM32

Build a  basic USB host for HID keyboard decoder.


With over 50 years of electronic circuit building and embedded software design, it's time for this 80 year old to look at MCU's with more than 8 bits. I have been using 8 bit Atmel and 16 bit FPGA devices such as PSoC 4 and 5, but nothing with the speeds of STM32 system on a chip devices so far.

I became acquainted with STM32 and Black Pill development boards after building Vincent Besson's epic project for the Apple ][e computer disk drive emulator.

From Vincent's read me page.

"The SmartDisk II is an Apple II floppy disk emulator based on the STM32F411 (known as the blackPill). It replicates the behaviour of the DISKII and UNIDISK3.5 devices and provide a modern solution to read Apple II Images using various format: PO, DSK, WOZ, HDV, 2MG,..."


Why build a keyboard decoder?

The PS2 serial keyboards are getting to be difficult to obtain second hand and require connection cables. Modern USB wireless keyboards are self contained and battery operated and are easy to purchase and cheaper than the older serial keyboards. The down side is that the embedded MCU has to have USB host capability with HID functional code in order to use the new USB keyboards. 
Surely not a big thing to understand and implement. 
So in Lewis Carroll mode I am going to be "Crusty in STM32 Wonderland" and drop down the rabbit hole of new experience.

Hardware is going to be:

MCU: STM32F411CEU6 (100 MHz Cortex-M4, 512KB Flash, 128KB SRAM) 
Using the WeAct Black Pill V2.0 development board.

Programmer

STM32 ST-Link V2 Emulator Downloader Programmer

Software Development 

Will be on a Windows 11 laptop using STM32CubeIDE and STMCubeMX


STM32 Build a basic USB host for HID keyboard decoder.

STM32 Build a  basic USB host for HID keyboard decoder. With over 50 years of electronic circuit building and embedded software design, it...