TASKING VX-toolset for TriCore User Guide
typedef volatile union
{
struct
{
unsigned __sfrbit32 SRPN : 8; /* Service Priority Number */
unsigned __sfrbit32 : 2;
unsigned __sfrbit32 TOS : 2; /* Type-of-Service Control */
unsigned __sfrbit32 SRE : 1; /* Service Request Enable Control */
unsigned __sfrbit32 SRR : 1; /* Service Request Flag */
unsigned __sfrbit32 CLRR : 1; /* Request Flag Clear Bit */
unsigned __sfrbit32 SETR : 1; /* Request Flag Set Bit */
unsigned __sfrbit32 : 16;
} B;
int I;
unsigned int U;
} LBCU_SRC_type;
Read-only fields can be marked by using the const
keyword.
The SFR is defined by a cast to a ‘typedef-ed union’ pointer. The SFR address is given in parenthesis.
Read-only SFRs are marked by using the const
keyword in the macro definition.
#define LBCU_SRC (*(LBCU_SRC_type*)(0xF87FFEFCu))
/* LBCU Service Control Register */
Restrictions
• You can use the
__sfrbit32
and
__sfrbit16
data type qualifiers only for int
types. The compiler issues an error if you use for example
__sfrbit32 char x : 8;
• When you use the
__sfrbit32
and
__sfrbit16
data type qualifiers for other types than a bit-field, the compiler ignores this without a warning. For example,
__sfrbit32 int global;
is equal to int global;
.
• Structures or unions that contain a member qualified with
__sfrbit16
, are zero padded to complete a halfword if necessary. The structure or union will be halfword aligned. Structures or unions that contain a member qualified with
__sfrbit32
, are zero padded to complete a full word if necessary. The structure or union will be word aligned.
1.3.3. Saturation: __sat
When a variable is declared with the type qualifier
__sat
, all operations on that variable will be performed using saturating arithmetic. When an operation is performed on a plain variable and a
__sat
variable, the
__sat
takes precedence, and the operation is done using saturating arithmetic. The type of the result of such an operation also includes the qualifier
__sat
, so that another operation on the result will also be saturated. In this respect, the behavior of the type qualifier
__sat
is comparable to the unsigned keyword. You can overrule this behavior by inserting type casts with or without the type qualifier
__sat in an expression.
You can only use the type qualifier
__sat
on type int
(fractional types are always saturated).
12