Skip to content

Commit 3d3bc45

Browse files
committed
6.9.4
Added QS-TX/RX to qpcpp library and examples
1 parent eec2050 commit 3d3bc45

33 files changed

+4260
-822
lines changed

GPLv3.txt LICENSE.txt

+674-674
Large diffs are not rendered by default.

libraries/qpcpp_arm-cm/examples/blinky-sam/blinky-sam.ino

+18-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void loop() {
7070
// interrupts.................................................................
7171
void TIMER_HANDLER(void) {
7272
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
73-
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
73+
QF::TICK_X(0, nullptr); // process time events for tick rate 0
7474
}
7575
//............................................................................
7676
void QF::onStartup(void) {
@@ -122,6 +122,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int location) {
122122
}
123123
}
124124

125+
//============================================================================
126+
// dummy QS callbacks...
127+
128+
//............................................................................
129+
void QP::QS::onCleanup(void) {
130+
}
131+
//............................................................................
132+
QP::QSTimeCtr QP::QS::onGetTime(void) {
133+
return 0U;
134+
}
135+
//............................................................................
136+
void QP::QS::onFlush(void) {
137+
}
138+
//............................................................................
139+
void QP::QS::onReset(void) {
140+
}
141+
125142
//============================================================================
126143
// generate declarations and definitions of all AO classes (state machines)...
127144
//.$declare${AOs::Blinky} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

libraries/qpcpp_arm-cm/examples/blinky-sam/blinky-sam.qm

+18-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void loop() {
119119
// interrupts.................................................................
120120
void TIMER_HANDLER(void) {
121121
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
122-
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
122+
QF::TICK_X(0, nullptr); // process time events for tick rate 0
123123
}
124124
//............................................................................
125125
void QF::onStartup(void) {
@@ -171,6 +171,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int locat
171171
}
172172
}
173173

174+
//============================================================================
175+
// dummy QS callbacks...
176+
177+
//............................................................................
178+
void QP::QS::onCleanup(void) {
179+
}
180+
//............................................................................
181+
QP::QSTimeCtr QP::QS::onGetTime(void) {
182+
return 0U;
183+
}
184+
//............................................................................
185+
void QP::QS::onFlush(void) {
186+
}
187+
//............................................................................
188+
void QP::QS::onReset(void) {
189+
}
190+
174191
//============================================================================
175192
// generate declarations and definitions of all AO classes (state machines)...
176193
$declare${AOs::Blinky}

libraries/qpcpp_arm-cm/examples/blinky2-sam/blinky2-sam.ino

+19-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void loop() {
8080
// interrupts.................................................................
8181
void TIMER_HANDLER(void) {
8282
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
83-
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
83+
QF::TICK_X(0, nullptr); // process time events for tick rate 0
8484
}
8585
//............................................................................
8686
void QF::onStartup(void) {
@@ -107,6 +107,7 @@ void QF::onStartup(void) {
107107
NVIC_EnableIRQ(TIMER_IRQn);
108108
// ...
109109
}
110+
110111
//............................................................................
111112
void QV::onIdle(void) { // called with interrupts DISABLED
112113
#ifdef NDEBUG
@@ -132,6 +133,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int location) {
132133
}
133134
}
134135

136+
//============================================================================
137+
// dummy QS callbacks...
138+
139+
//............................................................................
140+
void QP::QS::onCleanup(void) {
141+
}
142+
//............................................................................
143+
QP::QSTimeCtr QP::QS::onGetTime(void) {
144+
return 0U;
145+
}
146+
//............................................................................
147+
void QP::QS::onFlush(void) {
148+
}
149+
//............................................................................
150+
void QP::QS::onReset(void) {
151+
}
152+
135153
//============================================================================
136154
// generate declarations and definitions of all AO classes (state machines)...
137155
//.$declare${AOs::Blinky} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

libraries/qpcpp_arm-cm/examples/blinky2-sam/blinky2-sam.qm

+19-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void loop() {
173173
// interrupts.................................................................
174174
void TIMER_HANDLER(void) {
175175
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
176-
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
176+
QF::TICK_X(0, nullptr); // process time events for tick rate 0
177177
}
178178
//............................................................................
179179
void QF::onStartup(void) {
@@ -200,6 +200,7 @@ void QF::onStartup(void) {
200200
NVIC_EnableIRQ(TIMER_IRQn);
201201
// ...
202202
}
203+
203204
//............................................................................
204205
void QV::onIdle(void) { // called with interrupts DISABLED
205206
#ifdef NDEBUG
@@ -225,6 +226,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int locat
225226
}
226227
}
227228

229+
//============================================================================
230+
// dummy QS callbacks...
231+
232+
//............................................................................
233+
void QP::QS::onCleanup(void) {
234+
}
235+
//............................................................................
236+
QP::QSTimeCtr QP::QS::onGetTime(void) {
237+
return 0U;
238+
}
239+
//............................................................................
240+
void QP::QS::onFlush(void) {
241+
}
242+
//............................................................................
243+
void QP::QS::onReset(void) {
244+
}
245+
228246
//============================================================================
229247
// generate declarations and definitions of all AO classes (state machines)...
230248
$declare${AOs::Blinky}

libraries/qpcpp_arm-cm/examples/blinky_bsp-sam/blinky_bsp-sam.ino

+8-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@ Blinky::Blinky()
7878
//.${AOs::Blinky::SM} ........................................................
7979
Q_STATE_DEF(Blinky, initial) {
8080
//.${AOs::Blinky::SM::initial}
81-
m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);
8281
(void)e; // unused parameter
82+
m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);
83+
84+
QS_OBJ_DICTIONARY(&Blinky::instance);
85+
QS_SIG_DICTIONARY(TIMEOUT_SIG, nullptr);
86+
87+
QS_FUN_DICTIONARY(&Blinky::off);
88+
QS_FUN_DICTIONARY(&Blinky::on);
89+
8390
return tran(&off);
8491
}
8592
//.${AOs::Blinky::SM::off} ...................................................

libraries/qpcpp_arm-cm/examples/blinky_bsp-sam/blinky_bsp-sam.qm

+100-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ This structure of the code is recommended for applications with only one active
2828
<code>: QActive(Q_STATE_CAST(&amp;Blinky::initial)),
2929
m_timeEvt(this, TIMEOUT_SIG, 0U)</code>
3030
</operation>
31-
<statechart properties="0x00">
31+
<statechart properties="0x02">
3232
<initial target="../1">
33-
<action>m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);
34-
(void)e; // unused parameter</action>
33+
<action>(void)e; // unused parameter
34+
m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);
35+
36+
QS_OBJ_DICTIONARY(&amp;Blinky::instance);
37+
QS_SIG_DICTIONARY(TIMEOUT_SIG, nullptr);</action>
3538
<initial_glyph conn="2,2,5,1,20,8,-4">
3639
<action box="0,-2,32,6"/>
3740
</initial_glyph>
@@ -89,6 +92,14 @@ public:
8992

9093
using namespace QP;
9194

95+
//----------------------------------------------------------------------------
96+
// QS facilities
97+
98+
// un-comment if QS instrumentation needed
99+
//#define QS_ON
100+
101+
static QP::QSpyId const l_TIMER_ID = { 0U }; // QSpy source ID
102+
92103
//----------------------------------------------------------------------------
93104
// BSP functions
94105

@@ -97,6 +108,18 @@ void BSP::init(void) {
97108
// initialize the hardware used in this sketch...
98109
// NOTE: interrupts are configured and started later in QF::onStartup()
99110
pinMode(LED_BUILTIN, OUTPUT);
111+
112+
#ifdef QS_ON
113+
QS_INIT(nullptr);
114+
115+
// output QS dictionaries...
116+
QS_OBJ_DICTIONARY(&amp;l_TIMER_ID);
117+
118+
// setup the QS filters...
119+
QS_GLB_FILTER(QP::QS_SM_RECORDS); // state machine records
120+
QS_GLB_FILTER(QP::QS_AO_RECORDS); // active object records
121+
QS_GLB_FILTER(QP::QS_UA_RECORDS); // all user records
122+
#endif
100123
}
101124
//............................................................................
102125
void BSP::ledOff(void) {
@@ -127,7 +150,7 @@ void BSP::ledOn(void) {
127150
// interrupts.................................................................
128151
void TIMER_HANDLER(void) {
129152
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
130-
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
153+
QF::TICK_X(0U, &amp;l_TIMER_ID); // process time events for tick rate 0
131154
}
132155
//............................................................................
133156
void QF::onStartup(void) {
@@ -155,6 +178,7 @@ void QF::onStartup(void) {
155178
NVIC_EnableIRQ(TIMER_IRQn);
156179
// ...
157180
}
181+
158182
//............................................................................
159183
void QV::onIdle(void) { // called with interrupts DISABLED
160184
#ifdef NDEBUG
@@ -164,6 +188,29 @@ void QV::onIdle(void) { // called with interrupts DISABLED
164188
QV_CPU_SLEEP(); // atomically go to sleep and enable interrupts
165189
#else
166190
QF_INT_ENABLE(); // simply re-enable interrupts
191+
192+
#ifdef QS_ON
193+
194+
// transmit QS outgoing data (QS-TX)
195+
uint16_t len = Serial.availableForWrite();
196+
if (len &gt; 0U) { // any space available in the output buffer?
197+
uint8_t const *buf = QS::getBlock(&amp;len);
198+
if (buf) {
199+
Serial.write(buf, len); // asynchronous and non-blocking
200+
}
201+
}
202+
203+
// receive QS incoming data (QS-RX)
204+
len = Serial.available();
205+
if (len &gt; 0U) {
206+
do {
207+
QP::QS::rxPut(Serial.read());
208+
} while (--len &gt; 0U);
209+
QS::rxParse();
210+
}
211+
212+
#endif // QS_ON
213+
167214
#endif
168215
}
169216
//............................................................................
@@ -180,6 +227,55 @@ extern &quot;C&quot; Q_NORETURN Q_onAssert(char const * const module, int locati
180227
}
181228
}
182229

230+
//----------------------------------------------------------------------------
231+
// QS callbacks...
232+
#ifdef QS_ON
233+
234+
//............................................................................
235+
bool QP::QS::onStartup(void const * arg) {
236+
static uint8_t qsTxBuf[1024]; // buffer for QS transmit channel (QS-TX)
237+
static uint8_t qsRxBuf[128]; // buffer for QS receive channel (QS-RX)
238+
initBuf (qsTxBuf, sizeof(qsTxBuf));
239+
rxInitBuf(qsRxBuf, sizeof(qsRxBuf));
240+
Serial.begin(115200); // run serial port at 115200 baud rate
241+
return true; // return success
242+
}
243+
//............................................................................
244+
void QP::QS::onCommand(uint8_t cmdId, uint32_t param1,
245+
uint32_t param2, uint32_t param3)
246+
{
247+
(void)cmdId;
248+
(void)param1;
249+
(void)param2;
250+
(void)param3;
251+
}
252+
253+
#endif // QS_ON
254+
255+
//............................................................................
256+
void QP::QS::onCleanup(void) {
257+
}
258+
//............................................................................
259+
QP::QSTimeCtr QP::QS::onGetTime(void) {
260+
return millis();
261+
}
262+
//............................................................................
263+
void QP::QS::onFlush(void) {
264+
#ifdef QS_ON
265+
uint16_t len = 0xFFFFU; // big number to get as many bytes as available
266+
uint8_t const *buf = QS::getBlock(&amp;len); // get continguous block of data
267+
while (buf != nullptr) { // data available?
268+
Serial.write(buf, len); // might poll until all bytes fit
269+
len = 0xFFFFU; // big number to get as many bytes as available
270+
buf = QS::getBlock(&amp;len); // try to get more data
271+
}
272+
Serial.flush(); // wait for the transmission of outgoing data to complete
273+
#endif // QS_ON
274+
}
275+
//............................................................................
276+
void QP::QS::onReset(void) {
277+
NVIC_SystemReset();
278+
}
183279
</text>
184280
</file>
185281
<file name="blinky.hpp">

0 commit comments

Comments
 (0)