5744P LIB union struct

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

5744P LIB union struct

1,240 Views
pingli
Contributor III

Hi,NXP

   I have a qustion for S32DS 5744P lib about C union struct 。

C language:

pastedImage_8.png

In 5744P lib  :

typedef union { ///INIT_VREG_Tx
vuint32_t R;
struct {
vuint32_t :16;                           high bit
vuint32_t RW : 1;
vuint32_t ADR : 6;
vuint32_t P : 1;
vuint32_t ICCA_LIM : 1;
vuint32_t TCCA_LIM_OFF : 1;
vuint32_t IPFF_DIS : 1;
vuint32_t VCAN_OV_MON : 1;
vuint32_t : 1;
vuint32_t TAUX_LIM_OFF : 1;
vuint32_t VAUX_TRK_EN : 1;
vuint32_t : 1;                               low bit
} B;
struct {
vuint32_t :16;
vuint32_t RW : 1;
vuint32_t ADR : 6;
vuint32_t P : 1;
vuint32_t BYTE_FIELD : 8;
} Bytes;
} INIT_VREG_Tx_32B_tag;

what`s right ?

Think you!

Clipping

Tags (3)
0 Kudos
Reply
3 Replies

1,052 Views
q333444ew
Contributor I

Hello,Stanislav

I think he want to the order of bitfields. Is it means for vuint32_t data the order is from high side to low side?For vuint16_t data, the order is from low side to high side? I am not sure. Could you help me?

Thanks!

Regards!

Xinyu

0 Kudos
Reply

1,052 Views
stanish
NXP Employee
NXP Employee

The order of items in bitfields is the same regardless of vuint32_t or vuint16_t data type.

First item in the bitfield definition is the most significant bit regardless of its name.

So if you set just the first bit of the structure and read it back as uint16_t value you get value 0x8000.

For uint32 the value is 0x80000000.

For more info about data representation on PowerPC I'd recommend you to see "Data Representation" chapter in this document:

http://www.nxp.com/docs/en/reference-manual/E500ABIUG.pdf 

Hope it helps,

Stan

0 Kudos
Reply

1,052 Views
stanish
NXP Employee
NXP Employee

Hi,

I created a simple test case and I can see the bitfields respects the same endianess in both cases:

pastedImage_1.png

Can you please send us the example project for analysis if it still does not match on your side?

Please check this posts related to reversing bitfield allocation:

https://community.nxp.com/message/929337 

Thanks!

Stan

0 Kudos
Reply