2020-04-08 05:11 PM
2020-04-09 07:17 AM
Hi @LLoid.1 , please consider the example library an d driver on Github repository.
In order to get physical units from register data content you have just to convert the 16-bit value obtained concatenating the two dataout registers into decimal value through two's complement conversion and then divide for the FullScale-related sensitivity
/**
* @defgroup LIS3MDL_Sensitivity
* @brief These functions convert raw-data into engineering units.
* @{
*
*/
float lis3mdl_from_fs4_to_gauss(int16_t lsb)
{
return ((float)lsb / 6842.0f);
}
float lis3mdl_from_fs8_to_gauss(int16_t lsb)
{
return ((float)lsb / 3421.0f);
}
float lis3mdl_from_fs12_to_gauss(int16_t lsb)
{
return ((float)lsb / 2281.0f);
}
float lis3mdl_from_fs16_to_gauss(int16_t lsb)
{
return ((float)lsb / 1711.0f);
}
Regards