Skip to content

Commit

Permalink
6.9.4
Browse files Browse the repository at this point in the history
Added QS-TX/RX to qpcpp library and examples
  • Loading branch information
quantum-leaps committed Jan 14, 2022
1 parent eec2050 commit 3d3bc45
Show file tree
Hide file tree
Showing 33 changed files with 4,260 additions and 822 deletions.
1,348 changes: 674 additions & 674 deletions GPLv3.txt → LICENSE.txt

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion libraries/qpcpp_arm-cm/examples/blinky-sam/blinky-sam.ino
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void loop() {
// interrupts.................................................................
void TIMER_HANDLER(void) {
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
QF::TICK_X(0, nullptr); // process time events for tick rate 0
}
//............................................................................
void QF::onStartup(void) {
Expand Down Expand Up @@ -122,6 +122,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int location) {
}
}

//============================================================================
// dummy QS callbacks...

//............................................................................
void QP::QS::onCleanup(void) {
}
//............................................................................
QP::QSTimeCtr QP::QS::onGetTime(void) {
return 0U;
}
//............................................................................
void QP::QS::onFlush(void) {
}
//............................................................................
void QP::QS::onReset(void) {
}

//============================================================================
// generate declarations and definitions of all AO classes (state machines)...
//.$declare${AOs::Blinky} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Expand Down
19 changes: 18 additions & 1 deletion libraries/qpcpp_arm-cm/examples/blinky-sam/blinky-sam.qm
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void loop() {
// interrupts.................................................................
void TIMER_HANDLER(void) {
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
QF::TICK_X(0, nullptr); // process time events for tick rate 0
}
//............................................................................
void QF::onStartup(void) {
Expand Down Expand Up @@ -171,6 +171,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int locat
}
}

//============================================================================
// dummy QS callbacks...

//............................................................................
void QP::QS::onCleanup(void) {
}
//............................................................................
QP::QSTimeCtr QP::QS::onGetTime(void) {
return 0U;
}
//............................................................................
void QP::QS::onFlush(void) {
}
//............................................................................
void QP::QS::onReset(void) {
}

//============================================================================
// generate declarations and definitions of all AO classes (state machines)...
$declare${AOs::Blinky}
Expand Down
20 changes: 19 additions & 1 deletion libraries/qpcpp_arm-cm/examples/blinky2-sam/blinky2-sam.ino
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void loop() {
// interrupts.................................................................
void TIMER_HANDLER(void) {
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
QF::TICK_X(0, nullptr); // process time events for tick rate 0
}
//............................................................................
void QF::onStartup(void) {
Expand All @@ -107,6 +107,7 @@ void QF::onStartup(void) {
NVIC_EnableIRQ(TIMER_IRQn);
// ...
}

//............................................................................
void QV::onIdle(void) { // called with interrupts DISABLED
#ifdef NDEBUG
Expand All @@ -132,6 +133,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int location) {
}
}

//============================================================================
// dummy QS callbacks...

//............................................................................
void QP::QS::onCleanup(void) {
}
//............................................................................
QP::QSTimeCtr QP::QS::onGetTime(void) {
return 0U;
}
//............................................................................
void QP::QS::onFlush(void) {
}
//............................................................................
void QP::QS::onReset(void) {
}

//============================================================================
// generate declarations and definitions of all AO classes (state machines)...
//.$declare${AOs::Blinky} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Expand Down
20 changes: 19 additions & 1 deletion libraries/qpcpp_arm-cm/examples/blinky2-sam/blinky2-sam.qm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void loop() {
// interrupts.................................................................
void TIMER_HANDLER(void) {
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
QF::TICK_X(0, nullptr); // process time events for tick rate 0
}
//............................................................................
void QF::onStartup(void) {
Expand All @@ -200,6 +200,7 @@ void QF::onStartup(void) {
NVIC_EnableIRQ(TIMER_IRQn);
// ...
}

//............................................................................
void QV::onIdle(void) { // called with interrupts DISABLED
#ifdef NDEBUG
Expand All @@ -225,6 +226,23 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int locat
}
}

//============================================================================
// dummy QS callbacks...

//............................................................................
void QP::QS::onCleanup(void) {
}
//............................................................................
QP::QSTimeCtr QP::QS::onGetTime(void) {
return 0U;
}
//............................................................................
void QP::QS::onFlush(void) {
}
//............................................................................
void QP::QS::onReset(void) {
}

//============================================================================
// generate declarations and definitions of all AO classes (state machines)...
$declare${AOs::Blinky}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,15 @@ Blinky::Blinky()
//.${AOs::Blinky::SM} ........................................................
Q_STATE_DEF(Blinky, initial) {
//.${AOs::Blinky::SM::initial}
m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);
(void)e; // unused parameter
m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);

QS_OBJ_DICTIONARY(&Blinky::instance);
QS_SIG_DICTIONARY(TIMEOUT_SIG, nullptr);

QS_FUN_DICTIONARY(&Blinky::off);
QS_FUN_DICTIONARY(&Blinky::on);

return tran(&off);
}
//.${AOs::Blinky::SM::off} ...................................................
Expand Down
104 changes: 100 additions & 4 deletions libraries/qpcpp_arm-cm/examples/blinky_bsp-sam/blinky_bsp-sam.qm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ This structure of the code is recommended for applications with only one active
<code>: QActive(Q_STATE_CAST(&amp;Blinky::initial)),
m_timeEvt(this, TIMEOUT_SIG, 0U)</code>
</operation>
<statechart properties="0x00">
<statechart properties="0x02">
<initial target="../1">
<action>m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);
(void)e; // unused parameter</action>
<action>(void)e; // unused parameter
m_timeEvt.armX(BSP::TICKS_PER_SEC/2, BSP::TICKS_PER_SEC/2);

QS_OBJ_DICTIONARY(&amp;Blinky::instance);
QS_SIG_DICTIONARY(TIMEOUT_SIG, nullptr);</action>
<initial_glyph conn="2,2,5,1,20,8,-4">
<action box="0,-2,32,6"/>
</initial_glyph>
Expand Down Expand Up @@ -89,6 +92,14 @@ public:

using namespace QP;

//----------------------------------------------------------------------------
// QS facilities

// un-comment if QS instrumentation needed
//#define QS_ON

static QP::QSpyId const l_TIMER_ID = { 0U }; // QSpy source ID

//----------------------------------------------------------------------------
// BSP functions

Expand All @@ -97,6 +108,18 @@ void BSP::init(void) {
// initialize the hardware used in this sketch...
// NOTE: interrupts are configured and started later in QF::onStartup()
pinMode(LED_BUILTIN, OUTPUT);

#ifdef QS_ON
QS_INIT(nullptr);

// output QS dictionaries...
QS_OBJ_DICTIONARY(&amp;l_TIMER_ID);

// setup the QS filters...
QS_GLB_FILTER(QP::QS_SM_RECORDS); // state machine records
QS_GLB_FILTER(QP::QS_AO_RECORDS); // active object records
QS_GLB_FILTER(QP::QS_UA_RECORDS); // all user records
#endif
}
//............................................................................
void BSP::ledOff(void) {
Expand Down Expand Up @@ -127,7 +150,7 @@ void BSP::ledOn(void) {
// interrupts.................................................................
void TIMER_HANDLER(void) {
TC_GetStatus(TIMER, TIMER_CHANNEL); // clear the interrupt source
QF::TICK_X(0, (void *)0); // process time events for tick rate 0
QF::TICK_X(0U, &amp;l_TIMER_ID); // process time events for tick rate 0
}
//............................................................................
void QF::onStartup(void) {
Expand Down Expand Up @@ -155,6 +178,7 @@ void QF::onStartup(void) {
NVIC_EnableIRQ(TIMER_IRQn);
// ...
}

//............................................................................
void QV::onIdle(void) { // called with interrupts DISABLED
#ifdef NDEBUG
Expand All @@ -164,6 +188,29 @@ void QV::onIdle(void) { // called with interrupts DISABLED
QV_CPU_SLEEP(); // atomically go to sleep and enable interrupts
#else
QF_INT_ENABLE(); // simply re-enable interrupts

#ifdef QS_ON

// transmit QS outgoing data (QS-TX)
uint16_t len = Serial.availableForWrite();
if (len &gt; 0U) { // any space available in the output buffer?
uint8_t const *buf = QS::getBlock(&amp;len);
if (buf) {
Serial.write(buf, len); // asynchronous and non-blocking
}
}

// receive QS incoming data (QS-RX)
len = Serial.available();
if (len &gt; 0U) {
do {
QP::QS::rxPut(Serial.read());
} while (--len &gt; 0U);
QS::rxParse();
}

#endif // QS_ON

#endif
}
//............................................................................
Expand All @@ -180,6 +227,55 @@ extern &quot;C&quot; Q_NORETURN Q_onAssert(char const * const module, int locati
}
}

//----------------------------------------------------------------------------
// QS callbacks...
#ifdef QS_ON

//............................................................................
bool QP::QS::onStartup(void const * arg) {
static uint8_t qsTxBuf[1024]; // buffer for QS transmit channel (QS-TX)
static uint8_t qsRxBuf[128]; // buffer for QS receive channel (QS-RX)
initBuf (qsTxBuf, sizeof(qsTxBuf));
rxInitBuf(qsRxBuf, sizeof(qsRxBuf));
Serial.begin(115200); // run serial port at 115200 baud rate
return true; // return success
}
//............................................................................
void QP::QS::onCommand(uint8_t cmdId, uint32_t param1,
uint32_t param2, uint32_t param3)
{
(void)cmdId;
(void)param1;
(void)param2;
(void)param3;
}

#endif // QS_ON

//............................................................................
void QP::QS::onCleanup(void) {
}
//............................................................................
QP::QSTimeCtr QP::QS::onGetTime(void) {
return millis();
}
//............................................................................
void QP::QS::onFlush(void) {
#ifdef QS_ON
uint16_t len = 0xFFFFU; // big number to get as many bytes as available
uint8_t const *buf = QS::getBlock(&amp;len); // get continguous block of data
while (buf != nullptr) { // data available?
Serial.write(buf, len); // might poll until all bytes fit
len = 0xFFFFU; // big number to get as many bytes as available
buf = QS::getBlock(&amp;len); // try to get more data
}
Serial.flush(); // wait for the transmission of outgoing data to complete
#endif // QS_ON
}
//............................................................................
void QP::QS::onReset(void) {
NVIC_SystemReset();
}
</text>
</file>
<file name="blinky.hpp">
Expand Down
Loading

0 comments on commit 3d3bc45

Please sign in to comment.