QP/C: An Event-Driven Framework Designed for Real-Time Embedded Systems

As an embedded developer, do you have a love-hate relationship with bare-metal programming? Are you overwhelmed by interrupts and questioning your life while writing state machines? Let’s get to know QP/C: a lightweight asynchronous event framework that transforms MCUs into “thinking” entities, allowing you to elegantly manage complex logic and say goodbye to “interrupt hell”!

What is QP/C? QP/C (Quantum Platform for C) is an event-driven framework specifically designed for real-time embedded systems, based on the core concept of “Active Objects” (also known as Actors) combined with “Hierarchical State Machines”.

  • • Break down functionality into individual “actors”, each with its own queue and event handling.
  • • Built-in hierarchical state machine (UML 2.5 style), allowing you to write complex logic as if you were drawing a flowchart.
  • • The framework itself is a small RTOS, but lighter and more flexible, focusing on events with one queue per thread.

What pain points does it address?

  1. 1. Interrupt and Callback Hell Previously, it was all about global variables + interrupt callbacks, which could easily lead to deadlocks and sequence errors. QP/C treats interrupts as “dispatchers”, delegating business logic to active objects, resulting in a clearer system.
  2. 2. Readability and Maintainability The powerful visualization advantages of state machine diagrams can lead to confusion when writing C code by hand. QP/C allows you to draw diagrams in QM or other tools, automatically generating state machine implementations.
  3. 3. Controlled Real-Time Performance It includes three types of kernels: QV (cooperative), QK (preemptive), and QXK (dual-mode preemptive/blocking). Use QV for simple applications, switch to QK for preemption, and use QXK for more complex scenarios, with low performance overhead and high testability.
  4. 4. Elegant Fallback in Resource-Constrained Environments It features a built-in “safe” mode—SafeQP/C, which places safety functions and redundancy checks into a separate commercial version. The open-source version is lightweight, GPLv3 licensed, while the commercial version includes certification suites to meet industrial/medical/automotive safety certifications.

What are the secret weapons for quick onboarding?

  • QP-bundle: Packages QP/C + QM (graphical state machine tool) + QTools (debugging/tracing/simulation) for a one-stop solution.
  • Blinky Example: A must-have for beginners, it runs with just a few lines of code, allowing you to learn while practicing.
  • Multi-Platform Support: From the smallest ARM Cortex-M0 to Linux, Windows, and Zephyr, with dozens of ready-made ports available for immediate use.
  • Debugging Tools: QS (Quantum Spy) software tracking captures events, timestamps, queue depths in real-time, and even allows “event injection” for unit testing; if debugging fails, check the big screen.

Community and Licensing

  • Dual Licensing Model: Open-source GPLv3, with a paid commercial license available for those who need it, ensuring peace of mind without violating open-source policies.
  • Safety Version: SafeQP/C, SafeQP/C++, comes with complete safety lifecycle documentation to help you avoid pitfalls.
  • Active Community: GitHub ⭐1100+, forums, video tutorials, official AppNotes, video courses, and small tools are all available.

A Glimpse at Real-World Cases

  • Industrial Automation: Hundreds of active objects collaborating, with clear hierarchical state machines, decoupled modules, significantly enhancing reliability.
  • Consumer Electronics: Using the QV kernel for asynchronous wake-up in low-power scenarios, concentrating event distribution, saving power and code.
  • Automotive ECU: SafeQP/C has received TÜV and ISO 26262 certification support, meeting high reliability requirements.

Conclusion QP/C integrates the “Actor Model” and “Hierarchical State Machine” into MCUs, bringing a fresh perspective to embedded development: clear event flows, visual state transitions, and flexible kernel strategies. Want to escape “interrupt hell” and break free from the nightmare of “if-else” chains? QP/C is definitely worth a try.

Project Address: https://github.com//QuantumLeaps/qpc

Leave a Comment