QP-nano
Defines | Functions | Variables
qkn.h File Reference

Public QP-nano interface. More...

Go to the source code of this file.

Defines

#define QK_PREEMPTIVE   1
 Preprocessor switch for configuring preemptive real-time kernel (QK-nano). The macro is automatically defined by including the qkn.h file in qpn_port.h.
#define QK_SCHEDULE_()
 The macro to invoke the QK scheduler in the QK_ISR_EXIT()
#define QK_schedule_()
 QK-nano scheduler for backwards compatiblity.

Functions

void QK_init (void)
 QK-nano initialization.
uint8_t QK_schedPrio_ (void) Q_REENTRANT
 Find the highest-priority task ready to run.
void QK_sched_ (uint8_t p) Q_REENTRANT
 QK-nano scheduler.
void QK_onIdle (void)
 QK idle callback (customized in BSPs for QK)

Variables

uint8_t volatile QK_currPrio_

Detailed Description

Public QP-nano interface.

This header file must be included in all modules that use QP-nano with preemptive kernel option. Typically, this header file is included indirectly through the header file qpn.h.

Definition in file qkn.h.


Define Documentation

#define QK_PREEMPTIVE   1

Preprocessor switch for configuring preemptive real-time kernel (QK-nano). The macro is automatically defined by including the qkn.h file in qpn_port.h.

Note:
If defined, this macro eliminates the code for the non-preemptive scheduler provided in QF-nano. Instead, the fully preemptive QK-nano real-time kernel is used.

Definition at line 49 of file qkn.h.

#define QK_schedule_ ( )
Value:
do { \
    uint8_t p = QK_schedPrio_(); \
    if (p != (uint8_t)0) { \
        QK_sched_(p); \
    } \
} while(0)

QK-nano scheduler for backwards compatiblity.

Note:
QK_schedule_() must be always called with interrupts locked. The scheduler might unlock the interrupts internally, but always returns with interrupts locked.

Definition at line 104 of file qkn.h.


Function Documentation

void QK_init ( void  )

QK-nano initialization.

This function is optional and might be used in some QK-nano ports. When the function is defined, it must called exactly once before any other QK function, typically from the BSP initialization function.

void QK_onIdle ( void  )

QK idle callback (customized in BSPs for QK)

QK_onIdle() is called continously by the QK-nano idle loop. This callback gives the application an opportunity to enter a power-saving CPU mode, or perform some other idle processing.

Note:
QK_onIdle() is invoked with interrupts unlocked and must also return with interrupts unlocked. This is in contrast to the callback QF_onIdle(), which is used by the non-preemptive QF-nano scheduler.

Referenced by QF_run().

void QK_sched_ ( uint8_t  p)

QK-nano scheduler.

Note:
QK_sched_() must be always called with interrupts locked. The scheduler might unlock the interrupts internally, but always returns with interrupts locked.

Definition at line 125 of file qkn.c.

References QActive::nUsed, Q_ASSERT, Q_PAR, Q_PARAM_SIZE, Q_ROM, Q_ROM_BYTE, Q_ROM_PTR, Q_ROM_VAR, Q_SIG, QF_active, QF_INT_LOCK, QF_INT_UNLOCK, QF_readySet_, QFsm_dispatch(), QHsm_dispatch(), QK_currPrio_, and QActive::tail.

Referenced by QActive_post().

uint8_t QK_schedPrio_ ( void  )

Find the highest-priority task ready to run.

Note:
QK_schedPrio_() must be always called with interrupts locked and returns with interrupts locked.

Definition at line 98 of file qkn.c.

References Q_ROM_BYTE, and QF_readySet_.

Referenced by QActive_post().


Variable Documentation

uint8_t volatile QK_currPrio_

current QK priority

Definition at line 44 of file qkn.c.

Referenced by QF_init(), and QK_sched_().