QP-nano  6.9.0
Real-Time Embedded Framework
qfn.c File Reference

QF-nano implementation. More...

#include "qpn_conf.h"
#include "qfn_port.h"
#include "qassert.h"

Go to the source code of this file.

Functions

void QF_init (uint_fast8_t maxActive)
 
void QF_tickXISR (uint_fast8_t const tickRate)
 

Variables

uint_fast8_t QF_maxActive_
 
uint_fast8_t volatile QF_readySet_
 
uint_fast8_t volatile QF_timerSetX_ [QF_MAX_TICK_RATE]
 
uint8_t const Q_ROM QF_log2Lkup [16]
 

Function Documentation

◆ QF_init()

void QF_init ( uint_fast8_t  maxActive)
Description
The function QF_init() initializes the number of active objects to be managed by the framework and clears the internal QF-nano variables as well as all registered active objects to zero, which is needed in case when the startup code does not clear the uninitialized data (in violation of the C Standard).
Note
The intended use of the function is to call as follows: QF_init(Q_DIM(QF_active));
Precondition
the number of active objects must be in range

Definition at line 315 of file qfn.c.

◆ QF_tickXISR()

void QF_tickXISR ( uint_fast8_t const  tickRate)
Description
This function must be called periodically from a time-tick ISR or from an ISR so that QF-nano can manage the timeout events assigned to the given system clock tick rate.
Parameters
[in]tickRatesystem clock tick rate serviced in this call.
Note
Each system tick rate posts timeout events with a different signal as follows:
tickRate==0 Q_TIMEOUT_SIG
tickRate==1 Q_TIMEOUT1_SIG
tickRate==2 Q_TIMEOUT2_SIG
tickRate==3 Q_TIMEOUT3_SIG
The calls to QF_tickXISR() with different tick rate parameter can preempt each other. For example, higher clock tick rates might be serviced from interrupts that can preempt lower-priority interrupts.

Definition at line 398 of file qfn.c.

Variable Documentation

◆ QF_maxActive_

uint_fast8_t QF_maxActive_
Description
This variable stores the number of active objects in the application. This is the number of elements (dimension of) the QF_active[] array.

Definition at line 53 of file qfn.c.

◆ QF_readySet_

uint_fast8_t volatile QF_readySet_
Description
The QF-nano ready set keeps track of active objects that are ready to run. The ready set represents each active object as a bit, with the bits assigned according to priorities of the active objects. The bit is set if the corresponding active object is ready to run (i.e., has one or more events in its event queue) and zero if the event queue is empty. The QF-nano ready set is one byte-wide, which corresponds to 8 active objects maximum.

Definition at line 65 of file qfn.c.

◆ QF_timerSetX_

uint_fast8_t volatile QF_timerSetX_[QF_MAX_TICK_RATE]
Description
The QF-nano timer set keeps track of the armed time events. The timer set represents the timeout down-counter of each active object as a bit, with the bits assigned according to priorities of the active objects. The bit is set if the corresponding timeout down-counter is not zero (i.e., is counting down) and zero if the down-counter is zero. The QF-nano time event set is one byte-wide, which corresponds to 8 active objects maximum.

The main use of the QF_timerSetX_ is to quickly determine that all time events are disarmed by testing (QF_timerSetX_[tickRate] == 0). If so, the CPU can go to longer sleep mode, in which the system clock tick ISR is turned off.
Note
The test (QF_timerSet_[tickRate] == 0) must be always performed inside a CRITICAL SECTION.

Definition at line 85 of file qfn.c.

◆ QF_log2Lkup

uint8_t const Q_ROM QF_log2Lkup[16]
Initial value:
= {
0U, 1U, 2U, 2U, 3U, 3U, 3U, 3U,
4U, 4U, 4U, 4U, 4U, 4U, 4U, 4U
}

Lookup table for (log2(n) + 1), where n is the index into the table. This lookup delivers the 1-based number of the most significant 1-bit of a nibble.

Definition at line 89 of file qfn.c.