QP-nano  6.9.0
Real-Time Embedded Framework
qkn/qfn_port.h File Reference

QF-nano port for Lint, preemptive QK-nano kernel, generic C compiler. More...

#include <stdint.h>
#include <stdbool.h>
#include "qepn.h"
#include "qfn.h"
#include "qkn.h"

Go to the source code of this file.

Macros

#define Q_ROM
 
#define Q_ROM_BYTE(rom_var_)   (rom_var_)
 
#define Q_ROM_PTR(rom_var_)   (rom_var_)
 
#define QF_INT_DISABLE()   int_disable()
 
#define QF_INT_ENABLE()   int_enable()
 
#define QK_ISR_ENTRY()   ((void)0)
 
#define QK_ISR_EXIT()   (*((uint32_t volatile *)0xE000ED04U) = 0x10000000U)
 
#define QF_ISR_NEST
 
#define QK_INIT()   QK_init()
 
#define QK_ON_CONTEXT_SW
 

Functions

void QK_init (void)
 
void int_disable (void)
 
void int_enable (void)
 

Macro Definition Documentation

◆ Q_ROM

#define Q_ROM
Description
This header file contains the port and customization of QP-nano to the specific CPU and compiler. The port header file is included in the main qpn.h header file.

Macro to specify compiler-specific directive for placing a constant object in ROM.

Description
Many compilers for 8-bit Harvard-architecture MCUs provide non-stanard extensions to support placement of objects in different memories. In order to conserve the precious RAM, QP-nano uses the Q_ROM macro for all constant objects that can be allocated in ROM.

To override the following empty definition, you need to define the Q_ROM macro in the qpn_port.h header file. Some examples of valid Q_ROM macro definitions are: __code (IAR 8051 compiler), code (Keil 8051 compiler), PROGMEM (gcc for AVR), __flash (IAR for AVR).

Definition at line 64 of file qkn/qfn_port.h.

◆ Q_ROM_BYTE

#define Q_ROM_BYTE (   rom_var_)    (rom_var_)

Macro to access a byte allocated in ROM

Description
Some compilers for Harvard-architecture MCUs, such as gcc for AVR, do not generate correct code for accessing data allocated in the program space (ROM). The workaround for such compilers is to explicitly add assembly code to access each data element allocated in the program space. The macro Q_ROM_BYTE() retrieves a byte from the given ROM address.

The Q_ROM_BYTE() macro should be defined in the qpn_port.h header file for each compiler that cannot handle correctly data allocated in ROM (such as the gcc). If the macro is left undefined, the default definition simply returns the argument and lets the compiler synthesize the correct code.

Definition at line 82 of file qkn/qfn_port.h.

◆ Q_ROM_PTR

#define Q_ROM_PTR (   rom_var_)    (rom_var_)

Macro to access a pointer allocated in ROM

Description
Some compilers for Harvard-architecture MCUs, such as the gcc for AVR, do not generate correct code for accessing data allocated in the program space. The workaround for such compilers is to explictly add assembly code to access each data element allocated in the program space. The macro Q_ROM_PTR() retrieves an object-pointer from the given ROM address. Please note that the pointer can be pointing to the object in RAM or ROM.

The Q_ROM_PTR() macro should be defined in the qpn_port.h header file for each compiler that cannot handle correctly data allocated in ROM (such as the gcc). If the macro is left undefined, the default definition simply returns the argument and lets the compiler synthesize the correct code.

Definition at line 100 of file qkn/qfn_port.h.

◆ QF_INT_DISABLE

#define QF_INT_DISABLE ( )    int_disable()

The macro defines the mechanism of locking the interrupts.

Note
This is just an example of QF_INT_DISABLE. You need to define the macro appropriately for the CPU/compiler you're using.
The QF_INT_DISABLE macro must be always paired with QF_INT_ENABLE. You should keep the code between these two macros to the minimum.

Definition at line 110 of file qkn/qfn_port.h.

◆ QF_INT_ENABLE

#define QF_INT_ENABLE ( )    int_enable()

The macro defines the mechanism of unlocking the interrupts.

Description
Note
This is just an example of QF_INT_ENABLE. You need to define the macro appropriately for the CPU/compiler you're using.
The QF_INT_ENABLE macro must be always paired with QF_INT_DISABLE. You should keep the code between these two macros to the minimum.

Definition at line 121 of file qkn/qfn_port.h.

◆ QK_ISR_ENTRY

#define QK_ISR_ENTRY ( )    ((void)0)

QK-nano ISR entry

an example only

Definition at line 127 of file qkn/qfn_port.h.

◆ QK_ISR_EXIT

#define QK_ISR_EXIT ( )    (*((uint32_t volatile *)0xE000ED04U) = 0x10000000U)

QK-nano ISR exit

Definition at line 130 of file qkn/qfn_port.h.

◆ QF_ISR_NEST

#define QF_ISR_NEST

Macro that specifies whether QK-nano ISR nesting is allowed

Definition at line 133 of file qkn/qfn_port.h.

◆ QK_INIT

#define QK_INIT ( )    QK_init()

Macro that specifies QK-nano initialization

Description
Some QK-nano ports might need initialization (e.g., seeting the priorities of exceptions PendSV and SVCall in ARM Cortex-M port). The QK_INIT() macro in this case calls the initialization defined in assembly.
Note
The macro QK_INIT() can be left undefined.

Definition at line 144 of file qkn/qfn_port.h.

◆ QK_ON_CONTEXT_SW

#define QK_ON_CONTEXT_SW

Macro that enables context-switch callback in QK-nano

Definition at line 148 of file qkn/qfn_port.h.

Function Documentation

◆ QK_init()

void QK_init ( void  )

◆ int_disable()

void int_disable ( void  )

example of a function to disable interrupts

◆ int_enable()

void int_enable ( void  )

example of a function to enable interrupts