This project is the firmware part of the device that converts the USB signaling of modern PS/2-incapable keyboards to the protocol of PS/2 keyboard port. This is the opposite of the common converters that let one attach an old keyboard to a modern USB-only computer (e.g. laptop).
The project was developed on the STM32F401C-DISCO
board, so the PS/2 wires are mapped to the GPIO and power pins that are closest together and not used by other peripherals on the board.
The complete converter consists of a hardware component (that needs to be built) programmed by specific firmware (this project). After you build the converter, you'll get the USB port where the keyboard can be connected, and the PS/2 connector to connect to the computer.
Current status is indicated by the 4 LEDs on the Discovery board. This can be disabled (e.g. if you want to free up corresponding pins on your custom board) by passing -DENABLE_LED=OFF
to CMake. Status codes are as follows:
Debug output via USART can be enabled by passing -DENABLE_DEBUG_OUTPUT=ON
to CMake.
These instructions are assuming the STM32F401C-DISCO
board, on which this project was developed. If you use another one, adapt the instructions to your needs.
To get your converter, you'll need:
STM32F401VCT6
controller, e.g. STM32F401C-DISCO
,Having obtained the required components, connect them as follows:
If you use the STM32F401C-DISCO
board, you can connect resistors on one side, and the PS/2 wires on the other.
If you want to see debug output (don't forget to enable it in CMake config), connect the USB-UART dongle as follows:
To build the firmware, you'll need:
arm-none-eabi
toolchain (on Debian/Ubuntu the package is called gcc-arm-none-eabi
);st-flash
utility (on Debian/Ubuntu it's available in package stlink-tools
). Make sure that the version of the package is 1.6.0, not ~1.6.1~: the latter is broken and may give errors.Once you have the needed tools, issue in the command line (where /path/to/the/source
is the path where you cloned the source tree of this project):
cd /path/to/the/source
mkdir build && cd build
cmake ..
make
This yields the firmware binary usb2ps2conv.bin
.
To write the firmware built into the controller's flash, connect the board to the computer using the ST-LINK USB connector, and issue
make flash
If you use a board different from STM32F401C-DISCO
, you'll likely want to change the pins used. These can be changed in the source file ps2-kbd-emulator.cpp
, in the definitions DATA_GPIO_LETTER
, DATA_PIN_NUM
, CLK_GPIO_LETTER
, CLK_PIN_NUM
. The default values are E,6 and C,13, respectively, which means pins PE6 and C13. To change Tx USART pin for the debug output, see the file dbg-out.c
for the definition of DBG_USART_NUM
, DBG_USART_TX_GPIO_LETTER
and DBG_USART_TX_PIN_NUM
.