2017-05-17 13:15:09 -04:00
|
|
|
//****************************************************************************
|
|
|
|
// Product: DPP example, QUTEST
|
2018-05-25 12:24:18 -04:00
|
|
|
// Last Updated for Version: 6.3.1
|
|
|
|
// Date of the Last Update: 2018-05-24
|
2017-05-17 13:15:09 -04:00
|
|
|
//
|
|
|
|
// Q u a n t u m L e a P s
|
|
|
|
// ---------------------------
|
|
|
|
// innovating embedded systems
|
|
|
|
//
|
|
|
|
// Copyright (C) Quantum Leaps, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is open source software: you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as published
|
|
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Alternatively, this program may be distributed and modified under the
|
|
|
|
// terms of Quantum Leaps commercial licenses, which expressly supersede
|
|
|
|
// the GNU General Public License and are specifically designed for
|
|
|
|
// licensees interested in retaining the proprietary status of their code.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
// Contact information:
|
2018-03-19 14:51:26 -04:00
|
|
|
// https://www.state-machine.com
|
2017-05-17 13:15:09 -04:00
|
|
|
// mailto:info@state-machine.com
|
|
|
|
//****************************************************************************
|
|
|
|
#include "qpcpp.h"
|
|
|
|
#include "dpp.h"
|
|
|
|
#include "bsp.h"
|
|
|
|
|
2017-07-20 13:06:27 -04:00
|
|
|
Q_DEFINE_THIS_MODULE("bsp")
|
|
|
|
|
2017-05-17 13:15:09 -04:00
|
|
|
// namespace DPP *************************************************************
|
|
|
|
namespace DPP {
|
|
|
|
|
|
|
|
static uint32_t l_rnd; // random seed
|
|
|
|
|
2018-05-25 12:24:18 -04:00
|
|
|
enum {
|
|
|
|
BSP_CALL = QP::QS_USER,
|
|
|
|
};
|
|
|
|
|
2017-05-17 13:15:09 -04:00
|
|
|
// BSP functions =============================================================
|
2018-03-19 14:51:26 -04:00
|
|
|
void BSP::init(int argc, char **argv) {
|
|
|
|
Q_ALLEGE(QS_INIT(argc <= 1 ? (void *)0 : argv[1]));
|
2017-05-17 13:15:09 -04:00
|
|
|
|
|
|
|
QS_FUN_DICTIONARY(&BSP::displayPaused);
|
2018-05-25 12:24:18 -04:00
|
|
|
QS_FUN_DICTIONARY(&BSP::displayPhilStat);
|
2017-05-17 13:15:09 -04:00
|
|
|
QS_FUN_DICTIONARY(&BSP::random);
|
2018-05-25 12:24:18 -04:00
|
|
|
QS_FUN_DICTIONARY(&BSP::randomSeed);
|
|
|
|
|
|
|
|
QS_USR_DICTIONARY(BSP_CALL);
|
|
|
|
|
|
|
|
BSP::randomSeed(1234U);
|
2017-05-17 13:15:09 -04:00
|
|
|
}
|
|
|
|
//............................................................................
|
|
|
|
void BSP::displayPaused(uint8_t paused) {
|
|
|
|
QS_TEST_PROBE_DEF(&BSP::displayPaused)
|
|
|
|
|
|
|
|
QS_TEST_PROBE(
|
|
|
|
Q_ASSERT_ID(100, 0);
|
|
|
|
)
|
2018-05-25 12:24:18 -04:00
|
|
|
QS_BEGIN(BSP_CALL, 0) // application-specific record
|
|
|
|
QS_FUN(&BSP::displayPaused);
|
|
|
|
QS_U8(0, paused);
|
|
|
|
QS_END()
|
2017-05-17 13:15:09 -04:00
|
|
|
}
|
|
|
|
//............................................................................
|
2018-05-25 12:24:18 -04:00
|
|
|
void BSP::displayPhilStat(uint8_t n, char const *stat) {
|
|
|
|
QS_BEGIN(BSP_CALL, 0) // application-specific record
|
|
|
|
QS_FUN(&BSP::displayPhilStat);
|
|
|
|
QS_U8(0, n);
|
|
|
|
QS_STR(stat);
|
|
|
|
QS_END()
|
|
|
|
}
|
|
|
|
//............................................................................
|
|
|
|
uint32_t BSP::random(void) {
|
|
|
|
QS_TEST_PROBE_DEF(&BSP::random)
|
|
|
|
uint32_t rnd = 123U;
|
2017-05-17 13:15:09 -04:00
|
|
|
|
2018-05-25 12:24:18 -04:00
|
|
|
QS_TEST_PROBE(
|
|
|
|
rnd = qs_tp_;
|
|
|
|
)
|
|
|
|
QS_BEGIN(BSP_CALL, 0) // application-specific record
|
|
|
|
QS_FUN(&BSP::random);
|
|
|
|
QS_U32(0, rnd);
|
|
|
|
QS_END()
|
|
|
|
return rnd;
|
2017-05-17 13:15:09 -04:00
|
|
|
}
|
|
|
|
//............................................................................
|
|
|
|
void BSP::randomSeed(uint32_t seed) {
|
2018-05-25 12:24:18 -04:00
|
|
|
QS_TEST_PROBE_DEF(&BSP::randomSeed)
|
|
|
|
|
|
|
|
QS_TEST_PROBE(
|
|
|
|
seed = qs_tp_;
|
|
|
|
)
|
2017-05-17 13:15:09 -04:00
|
|
|
l_rnd = seed;
|
2018-05-25 12:24:18 -04:00
|
|
|
QS_BEGIN(BSP_CALL, 0) // application-specific record
|
|
|
|
QS_FUN(&BSP::randomSeed);
|
|
|
|
QS_U32(0, seed);
|
|
|
|
QS_END()
|
2017-05-17 13:15:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//............................................................................
|
|
|
|
void BSP::terminate(int16_t result) {
|
|
|
|
(void)result;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DPP
|