STM32 is a microcontroller family based on 32bit Contex-M3 CPU, it supports various peripherals, has lots of GPIO pins and more RAM than most megaAVR MCUs.
Here are some advantages and disadvantages of STM32F103C8 compared to generic megaAVR
Disdvantages:
- incompatible with AVR
- 3.3V operation (many pins are 5V tolerant)
- no "free" EEPROM
- 32bit ARM CPU clocked at 72MHz
- 20KB RAM
- cool features like better timers and nested interrupts
- slightly more usable I/O pins
If I forgot something significant, it's unintentional, sorry.
Hardware
I have a SteelSeries 7G keyboard, MX Blacks are replaced with MX Clears.
This keyboard has 3 LEDs and 16x8 matrix with diodes, so 4+16+8=28 GPIOs needed if LEDs are hardware PWM controlled by one timer. STM32F103C8 can handle this with its 48pin package and yet have some pins to spare.
I'm using cheap development board, not the highest possible quality, but OK. You can find it on ebay or aliexpress by searching "STM32F103C8T6 board".
Spoiler:
There are 3 major sections.
Embedded boot loader - read-only, factory programmed. Selected by BOOT pins, supports flash programming via USART.
Boot loader - custom loader. Features:
- DFU to load/update Main secion
- checks if magic keys are not pressed, Main is programmed and then runs Main
- HID keyboard with basic functionality (boot protocol, 6KRO, two layers - one FN key as a layer shift)
Main - all advanced stuff to go here. But nothing really interesting here yet.
Source code is available here: https://sourceforge.net/p/keyboard-stm3 ... ree/trunk/ I believe almost any ARM EABI toolchain should work fine, there are almost no external dependencies.
To build, check the config.mk file and either edit it or define overrides in config-local.mk. Then change directory to boot and run GNU Make.
Firmware is built from single file from which all other source files are included - this allows GCC to perform some advanced optimizations and significantly reduce binary size (up to 2 times).
Conclusion
I'm typing all this on a modded 7G keyboard in a "bootloader" mode. I'm planning to start working on Main firmware soon, sort out some things, implement "missing boot features" and port them to bootloader later.
Advanced keyboard features seemed pretty straightforward at first but the more I digged the less I could comprehend how to actually implement everything, it'll take some time...
Anyway, questions? ideas? If somebody wants to try the "STM32-way", I'll try to help
