mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-05 14:17:20 +08:00
bmm150: more explicit data conversion & reduce to 30Hz
- 30Hz is the sensors max update rate in continous mode (though not in forced mode as we are using it) - 30Hz allows to increase the quality of the measurements
This commit is contained in:
@@ -228,29 +228,29 @@ int BMM150::collect()
|
||||
*/
|
||||
|
||||
/* Extract X axis data */
|
||||
lsb = ((mag_data[0] & 0xF8) >> 3);
|
||||
msb = (((int8_t)mag_data[1]) << 5);
|
||||
lsb = ((mag_data[0] & 0xF8));
|
||||
msb = ((uint16_t)(mag_data[1]) << 8);
|
||||
msblsb = (msb | lsb);
|
||||
x_raw = (int16_t)msblsb;
|
||||
x_raw = (int16_t)msblsb / 8;
|
||||
|
||||
|
||||
/* Extract Y axis data */
|
||||
lsb = ((mag_data[2] & 0xF8) >> 3);
|
||||
msb = (((int8_t)mag_data[3]) << 5);
|
||||
lsb = ((mag_data[2] & 0xF8));
|
||||
msb = (((uint16_t)(mag_data[3])) << 8);
|
||||
msblsb = (msb | lsb);
|
||||
y_raw = (int16_t)msblsb;
|
||||
y_raw = (int16_t)msblsb / 8;
|
||||
|
||||
/* Extract Z axis data */
|
||||
lsb = ((mag_data[4] & 0xFE) >> 1);
|
||||
msb = (((int8_t)mag_data[5]) << 7);
|
||||
lsb = ((mag_data[4] & 0xFE));
|
||||
msb = (((uint16_t)(mag_data[5])) << 8);
|
||||
msblsb = (msb | lsb);
|
||||
z_raw = (int16_t)msblsb;
|
||||
z_raw = (int16_t)msblsb / 2;
|
||||
|
||||
/* Extract Resistance data */
|
||||
lsb = ((mag_data[6] & 0xFC) >> 2);
|
||||
msb = (mag_data[7] << 6);
|
||||
lsb = ((mag_data[6] & 0xFC));
|
||||
msb = (((uint16_t)mag_data[7]) << 8);
|
||||
msblsb = (msb | lsb);
|
||||
resistance = (uint16_t)msblsb;
|
||||
resistance = (uint16_t)msblsb / 4;
|
||||
|
||||
/* Check whether data is new or old */
|
||||
if (!(status & 0x01)) {
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
#define BMM150_DEFAULT_ODR BMM150_DATA_RATE_30HZ
|
||||
|
||||
/* Maximum output data rate */
|
||||
#define BMM150_MAX_DATA_RATE 100
|
||||
#define BMM150_MAX_DATA_RATE 30
|
||||
|
||||
/* Default BMM150_INT_SETT_CTRL_REG Value */
|
||||
#define BMM150_DEFAULT_INT_SETT 0x3F
|
||||
@@ -181,7 +181,7 @@
|
||||
#define BMM150_SOFT_RESET_MASK 0x82
|
||||
|
||||
/* This value is set based on Max output data rate value */
|
||||
#define BMM150_CONVERSION_INTERVAL (1000000 / 100) /* microseconds */
|
||||
#define BMM150_CONVERSION_INTERVAL (1000000 / BMM150_MAX_DATA_RATE) /* microseconds */
|
||||
|
||||
struct bmm150_data {
|
||||
int16_t x;
|
||||
|
||||
Reference in New Issue
Block a user