r/embedded • u/Occasion-Complete • 19h ago
SPI slave emulator
I made a generic register-based SPI slave emulator on a Tang Nano 9k and tried mocking a BMI160. I made it to be able to test my MCU firmware. For example, to simulate edge case sensor values, like hot/cold temperatures, without actually manufacturing physical conditions to trigger firmware response. I wrote a small Python interface so a test script can configure the emulator registers and responses.
The demo is ESP32 connected to an actual BMI160 via SPI, displaying X/Y/Z accel values on OLED. Then the BMI160 is replaced with my emulator, and without changing the C code on my MCU, I continue to stream X/Y/Z accel values on OLED. The SPI emulator is programmed with synthesized values using Python API. It can also capture transacted SPI values and send MOSI/MISO data over UART to debug.
This project made me super interested in learning automated testing in embedded. Would love to know if I can contribute to any projects related to this kind of stuff, doesn't have to be specifically spi.
1
1
u/Occasion-Complete 6h ago
More about python api here: www.horse-on-hil.com