namespace QP { /*##########################################################################*/ /*! @page exa_rtos Examples for Third-Party RTOS The main purpose of integrating QP/C++ with conventional RTOSes is to enable you to incorporate various communication stacks (TCP/IP, USB, CAN, etc.) as well as other middleware, which requires the ability to **block** the task code. Currently the following 3rd-party RTOSes are supported: - @subpage exa_embos (directory examples/embos/) - @subpage exa_freertos (directory examples/freertos/) - @subpage exa_threadx (directory examples/threadx/) - @subpage exa_uc-os2 (directory examples/uc-os2/) - @subpage exa_zephyr (directory examples/zephyr/) @note You do **not** need to use a third-party RTOS just to achieve preemptive multitasking with QP/C++. The framework contains a selection of built-in real-time kernels, such as the cooperative @ref srs_qv "QV kernel", the preemptive non-blocking @ref srs_qk "QK kernel", and the preemptive, dual-mode, blocking @ref srs_qxk "QXK kernel". Specifically, the QXK kernel has been designed specifically for mixing event-driven active objects with traditional **blocking code**, such as commercial middleware (TCP/IP stacks, UDP stacks, embedded file systems, etc.) or legacy software. @next{exa_embos examples} */ /*##########################################################################*/ /*! @page exa_embos embOS The QP/C++ examples for SEGGER embOS are as follows: - ARM Cortex-M - @subpage embos_dpp_nucleo-h743zi (Cortex-M7)
(GNU-ARM and IAR EWARM toolsets) @note You can hover the mouse cursor over the    icon in the list below to see the picture of the board. @next{embos_dpp_nucleo-h743zi} */ /*##########################################################################*/ /*! @page embos_dpp_nucleo-h743zi DPP on NUCLEO-H743ZI The @ref dpp "DPP example" for embOS on NUCLEO-H743ZI board is located directory examples/embos/arm-cm/dpp_nucleo-h743zi. @image html bd_NUCLEO-H743ZI.jpg NUCLEO-H743ZI @ref dpp "Dining Philosophers Problem (DPP)" example for NUCLEO-H743ZI MCU (Cortex-M7). Toolsets: - GNU-ARM in directory examples/embos/arm-cm/dpp_nucleo-h743zi/gnu. Makefile provided. @verbatim make make CONF=rel make CONF=spy @endverbatim - IAR EWARM in directory examples/embos/arm-cm/dpp_nucleo-h743zi/iar. Workspace `dpp.eww` provided. Features: - embOS RTOS kernel - BSP with embOS-specific: OS_TICK_HOOK, OS_Idle(), "kernel unaware" ISRs - multiple active objects, including 5 instances of the same AO class (Philo) - [QP/Spy software tracing](https://www.state-machine.com/qtools/qpspy.html) using the virtual COM-port - bi-directional [QP/Spy](https://www.state-machine.com/qtools/qs.html#qs_rx) (sending commands to the target) The output is generated at 115200 baud rate. Here is an example invocation of the QSPY host application to receive the QS data from NUCLEO-H743ZI: @verbatim qspy -c COM4 @endverbatim The actual COM port number might be different on your Windows machine. Please check the Device Manager to find the COM port number. @next{exa_freertos examples} */ /*##########################################################################*/ /*! @page exa_freertos FreeRTOS The QP/C++ examples for FreeRTOS are as follows: - ARM Cortex-M - @subpage freertos_dpp_ek-tm4c123gxl (Cortex-M4F)
(ARM-KEIL, GNU-ARM and IAR EWARM toolchains) - @subpage freertos_dpp_stm32f746g-disco (Cortex-M7)
(ARM-KEIL, GNU-ARM and IAR EWARM toolchains) - @subpage freertos_dpp_nucleo-h743zi (Cortex-M7)
(ARM-KEIL, GNU-ARM and IAR EWARM toolchains) - @subpage freertos_start-stop_nucleo-h743zi (Cortex-M7)
(ARM-KEIL, GNU-ARM and IAR EWARM toolchains) @note You can hover the mouse cursor over the    icon in the list below to see the picture of the board. @next{exa_os examples} */ /*##########################################################################*/ /*! @page freertos_dpp_ek-tm4c123gxl DPP on EK-TM4C123GXL @image html bd_EK-TM4C123GXL.jpg EK-TM4C123GXL board @ref dpp "DPP example" for @ref freertos "FreeRTOS" on Texas Instruments TivaC123GXL MCU (Cortex-M4F) with the following toolchains: - ARM-Keil - GNU-ARM - IAR-ARM Demonstrated features: - Multiple Active Objects - Regular "kernel-aware" ISR with "FromISR" APIs + `QF::TICK_X_FROM_ISR()` + `QF::PUBLISH_FROM_ISR()` + `Q_NEW_FROM_ISR()` + `QActive::POST_FROM_ISR()` - Hi-priority "kernel-unaware" ISR - `vApplicationTickHook()` - QP/Spy output over the virtual COM port (Spy build configuration) - QP/Spy input over the virtual COM port (bi-directional Spy) (Spy build configuration) @next{freertos_dpp_stm32f746g-disco examples} */ /*##########################################################################*/ /*! @page freertos_dpp_stm32f746g-disco DPP on STM32F746G-Discovery @image html bd_STM32F746G-Disco.jpg STM32F746G-Discovery @ref dpp "DPP example" for @ref freertos "FreeRTOS" on STM32F746G-Discovery MCU (Cortex-M7) with the following toolchains: - ARM-Keil - GNU-ARM - IAR-ARM Demonstrated features: - Multiple Active Objects - Regular "kernel-aware" ISR with "FromISR" APIs + `QF::TICK_X_FROM_ISR()` + `QF::PUBLISH_FROM_ISR()` + `Q_NEW_FROM_ISR()` + `QActive::POST_FROM_ISR()` - Hi-priority "kernel-unaware" ISR - `vApplicationTickHook()` - QP/Spy output over the virtual COM port (Spy build configuration) - QP/Spy input over the virtual COM port (bi-directional Spy) (Spy build configuration) @next{freertos_dpp_nucleo-h743zi} */ /*##########################################################################*/ /*! @page freertos_dpp_nucleo-h743zi DPP on NUCLEO-H743ZI @image html bd_NUCLEO-H743ZI.jpg NUCLEO-H743ZI @ref dpp "Dining Philosophers Problem (DPP)" example for NUCLEO-H743ZI MCU (Cortex-M7). Features: - multiple active objects, including 5 instances of the same AO class (Philo) - [QP/Spy software tracing](https://www.state-machine.com/qtools/qpspy.html) using the virtual COM-port - bi-directional [QP/Spy](https://www.state-machine.com/qtools/qs.html#qs_rx) (sending commands to the target) @next{freertos_start-stop_nucleo-h743zi} */ /*##########################################################################*/ /*! @page freertos_start-stop_nucleo-h743zi Start-Stop on NUCLEO-H743ZI @image html bd_NUCLEO-H743ZI.jpg NUCLEO-H743ZI Start-Stop example for NUCLEO-H743ZI MCU (Cortex-M7) demonstrates staring and stopping active objects multiple times during the runtime, as opposed to starting AOs only at the beginning. The code for the example is generated automatically by the [QM Model-Based Design tool](https://www.state-machine.com/products/qm/) (QM version 4.5.0 or higher). The start-stop application consists of two AOs: - the Launcher AO is started at the beginning and its job is to periodically (re)start another AO - the Worker AO is NOT started at the beginning, but instead it is instantiated and started by the Launcher AO. ![Launcher and Worker state machines](start-stop.png) The actual visible work is performed by the Worker AO, which blinks the yellow LED (LD1) on the NUCLEO-H743ZI board. After blinking the LED five times, the Worker AO publishes turns the blue LED (LD2), publishes the DONE event and stops itself (by calling QP::QActive::stop() on itself). The Launcher AO subscribes to the DONE event. Upon reception of this event, The Launcher AO gives the Worker a bit of time (at least one clock tick) to cleanly terminate and then it explicitly destroys the Worker. The Worker destructor turns the blue LED (LD2) off. Next the Launcher instantiates the Worker AO by means of the placement new operator and then it starts it again to repeat the cycle, which goes no forever. @remarks Because this application is intended for embedded real-time systems, it does not use the dynamic memory (heap). Instead it uses statically allocated memory (static mode of FreeRTOS) as well as **placement-new** and explicit destructor call. It is possible to use the standard **new** and **delete** operators with the standard heap, or some customized memory allocation (overloaded new/delete). This goes beyond the scope of this example. **Supported Toolchains** @n This example contains sub-directories for building it with various toolchains. The following toolchains are supported: - ARM-Keil MDK - GNU-ARM - IAR EWARM Please refer to the README.txt files in these sub-directories for more information about building and running the examples. **QP/Spy Support** @n This example demonstrates the [QP/Spy software tracing](https://www.state-machine.com/qtools/qpspy.html) in the **Spy build configuration**. The QP/Spy uses the virtual COM port provided by the NUCLEO-H743ZI board. To see the QP/Spy output, you need to launch the qspy host utility, as follows (Windows command prompt): @verbatim qspy -u -c COM4 @endverbatim where COM4 is the particular virtual serial port registered by your NUCLEO board. You need to adjust the COM port number for your machine. **Programming the NUCLEO Board** @n The NUCLEO boards appear as a USB-flash drive in the file system. Programming of the board is done by simply copying the binary into thy flash drive letter. For example, assuming that the NUCLEO board appears as drive E:, you program it with the following command: @verbatim copy dbg\start-stop.bin E: @endverbatim **Demonstrated Features** @n - multiple active objects (Launcher and Worker) - instantiating, starting and stopping active objects multiple times - [QP/Spy software tracing](https://www.state-machine.com/qtools/qpspy.html) using the virtual COM-port - bi-directional [QP/Spy](https://www.state-machine.com/qtools/qs.html#qs_rx) (sending commands to the target) @next{exa_threadx examples} */ /*##########################################################################*/ /*! @page exa_threadx ThreadX The QP/C++ examples for ThreadX (Express Logic) are as follows: - @subpage threadx_dpp_ek-tm4c123gxl (Cortex-M4F)
(IAR EWARM toolchain) - @subpage threadx_dpp_stm32f429-discovery
(IAR EWARM toolchain) @note You can hover the mouse cursor over the    icon in the list below to see the picture of the board. @next{exa_uc-os2 examples} */ /*##########################################################################*/ /*! @page threadx_dpp_ek-tm4c123gxl DPP on EK-TM4C123GXL @image html bd_EK-TM4C123GXL.jpg "EK-TM4C123GXL (TivaC LaunchPad) board" @ref dpp "DPP example" for ThreadX on Texas Instruments TivaC123GXL MCU (Cortex-M4F) with the following toolchain: - IAR-ARM Demonstrated features: - Multiple Active Objects - QP/Spy output over the virtual COM port (Spy build configuration) - QP/Spy input over the virtual COM port (bi-directional Spy) (Spy build configuration) @next{threadx_dpp_stm32f429-discovery examples} */ /*##########################################################################*/ /*! @page threadx_dpp_stm32f429-discovery DPP on STM32F4-Discovery The @ref dpp "DPP example" for ThreadX on STM32F4-Discovery board is located directory examples/threadx/arm-cm/dpp_stm32f429-discovery. @image html bd_STM32F4-Discovery.jpg "STM32F4-Discovery board" The sub-directory iar contains the workspace and project file that you can open in IAR EWARM IDE. After you load the DPP example into the STM32F4-Discovery board, the application should start blinking the 4 on-board LEDs. You can press the User button (blue) to PAUSE the philosophers for as long as the button is depressed. The philosophers resume dining when you release the User button. (In the PAUSED state the Table active object stops granting permissions to eat, so eventually all philosophers end in the "hungry" state.) @section threadx_dpp_stm32f429-discovery_qs QS Software Tracing The DPP example for ThreadX on STM32F4-Discovery board provides the "Spy" build configuration, which outputs the QS (Quantum Spy) software tracing data through USART2. To get the data out of the board, you need to connect the TTL/RS232 converter as follows:
STM32F4-Discovery | TTL/RS232 Converter -------------------|:------------------------ PA2 | TX PA3 | RX (currently not used) VDD | VCC GND | GND
@image html bd_STM32F4-Discovery_RS232.jpg STM32F4-Discovery board connected to RS232 level shifter The output is generated at 115200 baud rate. Here is an example invocation of the QSPY host application to receive the QS data from STM32F4-Discovery: @verbatim qspy -cCOM1 @endverbatim The actual COM port number might be different on your Windows machine. Please check the Device Manager to find the COM port number. @next{exa_uc-os2 examples} */ /*##########################################################################*/ /*! @page exa_uc-os2 uC-OS2 The QP/C++ examples for uC-OS2 are as follows: - ARM Cortex-M - @subpage uc-os2_dpp_ek-tm4c123gxl (Cortex-M4F)
(ARM-CLANG, GNU-ARM and IAR EWARM toolsets) - @subpage uc-os2_dpp_nucleo-l053r8 (Cortex-M0+)
(ARM-CLANG, GNU-ARM, and IAR EWARM toolsets) @note You can hover the mouse cursor over the    icon in the list below to see the picture of the board. @next{exa_os examples} */ /*##########################################################################*/ /*! @page uc-os2_dpp_ek-tm4c123gxl DPP on EK-TM4C123GXL @image html bd_EK-TM4C123GXL.jpg "EK-TM4C123GXL board" DPP example for Texas Instruments TivaC123GXL MCU (Cortex-M4F) and ARM-CLANG, GNU-ARM and IAR EWARM toolsets. @image html under_construction.jpg @next{uc-os2_dpp_nucleo-l053r8 examples} */ /*##########################################################################*/ /*! @page uc-os2_dpp_nucleo-l053r8 DPP on STM32-NUCLEO-L053R8 @image html bd_NUCLEO-L053R8.jpg "STM32-NUCLEO-L053R8 board" DPP example for STM32 L053R8 MCU (Cortex-M0+) and ARM-CLANG, GNU-ARM and IAR EWARM toolsets. @image html under_construction.jpg @next{exa_zephyr examples} */ /*##########################################################################*/ /*! @page exa_zephyr Zephyr The QP/C++ examples for Zephyr are as follows: - @subpage zephyr_blinky - @subpage zephyr_dpp @next{zephyr_blinky} */ /*##########################################################################*/ /*! @page zephyr_blinky Blinky The "Blinky" example blinks an on-board LED once per second. The blinking is done by an Active Object (Blinky) with a state machine. The example directory contains the following files: @verbatim /examples/zephyr/blinky | +-src/ - project sources | | | +-bsp.hpp | +-bsp.cpp | +-blinky.hpp | +-blinky.cpp | +-main.cpp | +-CMakeLists.txt - project files +-prj.conf - project config +-README.md @endverbatim @section zephyr_blinky-build Building and Running - Linux: @verbatim [1] cd /examples/zephyr/blinky [2] source ~/zephyrproject/zephyr/zephyr-env.sh [3] west build -b [3a] west build -b nucleo_h743zi [3b] west build -b nucleo_l053r8 ... [4] west flush @endverbatim `[1]` Open a terminal in the Blinky example directory.
`[2]` If Zephyr project is not in your path, you might need to source the `zephyr-env.sh` shell script.
`[3]` build the example project, where `` is any of the boards supported by Zepyr. The example has been tested with the following boards:
`[3a]` nucleo_h743zi (ARM Cortex-M7)
`[3b]` nucleo_l053r8 (ARM Cortex-M0+)
`[4]` flash the board @remark The example has been tested with the following boards: ![STM32-NUCLEO-L053R8 board](bd_NUCLEO-L053R8.jpg)
![STM32-NUCLEO-H743ZI board](bd_NUCLEO-H743ZI.jpg) @note The example should also work with most boards supported by Zephyr. @section zephyr_blinky-output Sample Output Once flashed to the board, the application also produces ASCII output to the serial terminal (if supported by the board): @verbatim *** Booting Zephyr OS build v2.6.0-rc2-88-g3d39f72a88b3 *** BSP::ledOff QF::onStartup BSP::ledOn BSP::ledOff BSP::ledOn BSP::ledOff @endverbatim @section zephyr_blinky-limits Limitations The simple Blinky example does not support the QS software tracing. @next{zephyr_dpp} */ /*##########################################################################*/ /*! @page zephyr_dpp DPP DPP example with multiple active objects. @verbatim /examples/zephyr/dpp | +-src/ - project sources | | | +-bsp.hpp | +-bsp.cpp | +-dpp.hpp | +-philo.cpp | +-table.cpp | +-main.cpp | +-CMakeLists.txt - project files +-prj.conf - project config +-README.md @endverbatim @section zephyr_dpp-build Building and Running - Linux: @verbatim [1] cd /examples/zephyr/dpp [2] source ~/zephyrproject/zephyr/zephyr-env.sh [3] west build -b [3a] west build -b nucleo_h743zi [3b] west build -b nucleo_l053r8 ... [4] west flush @endverbatim `[1]` Open a terminal in the DPP example directory.
`[2]` If Zephyr project is not in your path, you might need to source the `zephyr-env.sh` shell script.
`[3]` build the example project, where `` is any of the boards supported by Zepyr. The example has been tested with the following boards:
`[3a]` nucleo_h743zi (ARM Cortex-M7)
`[3b]` nucleo_l053r8 (ARM Cortex-M0+)
`[4]` flash the board @remark The example has been tested with the following boards: ![STM32-NUCLEO-L053R8 board](bd_NUCLEO-L053R8.jpg)
![STM32-NUCLEO-H743ZI board](bd_NUCLEO-H743ZI.jpg) @note The example should also work with most boards supported by Zephyr. @section zephyr_dpp-output Sample Output Once flashed to the board, the application also produces ASCII output to the serial terminal (if supported by the board): @verbatim *** Booting Zephyr OS build v2.6.0-rc2-88-g3d39f72a88b3 *** Philo[4]->thinking Philo[3]->eating Philo[1]->thinking Philo[0]->eating Philo[4]->hungry Philo[3]->thinking Philo[2]->eating Philo[1]->hungry Philo[0]->thinking Philo[4]->eating Philo[3]->hungry Philo[0]->hungry Philo[4]->thinking Philo[0]->eating Philo[2]->thinking Philo[3]->eating Philo[4]->hungry Philo[2]->hungry Philo[3]->thinking Philo[2]->eating Philo[0]->thinking @endverbatim @section zephyr_dpp-qpspy Using the QP/SPY Software Tracing The @ref zephyr "QP/C Zephyr port" supports the [QSPY Software Tracing](https://www.state-machine.com/qtools/qpspy.html) option and will add the appropriate macros and files to build the "QSPY" configuration. If you wish to enable "QSPY" you can provide the option "QSPY" in the command-line for the build. For example: @verbatim west build -b nucleo_h743zi -- -DQSPY=ON @endverbatim @note The QP/Spy software tracing uses the Zephyr's console UART. This means that the Zephyr `printk()` facility cannot be used while QP/Spy is configured. If yo have built the example with QP/Spy, you might want to watch the QP/Spy output. @section zephyr_dpp-qspy The QSPY Host Utility To receive the QP/Spy software tracing output you need to run a special [qspy host application](https://www.state-machine.com/qtools/qspy.html). @note You might need to build the `qspy` host utility on your Linux machine. The QSPY utility is available in [QTools collection](https://github.com/QuantumLeaps/qtools/tree/master/qspy). To launch the `qspy` host utility, open a separate terminal and run @verbatim qspy -c ``` specific example: ``` qspy -c /dev/ttyACM0 @endverbatim @subsection @section zephyr_dpp-qs-output QSPY Output Example After resetting the board, you should see output similar to the following: @verbatim ########## Trg-RST QP-Ver=701,Build=220810_150847 Obj-Dict 0x20003154->QS_RX Obj-Dict 0x20000680->AO_Table Obj-Dict 0x20000180->AO_Philo[0] Obj-Dict 0x20000280->AO_Philo[1] Obj-Dict 0x20000380->AO_Philo[2] Obj-Dict 0x20000480->AO_Philo[3] Obj-Dict 0x20000580->AO_Philo[4] Obj-Dict 0x0000A52C->timerID Usr-Dict 00000100->PHILO_STAT Usr-Dict 00000101->PAUSED_STAT Usr-Dict 00000102->COMMAND_STAT Usr-Dict 00000103->CONTEXT_SW Obj-Dict 0x20003054->EvtPool1 Obj-Dict 0x20000180->Philo::inst[0] Obj-Dict 0x2000026C->Philo::inst[0].m_timeEvt Obj-Dict 0x20000280->Philo::inst[1] Obj-Dict 0x2000036C->Philo::inst[1].m_timeEvt Obj-Dict 0x20000380->Philo::inst[2] Obj-Dict 0x2000046C->Philo::inst[2].m_timeEvt Obj-Dict 0x20000480->Philo::inst[3] Obj-Dict 0x2000056C->Philo::inst[3].m_timeEvt Obj-Dict 0x20000580->Philo::inst[4] Obj-Dict 0x2000066C->Philo::inst[4].m_timeEvt Fun-Dict 0x00008929->Philo::initial Fun-Dict 0x0000890F->Philo::thinking Fun-Dict 0x00008917->Philo::hungry Fun-Dict 0x0000891F->Philo::eating Sig-Dict 00000004,Obj=0x00000000->TIMEOUT_SIG 0000000327 AO-Subsc Obj=Philo::inst[0],Sig=00000005,Obj=0x20000180 0000000327 AO-Subsc Obj=Philo::inst[0],Sig=00000009,Obj=0x20000180 ===RTC===> St-Init Obj=Philo::inst[0],State=0x00009B1B->Philo::thinking ===RTC===> St-Entry Obj=Philo::inst[0],State=Philo::thinking 0000000328 Init===> Obj=Philo::inst[0],State=Philo::thinking 0000000334 AO-Subsc Obj=Philo::inst[1],Sig=00000005,Obj=0x20000280 0000000334 AO-Subsc Obj=Philo::inst[1],Sig=00000009,Obj=0x20000280 ===RTC===> St-Init Obj=Philo::inst[1],State=0x00009B1B->Philo::thinking ===RTC===> St-Entry Obj=Philo::inst[1],State=Philo::thinking 0000000334 Init===> Obj=Philo::inst[1],State=Philo::thinking 0000000340 AO-Subsc Obj=Philo::inst[2],Sig=00000005,Obj=0x20000380 0000000340 AO-Subsc Obj=Philo::inst[2],Sig=00000009,Obj=0x20000380 ===RTC===> St-Init Obj=Philo::inst[2],State=0x00009B1B->Philo::thinking ===RTC===> St-Entry Obj=Philo::inst[2],State=Philo::thinking 0000000340 Init===> Obj=Philo::inst[2],State=Philo::thinking 0000000346 AO-Subsc Obj=Philo::inst[3],Sig=00000005,Obj=0x20000480 0000000346 AO-Subsc Obj=Philo::inst[3],Sig=00000009,Obj=0x20000480 ===RTC===> St-Init Obj=Philo::inst[3],State=0x00009B1B->Philo::thinking ===RTC===> St-Entry Obj=Philo::inst[3],State=Philo::thinking 0000000346 Init===> Obj=Philo::inst[3],State=Philo::thinking 0000000352 AO-Subsc Obj=Philo::inst[4],Sig=00000005,Obj=0x20000580 0000000352 AO-Subsc Obj=Philo::inst[4],Sig=00000009,Obj=0x20000580 ===RTC===> St-Init Obj=Philo::inst[4],State=0x00009B1B->Philo::thinking ===RTC===> St-Entry Obj=Philo::inst[4],State=Philo::thinking 0000000352 Init===> Obj=Philo::inst[4],State=Philo::thinking Obj-Dict 0x20000680->Table::inst Sig-Dict 00000006,Obj=0x00000000->DONE_SIG Sig-Dict 00000005,Obj=0x00000000->EAT_SIG Sig-Dict 00000007,Obj=0x00000000->PAUSE_SIG Sig-Dict 00000008,Obj=0x00000000->SERVE_SIG Sig-Dict 00000009,Obj=0x00000000->TEST_SIG Sig-Dict 00000011,Obj=0x20000680->HUNGRY_SIG 0000000370 AO-Subsc Obj=Table::inst,Sig=DONE_SIG 0000000370 AO-Subsc Obj=Table::inst,Sig=PAUSE_SIG 0000000370 AO-Subsc Obj=Table::inst,Sig=SERVE_SIG 0000000371 AO-Subsc Obj=Table::inst,Sig=TEST_SIG 0000000371 PHILO_STAT 0 thinking 0000000371 PHILO_STAT 1 thinking 0000000371 PHILO_STAT 2 thinking 0000000371 PHILO_STAT 3 thinking @endverbatim @next{exa_os} */ } // namespace QP