1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/mpu9x50: Correct read_temperature

Change msbiot Makefile.dep back to mpu9150
This commit is contained in:
Jannes 2019-10-15 12:46:43 +02:00
parent 2df5d6048d
commit fdd34499ac
4 changed files with 18 additions and 17 deletions

View File

@ -6,7 +6,7 @@ endif
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
# add support for the MPU-9X50 as default saul device
# add support for the MPU-9150 as default saul device
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += mpu9x50
USEMODULE += mpu9150
endif

View File

@ -150,27 +150,27 @@ on the inclusion.
| IRQ Line | PA10 |
### MPU-9X50 Nine-Axis MotionTracking Device
### MPU-9150 Nine-Axis MotionTracking Device
The MSB-IoT is equipped with a MPU-9X50 MotionTracking Device from
The MSB-IoT is equipped with a MPU-9150 MotionTracking Device from
Invensense. The device combines a gyroscope, a magnetometer and an accelerometer
in one module.
Due to licensing issues, the current MPU-9X50 driver implementation for RIOT
Due to licensing issues, the current MPU-9150 driver implementation for RIOT
is not based on Invensense's 'Motion Driver' library and offers only a limited
set of features. Nonetheless, the RIOT driver allows to configure and read
values from all three sensors of the device. For an overview on the supported
features, you can check the driver's documentation in @ref drivers_mpu9x50.
A sample RIOT application for the MPU-9X50 that utilizes the driver can be
A sample RIOT application for the MPU-9150 that utilizes the driver can be
found [here](https://github.com/RIOT-OS/RIOT/tree/master/tests/driver_mpu9x50).
| Product | MPU-9X50 |
| Product | MPU-9150 |
|:--------------------- |:------------------------------------------------------------------------------------------------- |
| Type | Nine-Axis MotionTracking Device (Gyro, Accel and Compass) |
| Vendor | Invensense |
| Product Specification | [Product Specification](http://www.invensense.com/mems/gyro/documents/PS-MPU-9X50A-00v4_3.pdf) |
| Register Map | [Register Map](http://www.invensense.com/mems/gyro/documents/RM-MPU-9X50A-00v4_2.pdf) |
| Product Specification | [Product Specification](http://www.invensense.com/mems/gyro/documents/PS-MPU-9150A-00v4_3.pdf) |
| Register Map | [Register Map](http://www.invensense.com/mems/gyro/documents/RM-MPU-9150A-00v4_2.pdf) |
| Driver | @ref drivers_mpu9x50 |
| I²C Device | I2C1 (Mapped to I2C_0 in RIOT) |
| SCL | PB6 |

View File

@ -88,7 +88,7 @@ extern "C" {
#ifdef MODULE_MPU9150
#define MPU9X50_TEMP_SENSITIVITY 340
#define MPU9X50_TEMP_OFFSET 35
#elif MODULE_MPU9250
#elif defined(MODULE_MPU9250)
#define MPU9X50_TEMP_SENSITIVITY 333.87
#define MPU9X50_TEMP_OFFSET 21
#else

View File

@ -21,9 +21,10 @@
*/
#include "mpu9x50.h"
#include "mpu9x50-regs.h"
#include "mpu9x50_regs.h"
#include "periph/i2c.h"
#include "xtimer.h"
#include "byteorder.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
@ -361,20 +362,20 @@ int mpu9x50_read_compass(const mpu9x50_t *dev, mpu9x50_results_t *output)
int mpu9x50_read_temperature(const mpu9x50_t *dev, int32_t *output)
{
uint8_t data[2];
int16_t temp;
uint16_t data;
/* Acquire exclusive access */
if (i2c_acquire(DEV_I2C)) {
return -1;
}
/* Read raw temperature value */
i2c_read_regs(DEV_I2C, DEV_ADDR, MPU9X50_TEMP_START_REG, data, 2, 0);
i2c_read_regs(DEV_I2C, DEV_ADDR, MPU9X50_TEMP_START_REG, &data, 2, 0);
/* Release the bus */
i2c_release(DEV_I2C);
temp = ((uint16_t)data[0] << 8) | data[1];
*output = (((int32_t)temp * 1000LU) / 340) + (35 * 1000LU);
data = htons(data);
*output = (((int32_t)data * 1000LU) / MPU9X50_TEMP_SENSITIVITY) + (MPU9X50_TEMP_OFFSET * 1000LU);
return 0;
}
@ -505,7 +506,7 @@ static int compass_init(mpu9x50_t *dev)
/* Check whether compass answers correctly */
i2c_read_reg(DEV_I2C, DEV_COMP_ADDR, COMPASS_WHOAMI_REG, data, 0);
if (data[0] != MPU9150_COMP_WHOAMI_ANSWER) {
if (data[0] != MPU9X50_COMP_WHOAMI_ANSWER) {
DEBUG("[Error] Wrong answer from compass\n");
return -1;
}