Skip to content

Commit bcb5244

Browse files
committed
6.9.2
Added back qpn_avr library for backwards compatitility
1 parent 478a5c6 commit bcb5244

File tree

25 files changed

+5662
-1
lines changed

25 files changed

+5662
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ the whole `qp-<ver>_arduino-1.8.x.zip` archive to this folder.
2121
----
2222
# Provided Libraries and Tools
2323

24-
The archive `qp-<ver>_arduino-1.8.x.zip` contains one external library
24+
The archive `qp-<ver>_arduino-1.8.x.zip` contains two external libraries
2525
for SAM-based Arduinos:
2626

2727
- `qpcpp_sam` -- QP/C++ framework for SAM-based Arduinos
28+
- `qpn_avr` -- QP-nano framework for AVR-based Arduinos
29+
30+
NOTE: qpn_avr is now obsolete. It is provided for backgwards compatibility only!
31+
2832

2933
The archive also contains the QM modeling tool for Windows
3034

@@ -46,6 +50,10 @@ as follows:
4650
| | | +-... - QP/C++ library sources
4751
| | +-library.properties - QP/C++ library properties
4852
| |
53+
+-libraries/ - libraries folder
54+
| +-qpn_avr/ - QP-nano library for AVR-based Arduinos
55+
| | +-... (now obsolete, for backgwards compatibility only)
56+
| |
4957
| +-qm/ - QM modeling tool for Windows
5058
| | +-bin/ - QM binaries (executable and DLLs)
5159
| | | +-qm.exe - QM executable for Windows
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*.$file${.::blinky.ino} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
2+
/*
3+
* Model: blinky.qm
4+
* File: ${.::blinky.ino}
5+
*
6+
* This code has been generated by QM 5.1.0 <www.state-machine.com/qm/>.
7+
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8+
*
9+
* This program is open source software: you can redistribute it and/or
10+
* modify it under the terms of the GNU General Public License as published
11+
* by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful, but
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16+
* for more details.
17+
*/
18+
/*.$endhead${.::blinky.ino} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
19+
#include "qpn.h" // QP-nano framework for Arduino
20+
21+
#include "Arduino.h" // Main include file for the Arduino SDK
22+
23+
//============================================================================
24+
// declare all AO classes...
25+
/*.$declare${AOs::Blinky} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
26+
/*.${AOs::Blinky} ..........................................................*/
27+
typedef struct Blinky {
28+
/* protected: */
29+
QActive super;
30+
} Blinky;
31+
32+
/* protected: */
33+
static QState Blinky_initial(Blinky * const me);
34+
static QState Blinky_off(Blinky * const me);
35+
static QState Blinky_on(Blinky * const me);
36+
/*.$enddecl${AOs::Blinky} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
37+
//...
38+
39+
// AO instances and event queue buffers for them...
40+
Blinky AO_Blinky;
41+
static QEvt l_blinkyQSto[10]; // Event queue storage for Blinky
42+
//...
43+
44+
//============================================================================
45+
// QF_active[] array defines all active object control blocks ----------------
46+
QActiveCB const Q_ROM QF_active[] = {
47+
{ (QActive *)0, (QEvt *)0, 0U },
48+
{ (QActive *)&AO_Blinky, l_blinkyQSto, Q_DIM(l_blinkyQSto) }
49+
};
50+
51+
//============================================================================
52+
// various constants for the application...
53+
enum {
54+
BSP_TICKS_PER_SEC = 100, // number of system clock ticks in one second
55+
LED_L = 13 // the pin number of the on-board LED (L)
56+
};
57+
58+
//............................................................................
59+
void setup() {
60+
// initialize the QF-nano framework
61+
QF_init(Q_DIM(QF_active));
62+
63+
// initialize all AOs...
64+
QActive_ctor(&AO_Blinky.super, Q_STATE_CAST(&Blinky_initial));
65+
66+
// initialize the hardware used in this sketch...
67+
pinMode(LED_L, OUTPUT); // set the LED-L pin to output
68+
}
69+
70+
//............................................................................
71+
void loop() {
72+
QF_run(); // run the QF-nano framework
73+
}
74+
75+
//============================================================================
76+
// interrupts...
77+
ISR(TIMER2_COMPA_vect) {
78+
QF_tickXISR(0); // process time events for tick rate 0
79+
}
80+
81+
//============================================================================
82+
// QF callbacks...
83+
void QF_onStartup(void) {
84+
// set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking...
85+
TCCR2A = (1U << WGM21) | (0U << WGM20);
86+
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); // 1/2^10
87+
ASSR &= ~(1U << AS2);
88+
TIMSK2 = (1U << OCIE2A); // enable TIMER2 compare Interrupt
89+
TCNT2 = 0U;
90+
91+
// set the output-compare register based on the desired tick frequency
92+
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
93+
}
94+
//............................................................................
95+
void QV_onIdle(void) { // called with interrupts DISABLED
96+
// Put the CPU and peripherals to the low-power mode. You might
97+
// need to customize the clock management for your application,
98+
// see the datasheet for your particular AVR MCU.
99+
SMCR = (0 << SM0) | (1 << SE); // idle mode, adjust to your project
100+
QV_CPU_SLEEP(); // atomically go to sleep and enable interrupts
101+
}
102+
//............................................................................
103+
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int location) {
104+
// implement the error-handling policy for your application!!!
105+
(void)module;
106+
(void)location;
107+
QF_INT_DISABLE(); // disable all interrupts
108+
QF_RESET(); // reset the CPU
109+
for (;;) {
110+
}
111+
}
112+
113+
//============================================================================
114+
// define all AO classes (state machine)...
115+
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
116+
/*. Check for the minimum required QP version */
117+
#if (QP_VERSION < 680U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
118+
#error qpn version 6.8.0 or higher required
119+
#endif
120+
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
121+
/*.$define${AOs::Blinky} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
122+
/*.${AOs::Blinky} ..........................................................*/
123+
/*.${AOs::Blinky::SM} ......................................................*/
124+
static QState Blinky_initial(Blinky * const me) {
125+
/*.${AOs::Blinky::SM::initial} */
126+
QActive_armX((QActive *)me, 0U,
127+
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);
128+
return Q_TRAN(&Blinky_off);
129+
}
130+
/*.${AOs::Blinky::SM::off} .................................................*/
131+
static QState Blinky_off(Blinky * const me) {
132+
QState status_;
133+
switch (Q_SIG(me)) {
134+
/*.${AOs::Blinky::SM::off} */
135+
case Q_ENTRY_SIG: {
136+
digitalWrite(LED_L, LOW);
137+
status_ = Q_HANDLED();
138+
break;
139+
}
140+
/*.${AOs::Blinky::SM::off::Q_TIMEOUT} */
141+
case Q_TIMEOUT_SIG: {
142+
status_ = Q_TRAN(&Blinky_on);
143+
break;
144+
}
145+
default: {
146+
status_ = Q_SUPER(&QHsm_top);
147+
break;
148+
}
149+
}
150+
return status_;
151+
}
152+
/*.${AOs::Blinky::SM::on} ..................................................*/
153+
static QState Blinky_on(Blinky * const me) {
154+
QState status_;
155+
switch (Q_SIG(me)) {
156+
/*.${AOs::Blinky::SM::on} */
157+
case Q_ENTRY_SIG: {
158+
digitalWrite(LED_L, HIGH);
159+
status_ = Q_HANDLED();
160+
break;
161+
}
162+
/*.${AOs::Blinky::SM::on::Q_TIMEOUT} */
163+
case Q_TIMEOUT_SIG: {
164+
status_ = Q_TRAN(&Blinky_off);
165+
break;
166+
}
167+
default: {
168+
status_ = Q_SUPER(&QHsm_top);
169+
break;
170+
}
171+
}
172+
return status_;
173+
}
174+
/*.$enddef${AOs::Blinky} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
175+
//...
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<model version="5.1.0" links="0">
3+
<documentation>This is the Blinky example for the Arduino-UNO board, which blinks the on-board LED (L) once per second. The example demonstrates:
4+
5+
1. One active object class &quot;Blinky&quot; (inside the package &quot;AOs&quot;)
6+
2. A simple state machine</documentation>
7+
<framework name="qpn"/>
8+
<package name="AOs" stereotype="0x02">
9+
<class name="Blinky" superclass="qpn::QActive">
10+
<statechart properties="0x01">
11+
<initial target="../1">
12+
<action> QActive_armX((QActive *)me, 0U,
13+
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);</action>
14+
<initial_glyph conn="2,3,5,1,24,4,-2">
15+
<action box="0,-2,6,2"/>
16+
</initial_glyph>
17+
</initial>
18+
<state name="off">
19+
<entry brief="LED off">digitalWrite(LED_L, LOW);</entry>
20+
<tran trig="Q_TIMEOUT" target="../../2">
21+
<tran_glyph conn="2,13,3,1,24,7,-2">
22+
<action box="0,-2,8,2"/>
23+
</tran_glyph>
24+
</tran>
25+
<state_glyph node="2,5,22,11">
26+
<entry box="1,2,17,4"/>
27+
</state_glyph>
28+
</state>
29+
<state name="on">
30+
<entry brief="LED on">digitalWrite(LED_L, HIGH);</entry>
31+
<tran trig="Q_TIMEOUT" target="../../1">
32+
<tran_glyph conn="2,26,3,1,26,-16,-4">
33+
<action box="0,-2,8,2"/>
34+
</tran_glyph>
35+
</tran>
36+
<state_glyph node="2,18,22,10">
37+
<entry box="1,2,15,4"/>
38+
</state_glyph>
39+
</state>
40+
<state_diagram size="30,30"/>
41+
</statechart>
42+
</class>
43+
</package>
44+
<directory name=".">
45+
<file name="blinky.ino">
46+
<text>#include &quot;qpn.h&quot; // QP-nano framework for Arduino
47+
48+
#include &quot;Arduino.h&quot; // Main include file for the Arduino SDK
49+
50+
//============================================================================
51+
// declare all AO classes...
52+
$declare${AOs::Blinky}
53+
//...
54+
55+
// AO instances and event queue buffers for them...
56+
Blinky AO_Blinky;
57+
static QEvt l_blinkyQSto[10]; // Event queue storage for Blinky
58+
//...
59+
60+
//============================================================================
61+
// QF_active[] array defines all active object control blocks ----------------
62+
QActiveCB const Q_ROM QF_active[] = {
63+
{ (QActive *)0, (QEvt *)0, 0U },
64+
{ (QActive *)&amp;AO_Blinky, l_blinkyQSto, Q_DIM(l_blinkyQSto) }
65+
};
66+
67+
//============================================================================
68+
// various constants for the application...
69+
enum {
70+
BSP_TICKS_PER_SEC = 100, // number of system clock ticks in one second
71+
LED_L = 13 // the pin number of the on-board LED (L)
72+
};
73+
74+
//............................................................................
75+
void setup() {
76+
// initialize the QF-nano framework
77+
QF_init(Q_DIM(QF_active));
78+
79+
// initialize all AOs...
80+
QActive_ctor(&amp;AO_Blinky.super, Q_STATE_CAST(&amp;Blinky_initial));
81+
82+
// initialize the hardware used in this sketch...
83+
pinMode(LED_L, OUTPUT); // set the LED-L pin to output
84+
}
85+
86+
//............................................................................
87+
void loop() {
88+
QF_run(); // run the QF-nano framework
89+
}
90+
91+
//============================================================================
92+
// interrupts...
93+
ISR(TIMER2_COMPA_vect) {
94+
QF_tickXISR(0); // process time events for tick rate 0
95+
}
96+
97+
//============================================================================
98+
// QF callbacks...
99+
void QF_onStartup(void) {
100+
// set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking...
101+
TCCR2A = (1U &lt;&lt; WGM21) | (0U &lt;&lt; WGM20);
102+
TCCR2B = (1U &lt;&lt; CS22 ) | (1U &lt;&lt; CS21) | (1U &lt;&lt; CS20); // 1/2^10
103+
ASSR &amp;= ~(1U &lt;&lt; AS2);
104+
TIMSK2 = (1U &lt;&lt; OCIE2A); // enable TIMER2 compare Interrupt
105+
TCNT2 = 0U;
106+
107+
// set the output-compare register based on the desired tick frequency
108+
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
109+
}
110+
//............................................................................
111+
void QV_onIdle(void) { // called with interrupts DISABLED
112+
// Put the CPU and peripherals to the low-power mode. You might
113+
// need to customize the clock management for your application,
114+
// see the datasheet for your particular AVR MCU.
115+
SMCR = (0 &lt;&lt; SM0) | (1 &lt;&lt; SE); // idle mode, adjust to your project
116+
QV_CPU_SLEEP(); // atomically go to sleep and enable interrupts
117+
}
118+
//............................................................................
119+
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int location) {
120+
// implement the error-handling policy for your application!!!
121+
(void)module;
122+
(void)location;
123+
QF_INT_DISABLE(); // disable all interrupts
124+
QF_RESET(); // reset the CPU
125+
for (;;) {
126+
}
127+
}
128+
129+
//============================================================================
130+
// define all AO classes (state machine)...
131+
$define${AOs::Blinky}
132+
//...
133+
</text>
134+
</file>
135+
</directory>
136+
</model>

0 commit comments

Comments
 (0)