The QP/C distribution contains many example projects to demonstrate various QP/C features. Each example project is described on its own dedicated page that you can find using several criteria (see Cross-Reference). The example projects have the following main goals:
QP/C examples are located in sub-directories of the examples top-level folder, with the hierarchical organization outlined below:
[1]
Native examples are located in sub-directories named after the CPU architecture, such as arm-cm for ARM Cortex-M. Under that directory, the sub-directories blinky_ek-tm4c123gxl contain the specific example on the specified board, such as "Blinky" on the EK-TM4C123GXL board here. In the specific example folder, you find sub-folders for the QV, QK and QXK kernels, respectively.
[2]
Examples for 3rd-party RTOS are located in sub-directories named after the RTOS/OS, such as freertos for uc-os2 RTOS. Under that directory, the sub-directories, such as arm-cm, contain examples for the specified CPU architecture, such as ARM Cortex-M here.
[3]
Examples for 3rd-party Middleware are located in sub-directories named after the middleware, such as lwIP for the lwIP TCP/IP stack. Under that directory, the sub-directories, such as arm-cm, contain examples for the specified CPU architecture, such as ARM Cortex-M here.
[4]
Examples for QUTest illustrate unit testing of embedded event-driven code. NOTE: Examples in this directory can run on all types of workstations (Windows, Linux, MacOS), as well as embedded targets.
[5]
Examples for Workstations General-Purpose OS (GPOS) examples described in the PSiCC2 book, which you can try directly on your workstation without any embedded hardware. NOTE: Examples in this directory can also be used on the embedded versions of the desktop operating systems, such as embedded-Linux and Windows-embedded.
To demonstrate QP/C features on an embedded board, you need to create an application that does "something interesting". Instead of inventing this "something interesting" for each and every example, the example projects implement one of the three "example applications", which are described on the QP™/C Tutorial:
With the exception of the game application, all other example applications can be implemented on a board with just a couple of LEDs. The game application is a bit more involved and requires a small graphic display on the board.
Beyond these basic applications for demonstrating and testing the various QP/C ports, the QP/C distribution contains all examples described in the book Practical UML Statecharts in C/C++, 2nd Edition.
While some provided examples can run on your desktop computer, most embedded example projects require special hardware in form of Development Boards, which you need to acquire to be able to run the examples. The boards chosen for the examples are generally inexpensive and self-contained with no need for external hardware (such as external JTAG debuggers or power supplies).
Most provided examples require special embedded cross-development tools, such as embedded compilers, linkers, debuggers and IDEs, which you need to acquire independently from the QP/C distribution. Generally, the examples work with the free (size limited) evaluation versions of the commercial tools. The examples list the versions of tools they were developed and tested with. Please refer to the cross-reference section Development Tools to see which embedded toolchains are used.
QP examples QP ports are provided in the following three build configurations:
Many example projects contain code auto-generated by the QM modeling tool. Such projects always contain the corresponding QM model file, which you can open in QM, modify, and re-generate the code.
The QP/C example projects often need to use various additional code, such as MCU register definition files, startup code, device drivers, etc., which are provided by Third-Party vendors. All such code is located in the 3rd_party top-level folder.
The code in the 3rd_party folder comes from various sources, and Quantum Leaps, LLC expressly makes no claims of ownership to any of this code, even though some of the code might be customized or modified by Quantum Leaps.
README.txt
or LICENSE.txt
files included in the respective sub-folders.Perhaps the most important fact of life to remember is that in embedded systems nothing works until everything works. This means that you should always start with a working system and gradually evolve it, changing one thing at a time and making sure that it keeps working every step of the way.
Keeping this in mind, the provided QP/C application examples, such as the super-simple Blinky, or a bit more advanced dpp or game, allow you to get started with a working project rather than starting from scratch. You should also always try one of the provided example projects on the same evaluation board that it was designed for, before making any changes.
Only after convincing yourself that the example project works "as is", you can think about creating your own projects. At this point, the easiest and recommended way is to copy the existing working example project folder (such as the Blinky example) and rename it.
After copying the project folder, you still need to change the name of the project/workspace. The easiest and safest way to do this is to open the project/workspace in the corresponding IDE and use the Save As~~~ option to save the project under a different name. You can do this also with the QM model file, which you can open in QM and "Save As" a different model.
To work with QP/C effectively, you need to learn a bit more about active objects and state machines. Below is a list of links to enable you to further your knowledge: