CPU_SR_ALLOC

CPU_SR_ALLOC

Description

Allocates CPU status register word as local variable cpu_sr, when necessary, for use with critical section macros.

Files

Each specific processor’s/compiler’s cpu.h

Prototype

CPU_SR_ALLOC();

 

Arguments

None.

Returned Value

None.

Required Configuration

None.

Notes / Warnings

  1. CPU_SR_ALLOC() must be called immediately after the last local variable declaration in a function but before any code statements.

Example Usage

Listing - CPU_SR_ALLOC() example usage
CPU_BOOLEAN ts_init; CPU_TS ts_cur; CPU_SR_ALLOC(); /* Declared immediately after all local variables ... */ /* ... but before any code statements. */ ts_init = DEF_YES; ts_cur = CPU_TS_TmrRd();

 

Implementation Template

The following example template assumes corresponding functions are defined in either cpu.c or cpu_a.asm:

Listing - CPU_SR_ALLOC() implementation template
typedef CPU_INT32U CPU_SR; /* Defines CPU status register size (see Note #3b). */ /* Allocates CPU status register word (see Note #3a). */ #if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL) #define CPU_SR_ALLOC() CPU_SR cpu_sr = (CPU_SR)0 #else #define CPU_SR_ALLOC() #endif