QP/C++  6.5.1
DPP on EK-TM4C123GXL

The DPP example for TI-RTOS on EK-TM4C123GXL board is located directory examples/ti-rtos/arm-cm/dpp_ek-tm4c123gxl.

bd_EK-TM4C123GXL.jpg
EK-TM4C123GXL board
Attention
The TI-RTOS requires its own tooling (XDCTOOLS) and is too big to fit into the 3rd_party/ directory in the QP/C++ distribution. Therefore, you need to download and install TI-RTOS on your machine before you can build any examples (preferably in the default location C:/TI). Please refer to the TI Application Note "TI-RTOS for TivaC Getting Started Guide" (Literature Number: SPRUHU5D) for more information.

The sub-directory ccs contains the project files that you can import into the TI CCS IDE.

The sub-directory iar contains the workspace and project file that you can open in IAR EWARM IDE.

After you load the DPP example into the EK-TM4C123GXL board, the application should start blinking the on-board three-color LED (located below the Reset button). You can press the SW1 button (lower-left corner) to PAUSE the philosophers for as long as the button is depressed. The philosophers resume dining when you release the User button. (In the PAUSED state the Table active object stops granting permissions to eat, so eventually all philosophers end in the "hungry" state.)


main.cpp for TI-RTOS

The main.cpp for TI-RTOS is actually identical as for the built-in QV/QK/QXK kernels. In particular, you do not need to provide stack space to active objects, because they execute in the context of lightweight TI-RTOS Swis (Software Interrupts), which don't need private stacks.

int main() {
static QP::QEvt const *tableQueueSto[N_PHILO];
static QP::QEvt const *philoQueueSto[N_PHILO][N_PHILO];
static QP::QSubscrList subscrSto[DPP::MAX_PUB_SIG];
static QF_MPOOL_EL(DPP::TableEvt) smlPoolSto[2*N_PHILO];
QP::QF::init(); // initialize the framework and the underlying RT kernel
DPP::BSP::init(); // initialize the BSP
QP::QF::psInit(subscrSto, Q_DIM(subscrSto)); // init publish-subscribe
// initialize event pools...
QP::QF::poolInit(smlPoolSto,
sizeof(smlPoolSto), sizeof(smlPoolSto[0]));
// start the active objects...
for (uint8_t n = 0U; n < N_PHILO; ++n) {
DPP::AO_Philo[n]->start((uint_fast8_t)(n + 1U),
philoQueueSto[n], Q_DIM(philoQueueSto[n]),
[1] (void *)0, 0U); // no stack
}
DPP::AO_Table->start((uint_fast8_t)(N_PHILO + 1U),
tableQueueSto, Q_DIM(tableQueueSto),
[2] (void *)0, 0U); // no stack
return QP::QF::run(); // run the QF application
}
  • 1-2 You don't provide the per-active object stack at startup;

BSP for TI-RTOS

Note
TI-RTOS is configured specifically for the DPP application by means of the configuration file dpp.cfg, which is included in the ccs/ and iar/ directories. This file is processed in the custom build step for TI-RTOS.

The highlights of the Board Support Package (BSP) for TI-RTOS are explained below:

// TI-RTOS callback functions ================================================
[1] extern "C" {
// Clock function to service the QP clock tick ...............................
[2] static void clk0Fxn(UArg arg0) {
~ ~ ~
[3] QP::QF::TICK_X(0U, &l_SysTick_Handler); // process time events for rate 0
// Perform the debouncing of buttons...
~ ~ ~
if (tmp != 0U) { // debounced SW1 state changed?
if (buttons.depressed == 0U) { // is SW1 depressed?
static QP::QEvt const pauseEvt = { DPP::PAUSE_SIG, 0U, 0U};
[4] QP::QF::PUBLISH(&pauseEvt, &l_SysTick_Handler);
}
else { // the button is released
static QP::QEvt const serveEvt = { DPP::SERVE_SIG, 0U, 0U};
QP::QF::PUBLISH(&serveEvt, &l_SysTick_Handler);
}
}
}
// Idle callback (see dpp.cfg) ...............................................
[5] void myIdleFunc() {
~ ~ ~
#ifdef NDEBUG
// Put the CPU and peripherals to the low-power mode.
// you might need to customize the clock management for your application,
// see the datasheet for your particular Cortex-M3 MCU.
//
__asm (" WFI"); // Wait-For-Interrupt
#endif
}
} // extern "C"
// namespace QP **************************************************************
namespace QP {
// QF callbacks ==============================================================
[6] void QF::onStartup(void) {
[7] static Clock_Struct clk0Struct;
Clock_Params clkParams;
[8] Clock_Params_init(&clkParams);
[9] clkParams.startFlag = TRUE;
[10] clkParams.period = 1000U/DPP::BSP::TICKS_PER_SEC;
// Construct a periodic Clock Instance
[11] Clock_construct(&clk0Struct, &clk0Fxn, clkParams.period, &clkParams);
}
~ ~ ~
} // namespace QP
  • 1 The TI-RTOS callback functions are defined as extern "C";
  • 2 The function clk0Fxn() provides the TI-RTOS clock service (configured later in step [11]);
  • 3 The TI-RTOS clock function calls the QP::QF::TICK_X() service to process the QP time events;
  • 4 The TI-RTOS clock function might post or publish events to active objects;
  • 5 The TI-RTOS is configured (in the dpp.cfg file) to call the myIdle() function from the TI-RTOS idle loop; In the Release build configuration this function can put the CPU into a low-power sleep mode. In the Spy build configuration, the idle callback can perform QS software tracing output to the host.
  • 6 The QP::QF::onStartup() function configures and starts interrupts. Here the function also configures and starts TI-RTOS clock service;
  • 7 The TI-RTOS Clock_Struct is allocated statically;
  • 8 The Clock Parameters are initialized to default;
  • 9 The Clock service is started;
  • 10 The Clock period is set to fire the desired number of times per second (BSP::TICKS_PER_SEC). NOTE: The system clock rate in microseconds is configured in the TI-RTOS configuration file dpp.cfg;
  • 11 The Clock service is constructed in the statically allocated memory;
Note
Currently, the BSP does not demonstrate the QS (Q-SPY) tracing. Demonstrating the QS tracing for this example is planned in the future.

Next: uC/OS-II examples