ISM330xxx Library - Endianness problem
Hi,
My setup:
- SP570S-DISP Demo Board Evaluation
- uC: SPC570S50E1
- IDE: SPC5Studio 5.8.1
- IMU Sensor: STEVAL-MKI207V1 (ISM330DHCX)
I'm using "STMems_Standard_C_drivers/ism330dhcx_STdC" driver in order to manage communication between uC SPC570S50E1 and ISM330DHCX module.
https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/ism330dhcx_STdC
"STMems_Standard_C_drivers/ism330dhcx_STdC" driver are not-written in a machine-indipendent manner.
In particular, "struct" (Structure) access in "ism330dhcx_STdCdriver" is consider little-endian, but SPC570S50E1 is a big-endian machine.
Example (row 46-55): Structure access is considered in litte-endian byte order
typedef struct{
uint8_t bit0 : 1;
uint8_t bit1 : 1;
uint8_t bit2 : 1;
uint8_t bit3 : 1;
uint8_t bit4 : 1;
uint8_t bit5 : 1;
uint8_t bit6 : 1;
uint8_t bit7 : 1;
} bitwise_t;In order to properly use the ism330dhcx STdC driver on SPC570S50E1 uC, i have to modify all structures inverting the fields order.
Example:
typedef struct{
uint8_t bit7 : 1;
uint8_t bit6 : 1;
uint8_t bit5 : 1;
uint8_t bit4 : 1;
uint8_t bit3 : 1;
uint8_t bit2 : 1;
uint8_t bit1 : 1;
uint8_t bit0 : 1;
} bitwise_t;Please, do you have the "big-endian" version of this library?
Or could you provide me a an endian-independent version of library?
Thanks,
Regards
Leo
