Compiler Abstraction

Normative

Macros that keep driver source portable across compilers and memory architectures. Where the MCU/compiler has special keywords for memory addressing (e.g. far / near), declarations MUST be wrapped with these macros; where it does not, wrapping is not mandatory but the macro definitions MUST still exist. Keywords per Requirement Keywords.

Basics

Available via Compiler.h:

Symbol

Meaning

NULL_PTR

Null pointer, ((void *)0).

INLINE

Compiler-specific inline keyword (empty if inlining is unsupported).

LOCAL_INLINE

Compiler-specific inline keyword with static scope (empty if unsupported).

Memory class macros

Memory classes name where an object lives so declarations stay portable. AUTOMATIC, TYPEDEF come from Compiler.h; the rest are module-specific and defined in Compiler_Cfg.h. Each developer delivers a Compiler_Cfg.h for their module; the integrator merges them into one and maps each class to the required memory keyword.

Memory class

Used for

Defined in

AUTOMATIC

Local pointer declarations (empty definition).

Compiler.h

TYPEDEF

Type definitions (empty definition).

Compiler.h

REGSPACE

Pointers to HW special-function registers.

Compiler_Cfg.h

<MIP>_CODE[_FAST/_SLOW/_<PERIOD>]

Code.

Compiler_Cfg.h

<MIP>_CONST[_<OPTIONAL_KEYWORD>]

Global / static constants.

Compiler_Cfg.h

<MIP>_APPL_DATA

Pointers to application data from another component (ROM or RAM).

Compiler_Cfg.h

<MIP>_APPL_CONST

Pointers to application constants from another component.

Compiler_Cfg.h

<MIP>_VAR_<INIT_POLICY>[_<OPTIONAL_KEYWORD>]

Global / static variables (see the memory-mapping keywords in Naming Conventions).

Compiler_Cfg.h

Declaration macros

All available via Compiler.h. Each wraps a raw declaration so the memory/pointer class is applied portably. In the signatures below, variable_type / return_type is the underlying type, memory_class the class of the object itself, and pointer_class the class of the pointed-to object.

Macro

Use

VAR(variable_type, memory_class)

A variable declaration.

CONST(variable_type, memory_class)

A constant declaration.

P2VAR(variable_type, memory_class, pointer_class)

Pointer to a variable.

P2CONST(variable_type, memory_class, pointer_class)

Pointer to a constant.

CONSTP2VAR(variable_type, memory_class, pointer_class)

Constant pointer to a variable.

CONSTP2CONST(variable_type, memory_class, pointer_class)

Constant pointer to a constant.

P2FUNC(return_type, pointer_class, type_name)

Function-pointer type.

CONSTP2FUNC(return_type, pointer_class, type_name)

Constant function-pointer type.

FUNC(return_type, memory_class)

A function declaration/definition.

FUNC_P2VAR(return_type, pointer_class, memory_class)

A function returning a pointer to a variable.

FUNC_P2CONST(return_type, pointer_class, memory_class)

A function returning a pointer to a constant.

Example — the raw declaration and its wrapped form:

/* raw (qualifier order is compiler-dependent) */
MEM_CLASS uint32 a_variable;
PTR_CLASS uint32 * MEM_CLASS a_pointer;
<MIP>_CODE uint32 Mip_Function(uint32 param);

/* wrapped */
VAR(uint32, MEM_CLASS) a_variable;
P2VAR(uint32, MEM_CLASS, PTR_CLASS) a_pointer;
FUNC(uint32, <MIP>_CODE) Mip_Function(uint32 param);