Reputation: 3
I am exploring how to create complex data types in AUTOSAR. Been searching for the below concern, but I haven't found one that shows me the way with good clarity.
I would like to create an IRV in this form:
union {
uint8 u8Value;
struct {
uint8 bit0 : 1;
uint8 bit1 : 1;
...
}stMyBits;
}unMyUnion;
Base on my own investigation, I found in SW Data Prop Ref what is called SwBitsRepresentation from where you can specify start position and number of bits. However, it did not work because the RTE generated code look like this:
union {
uint8 u8Value;
struct {
uint8 bit0;
uint8 bit1;
...
}stMyBits;
}unMyUnion;
Compiling this will definitely NOT apply the desired bitfields.
Upvotes: 0
Views: 1233
Reputation: 2793
C bit fields are not supported in AUTOSAR for the lack of portability. If you want to implement a bitfield semantics you need to define an ImplementationDataType
that aggregates a SwDataDefProps
that in turn refers to a CompuMethod
of category BITFIELD_TEXTTABLE
.
Within the definition of the CompuMethod
you can specify the bitfields and their semantics.
An RTE generator will honor this configuration by generating access macros that provide a more or less convenient way to access the bits in the host variable.
You can find more information about the definition of a CompuMethod
of category BITFIELD_TEXTTABLE
in the AUTOSAR document “TPS Software Component Template”.
Upvotes: 0