Contiki-NG
|
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 | sensor_init (void) |
Initialize the MPU-9250 sensor driver. | |
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. | |
static bool | acc_read (uint8_t int_status, uint16_t *data) |
Read data from the accelerometer, total of 3 words (X, Y, Z). | |
static bool | gyro_read (uint8_t int_status, uint16_t *data) |
Read data from the accelerometer, total of 3 words (X, Y, Z). | |
static int32_t | acc_convert (int32_t raw_data) |
Convert accelerometer raw reading to a value in G. | |
static int32_t | gyro_convert (int32_t raw_data) |
Convert gyro raw reading to a value in deg/sec. | |
static int | value (int type) |
Returns a reading from the sensor. | |
static int | configure (int type, int enable) |
Configuration function for the MPU9250 sensor. | |
static int | status (int type) |
Returns the status of the sensor. | |
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: - Turn the sensor off by calling SENSORS_DEACTIVATE, but in order to take subsequent readings the sensor must be started up all over - Leave the sensor on. In this scenario, the caller can simply keep calling value() for subsequent readings, but having the sensor on will consume more energy, especially if both accelerometer and the gyro are on.
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 396 of file mpu-9250-sensor.c.
References value().
|
static |
Read data from the accelerometer, total of 3 words (X, Y, Z).
Definition at line 349 of file mpu-9250-sensor.c.
References i2c_arch_write_read(), int_status(), and value().
|
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 554 of file mpu-9250-sensor.c.
References configure(), ctimer_set(), ctimer_stop(), i2c_arch_acquire(), i2c_arch_release(), sensor_init(), sensor_sleep(), and value().
Referenced by configure().
|
static |
Convert gyro raw reading to a value in deg/sec.
raw_data | The raw accelerometer reading. |
Definition at line 413 of file mpu-9250-sensor.c.
References value().
|
static |
Read data from the accelerometer, total of 3 words (X, Y, Z).
Definition at line 372 of file mpu-9250-sensor.c.
References i2c_arch_write_read(), int_status(), and value().
|
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 336 of file mpu-9250-sensor.c.
References i2c_arch_write_read(), int_status(), and value().
Referenced by value().
|
static |
Initialize the MPU-9250 sensor driver.
Definition at line 243 of file mpu-9250-sensor.c.
References value().
Referenced by configure().
|
static |
Returns the status of the sensor.
type | SENSORS_ACTIVE or SENSORS_READY |
Definition at line 616 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 467 of file mpu-9250-sensor.c.
References acc_convert(), acc_read(), gyro_convert(), gyro_read(), i2c_arch_acquire(), i2c_arch_release(), int_status(), RTIMER_NOW, sensor_data_ready(), and value().
Referenced by acc_read(), configure(), gyro_read(), sensor_data_ready(), sensor_init(), sensor_sleep(), and sensor_wakeup().