qpc/doxygen/exa_apps.dox

143 lines
6.7 KiB
Plaintext
Raw Normal View History

2015-04-28 13:45:35 -04:00
/*##########################################################################*/
/*! @page exa_apps Example Applications
<p>To demonstrate QP/C features, you need to create an application that does "something interesting". Instead of inventing this "something interesting" for each and every example, most of the example projects implement one of the three example applications, which are described on the separate pages:
</p>
- @subpage blinky
- @subpage dpp
- @subpage game
2016-11-01 15:38:29 -04:00
- @subpage pelican
2015-04-28 13:45:35 -04:00
2017-05-17 13:16:32 -04:00
Additionally, the QP/C distribution contains several application examples described in the <a class="extern" target="_blank" href="https://www.state-machine.com/psicc2">PSiCC2</a> book.
- Calculator example from Chapter 2 of PSiCC2
- Orthogonal Component design pattern
- Orthogonal Component with QM model design pattern
- Deferred Event design pattern
- Transition-to-History (with ::QHsm class)
- Transition-to-History (with ::QMsm class)
- QMsmTst Test State Machine based on QP::QMsm with QM model
- QHsmTst Test State Machine based on QP::QHsm with QM model
- Reminder design pattern from Chapter 5 of PSiCC2
2016-11-01 15:38:29 -04:00
- Reminder design pattern different version
@next{blinky}
2015-04-28 13:45:35 -04:00
*/
/*##########################################################################*/
/*! @page blinky Simple Blinky Application
<p>The ultra-simple Blinky example is the embedded systems' equivalent of the venerable <i>"Hello World!"</i> program, that is, the simplest possible working QP application that does "something". In the case of Blinky, this "something" is blinking an LED at the rate of 1Hz, where an LED turns on and remains on for 0.5 seconds on then turns off and remains off for 0.5 seconds.
</p>
@image html blinky_ek-tm4c123gxl.gif Blinky on EK-TM4C123GLX (TivaC LaunchPad)
The ultra-simple Blinky application, which consists of just one active object named `Blinky`, is intentionally kept small and illustrates only the most basic QP features, such as:
- defining a simple Blinky active object (AO) @ref oop "class";
- hand-coding the simple state machine of the Blinky AO;
- using a periodic time event;
- initializing the QP framework; and
- starting an AO.
------------------------------------------------------------------------------
@section blinky_sm State Machine
The very simple state machine of the Blinky AO is shown in the figure below:
2017-05-17 13:16:32 -04:00
@image html SM_blinky.png "State Machine of the Blinky AO"
2015-04-28 13:45:35 -04:00
<ul class="tag">
<li><span class="tag">1</span> The top-most initial transition in this state machine arms a QP time event (QTimeEvt_armX()) to deliver the `TIMEOUT` signal every half second, so that the LED can stay on for one half second and off for the other half.
</li>
<li><span class="tag">2</span> The initial transition leads to state "off", which turns the LED off in the entry action (`BSP_ledOff()`).
</li>
<li><span class="tag">3</span> When the `TIMEOUT` event arrives in the "off" state, the "off" state transitions to the "on" state
</li>
<li><span class="tag">4</span> The "on" state turns the LED on in the entry action (`BSP_ledOn()`).
</li>
<li><span class="tag">5</span> When the `TIMEOUT` event arrives in the "on" state, the "on" state transitions back to "off", which cases execution of the entry action, in which the LED is turned off. From that point on the cycle repeats forever because the `TIMEOUT` events keep getting generated at the pre-determined rate.
</li>
</ul>
2015-09-04 12:08:22 -04:00
------------------------------------------------------------------------------
@section blinky_code State Machine Code
The Blinky state machine shown above is implemented in the blinky.c source file, as shown in the
listing below. The code has been specifically organized not to access target resources directly, but instead encapsulate all such access in the calls to the BSP (Board Support Package). So for example, instead of turning the LED on and off by writing to a specific GPIO register on an embedded board, the code calls the BSP functions `BSP_ledOn()` and `BSP_ledOff()`. These functions can then be defined differently for each Target board (or even a desktop workstation), without the need to change the state machine code.
@note
The Blinky source code (blinky.c) is actually the same on all platforms, including Windows
2016-11-01 15:38:29 -04:00
and the embedded boards. The only difference is in the Board Support Package (bsp.c), which is
2015-09-04 12:08:22 -04:00
specific for the target.
@includelineno examples/arm-cm/blinky_ek-tm4c123gxl/blinky.c
As you can see, the structure of the state machine is very clearly recognizable in this code. Please refer to the Application Note <a class="extern" target="_blank" href="http://state-machine.com/doc/AN_Crash_Course_in_UML_State_Machines.pdf">A Crash Course in UML State Machines</a> for exact explanation of the state machine coding techniques.
@subsection blinky_ao Defining Active Object (AO) Class
- hand-coding the simple state machine of the Blinky AO;
- using a periodic time event;
- initializing the QP framework; and
- starting an AO.
2015-04-28 13:45:35 -04:00
@next{dpp}
*/
/*##########################################################################*/
/*! @page dpp Dining Philosophers Problem (DPP)
2017-05-17 13:16:32 -04:00
The Dining Philosophers Problem (DPP) example is described in the <a class="extern" target="_blank" href="https://www.state-machine.com/doc/AN_DPP.pdf">Application Note: Dining Philosophers Problem (DPP) Example</a>.
2015-05-01 08:40:16 -04:00
2016-11-01 15:38:29 -04:00
@htmlonly
<div class="image">
2017-05-17 13:16:32 -04:00
<a target="_blank" href="https://www.state-machine.com/doc/AN_DPP.pdf"><img border="0" src="img/AN.jpg" title="Download PDF"></a>
2016-11-01 15:38:29 -04:00
<div class="caption">
Application Note: Dining Philosophers Problem (DPP) Example
</div>
</div>
@endhtmlonly
2015-05-01 08:40:16 -04:00
2015-04-28 13:45:35 -04:00
@next{game}
*/
/*##########################################################################*/
/*! @page game "Fly 'n' Shoot" Game
2017-05-17 13:16:32 -04:00
The "Fly 'n' Shoot" game example is described in the <a class="extern" target="_blank" href="https://www.state-machine.com/doc/AN_Fly-n-Shoot.pdf">Application Note: Fly 'n' Shoot Game Example</a>.
2016-11-01 15:38:29 -04:00
@htmlonly
<div class="image">
2017-05-17 13:16:32 -04:00
<a target="_blank" href="https://www.state-machine.com/doc/AN_Fly-n-Shoot.pdf"><img border="0" src="img/AN.jpg" title="Download PDF"></a>
2016-11-01 15:38:29 -04:00
<div class="caption">
Application Note: Fly 'n' Shoot Game Example
</div>
</div>
@endhtmlonly
@next{pelican}
*/
/*##########################################################################*/
/*! @page pelican PEdestrian LIgtht CONtrolled (PELICAN) Crossing
2017-05-17 13:16:32 -04:00
The "Fly 'n' Shoot" game example is described in the <a class="extern" target="_blank" href="https://www.state-machine.com/doc/AN_PELICAN.pdf">Application Note: PEdestrian LIght CONtrolled (PELICAN) Crossing Example</a>.
2015-05-01 08:40:16 -04:00
2016-11-01 15:38:29 -04:00
@htmlonly
<div class="image">
2017-05-17 13:16:32 -04:00
<a target="_blank" href="https://www.state-machine.com/doc/AN_PELICAN.pdf"><img border="0" src="img/AN.jpg" title="Download PDF"></a>
2016-11-01 15:38:29 -04:00
<div class="caption">
Application Note: PEdestrian LIght CONtrolled (PELICAN) Crossing Example
</div>
</div>
@endhtmlonly
2015-05-01 08:40:16 -04:00
2016-11-01 15:38:29 -04:00
@next{ports}
2015-04-28 13:45:35 -04:00
*/