cascade-interactive/flight-controller — reverse-engineered prompt

Reverse engineered prompt

I want you to turn this into a usable STM32 flight controller firmware project for a small quadcopter, while keeping the generated startup and peripheral code intact and putting the flight specific logic in clean modules. It should run scheduled tasks, talk to the ICM 20602 over SPI, validate the sensor, read accelerometer and gyroscope data, use DMA where it makes sense, convert raw values into physical units, and stream helpful debug data over USB serial.

Please finish the important pieces that are still in progress, especially sensor calibration and a basic attitude estimator using quaternion math. Keep the estimator code testable with the existing unit tests so it starts from identity, stays normalized, and does not produce NaNs. If it fits the current codebase, add simple scaffolding for the planned range sensor and optical flow sensor drivers without pretending they are fully complete yet.

I also want the code cleaned up enough that it is easy to extend toward PID control and stable hover next. Add comments and a short note on how to build, flash, run tests, and read the debug output. Look up current docs online if you need to.

Want more depth? Deep Reverse