Contiki-NG
|
Driver for the Invensense MPU-9250 Motion Processing Unit.More...
Files | |
file | mpu-9250-sensor.c |
Driver for the Sensortag Invensense MPU9250 motion processing unit. | |
file | mpu-9250-sensor.h |
Header file for the Sensortag Invensense MPU-9250 motion processing unit. | |
Enumerations | |
enum | MPU_9250_SENSOR_TYPE { MPU_9250_SENSOR_TYPE_NONE = (0), MPU_9250_SENSOR_TYPE_GYRO_X = (1 << 0), MPU_9250_SENSOR_TYPE_GYRO_Y = (1 << 1), MPU_9250_SENSOR_TYPE_GYRO_Z = (1 << 2), MPU_9250_SENSOR_TYPE_ACC_X = (1 << 3), MPU_9250_SENSOR_TYPE_ACC_Y = (1 << 4), MPU_9250_SENSOR_TYPE_ACC_Z = (1 << 5), MPU_9250_SENSOR_TYPE_GYRO, MPU_9250_SENSOR_TYPE_ACC, MPU_9250_SENSOR_TYPE_ALL } |
Functions | |
static bool | i2c_write_read (void *wbuf, size_t wcount, void *rbuf, size_t rcount) |
Setup and peform an I2C transaction. More... | |
static bool | i2c_write (void *wbuf, size_t wcount) |
Peform a write only I2C transaction. More... | |
static bool | i2c_read (void *rbuf, size_t rcount) |
Peform a read only I2C transaction. More... | |
static bool | sensor_init (void) |
Initialize the MPU-9250 sensor driver. More... | |
static void | sensor_sleep (void) |
Place the sensor in low-power mode. | |
static void | sensor_wakeup (void) |
Wakeup the sensor from low-power mode. | |
static bool | sensor_data_ready (uint8_t *int_status) |
Check whether a data or wake on motion interrupt has occurred. More... | |
static bool | acc_read (uint8_t int_status, uint16_t *data) |
Read data from the accelerometer, total of 3 words (X, Y, Z). More... | |
static bool | gyro_read (uint8_t int_status, uint16_t *data) |
Read data from the accelerometer, total of 3 words (X, Y, Z). More... | |
static int32_t | acc_convert (int32_t raw_data) |
Convert accelerometer raw reading to a value in G. More... | |
static int32_t | gyro_convert (int32_t raw_data) |
Convert gyro raw reading to a value in deg/sec. More... | |
static int | value (int type) |
Returns a reading from the sensor. More... | |
static int | configure (int type, int enable) |
Configuration function for the MPU9250 sensor. More... | |
static int | status (int type) |
Returns the status of the sensor. More... | |
Driver for the Invensense MPU-9250 Motion Processing Unit.
Due to the time required between triggering a reading and the reading becoming available, this driver is meant to be used in an asynchronous fashion. The caller must first activate the sensor by calling
mpu_9250_sensor.configure(SENSORS_ACTIVE, xyz);
The value for the xyz arguments depends on the required readings. If the caller intends to read both the accelerometer as well as the gyro then xyz should be MPU_9250_SENSOR_TYPE_ALL. If the caller only needs to take a reading from one of the two elements, xyz should be one of MPU_9250_SENSOR_TYPE_ACC or MPU_9250_SENSOR_TYPE_GYRO
Calling configure() will power up the sensor and initialise it. When the sensor is ready to provide readings, the driver will generate a sensors_changed event.
Calls to status() will return the driver's state which could indicate that the sensor is off, booting or on.
Once a reading has been taken, the caller has two options:
enum MPU_9250_SENSOR_TYPE |
Definition at line 90 of file mpu-9250-sensor.h.
|
static |
Convert accelerometer raw reading to a value in G.
raw_data | The raw accelerometer reading. |
Definition at line 453 of file mpu-9250-sensor.c.
|
static |
Read data from the accelerometer, total of 3 words (X, Y, Z).
Definition at line 406 of file mpu-9250-sensor.c.
|
static |
Configuration function for the MPU9250 sensor.
type | Activate, enable or disable the sensor. See below. |
enable | Enable or disable sensor. When type == SENSORS_HW_INIT we turn on the hardware. When type == SENSORS_ACTIVE and enable==1 we enable the sensor. When type == SENSORS_ACTIVE and enable==0 we disable the sensor. |
Definition at line 590 of file mpu-9250-sensor.c.
|
static |
Convert gyro raw reading to a value in deg/sec.
raw_data | The raw accelerometer reading. |
Definition at line 470 of file mpu-9250-sensor.c.
|
static |
Read data from the accelerometer, total of 3 words (X, Y, Z).
Definition at line 429 of file mpu-9250-sensor.c.
|
inlinestatic |
Peform a read only I2C transaction.
rbuf | Input buffer during the I2C transation. |
rcount | How many bytes to read into rbuf. |
Definition at line 279 of file mpu-9250-sensor.c.
References i2c_write_read().
|
inlinestatic |
Peform a write only I2C transaction.
wbuf | Output buffer during the I2C transation. |
wcount | How many bytes in the wbuf. |
Definition at line 267 of file mpu-9250-sensor.c.
References i2c_write_read().
|
static |
Setup and peform an I2C transaction.
wbuf | Output buffer during the I2C transation. |
wcount | How many bytes in the wbuf. |
rbuf | Input buffer during the I2C transation. |
rcount | How many bytes to read into rbuf. |
Definition at line 247 of file mpu-9250-sensor.c.
Referenced by i2c_read(), and i2c_write().
|
static |
Check whether a data or wake on motion interrupt has occurred.
This driver does not use interrupts, however this function allows us to determine whether a new sensor reading is available.
Definition at line 393 of file mpu-9250-sensor.c.
|
static |
Initialize the MPU-9250 sensor driver.
Definition at line 289 of file mpu-9250-sensor.c.
|
static |
Returns the status of the sensor.
type | SENSORS_ACTIVE or SENSORS_READY |
Definition at line 643 of file mpu-9250-sensor.c.
|
static |
Returns a reading from the sensor.
type | MPU_9250_SENSOR_TYPE_ACC_[XYZ] or MPU_9250_SENSOR_TYPE_GYRO_[XYZ]. |
Definition at line 516 of file mpu-9250-sensor.c.