InvenSense IMU-3000 digital triaxial gyroscope.
This module implements a driver for the InvenSense IMU-3000 digital 3-axis MEMS gyroscope and digital motion processor (IMU). The IMU-3000 provides digital-output x-, y-, and z-axis angular rate sensor readings with a sensitivity of 16 LSBs per deg/sec and programmable full-scale ranges of +/-250, +/-500, +/-1000, and +/-2000 deg/sec. The device includes a dedicated I2C master accelerometer sensor bus facilitating direct data acquisition from an off-chip third party accelerometer without intervention from an external processor. A configurable 512 Byte FIFO allows system microcontrollers to burst read the sensor data and then sleep while the IMU collects more data.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include "imu3000.h"
Data Structures | |
struct | imu3000_event_t |
Macros | |
#define | IMU3000_RESOLUTION (16) |
Axis data sample resolution (bits) More... | |
Functions | |
static bool | imu3000_default_init (sensor_hal_t *hal, sensor_hal_t *aux) |
InvenSense IMU-3000 gyroscope driver defaults. More... | |
static bool | imu3000_device_id (sensor_hal_t *hal, sensor_data_t *data) |
Read gyroscope device ID. More... | |
static bool | imu3000_event (sensor_t *sensor, sensor_event_t sensor_event, sensor_event_callback_t *callback, bool enable) |
Enable/disable IMU3000 sensor event. More... | |
static bool | imu3000_get_rotation (sensor_hal_t *hal, sensor_data_t *data) |
Read gyroscope angular rate axis data. More... | |
static bool | imu3000_get_temperature (sensor_hal_t *hal, sensor_data_t *data) |
Read gyroscope integrated temperature sensor data. More... | |
bool | imu3000_init (sensor_t *sensor, int resvd) |
InvenSense IMU-3000 motion processor driver initialization. More... | |
static bool | imu3000_ioctl (sensor_t *sensor, sensor_command_t cmd, void *arg) |
IMU3000 ioctl control entry point. More... | |
static void | imu3000_isr (volatile void *arg) |
Invensense IMU3000 driver interrupt service routine. More... | |
static bool | imu3000_read (sensor_t *sensor, sensor_read_t type, sensor_data_t *data) |
Read sensor data. More... | |
static bool | imu3000_set_bandwidth (sensor_hal_t *hal, int16_t band) |
Set the IMU-3000 low-pass filter bandwidth. More... | |
static bool | imu3000_set_range (sensor_hal_t *hal, int16_t range) |
Set the IMU-3000 full scale range. More... | |
static bool | imu3000_set_sample_rate (sensor_hal_t *hal, int16_t rate) |
Set the IMU3000 sample rate. More... | |
static bool | imu3000_set_state (sensor_hal_t *hal, sensor_state_t state) |
Set the IMU-3000 execution mode. More... | |
Variables | |
static const sensor_map_t | band_table [] |
InvenSense IMU-3000 low-pass Bandwidth Table (hertz, register value) More... | |
static sensor_event_callback_t | event_cb = {.handler = default_event_handler} |
Sensor Event Callback Descriptor. More... | |
static const sensor_map_t | range_table [] |
InvenSense IMU-3000 Range Table (deg/sec, register value) More... | |
int16_t const | scale_lsb_per_dps [] |
Sensitivity Scale Factors. More... | |
static int | sensor_dlpf_cfg = 3 |
The digital low-pass filter table index defaults to 42 Hz. More... | |
static int | sensor_fs_sel = 3 |
The range table index defaults to 2000 deg/sec full-scale. More... | |
#define IMU3000_RESOLUTION (16) |
Axis data sample resolution (bits)
|
static |
InvenSense IMU-3000 gyroscope driver defaults.
This is a convenience routine for setting the default device configuration during initialization or after reset.
References bus_desc_t::addr, AUX_ADDR_CLKOUTEN, sensor_hal::burst_addr, sensor_hal::bus, IMU3000_AUX_BURST_ADDR, IMU3000_AUX_SLV_ADDR, IMU3000_DLPF_FS, IMU3000_ID_VAL, IMU3000_PWR_MGM, IMU3000_SMPLRT_DIV, IMU3000_USER_CTRL, IMU3000_WHO_AM_I, IMU3000_X_OFFS_USRH, PWR_MGM_CLK_SEL_Z, PWR_MGM_H_RESET, sensor_map_t::reserved_val, sensor_bus_get, sensor_bus_put, sensor_bus_write, sensor_dlpf_cfg, sensor_fs_sel, status, bus_desc_t::status, STATUS_OK, USER_CTRL_AUX_IF_EN, and USER_CTRL_AUX_IF_RST.
Referenced by imu3000_set_state().
|
static |
Read gyroscope device ID.
This function reads the gyroscope hardware identification registers and returns these values to the addresses specified in the function parameters.
sensor | Address of an initialized sensor device descriptor. |
data | Address of sensor_data_t structure to return values. |
References sensor_data_t::device, IMU3000_WHO_AM_I, and sensor_bus_get.
Referenced by imu3000_read().
|
static |
Enable/disable IMU3000 sensor event.
sensor | Address of an initialized sensor device descriptor |
callback | Application-defined event callback handler descriptor |
enable | Enable flag: true = enable event, false = disable event |
References sensor_desc::hal, IMU3000_INT_CFG, INT_CFG_ANYRD_2CLEAR, INT_CFG_LATCH_INT_EN, INT_CFG_RAW_RDY_EN, sensor_bus_put, SENSOR_EVENT_NEW_DATA, sensor_reg_bitclear, and status.
Referenced by imu3000_init(), and imu3000_ioctl().
|
static |
Read gyroscope angular rate axis data.
This function reads angular rate data for all 3 axes of an IMU-3000 gyroscope.
sensor | Address of an initialized sensor device descriptor. |
data | The address of a vector storing sensor axis data. |
References sensor_data_t::axis, sensor_axis_vec_t::axis, IMU3000_GYRO_XOUT_H, sensor_hal::orientation, scale_lsb_per_dps, sensor_data_t::scaled, sensor_bus_read, sensor_fs_sel, sensor_axis_vec_t::sign, sensor_orient_t::x, sensor_orient_t::y, and sensor_orient_t::z.
Referenced by imu3000_ioctl(), and imu3000_read().
|
static |
Read gyroscope integrated temperature sensor data.
This function reads IMU-3000 integrated temperature sensor data. The temperature is always returned in scaled engineering units (degrees Celsius).
sensor | Address of an initialized sensor device descriptor. |
data | The address where temperature samples are returned. |
References be16_to_cpu, IMU3000_TEMP_OUT_H, sensor_data_t::scaled, sensor_bus_read, TEMP_COUNTS_PER_DEG_C, TEMP_OFFSET, TEMP_REF_DEG, and sensor_data_t::temperature.
Referenced by imu3000_read().
InvenSense IMU-3000 motion processor driver initialization.
This is the main initialization function for the IMU-3000 device.
sensor | Address of a sensor device descriptor. |
resvd | Reserved value. |
References ARRAYSIZE, sensor_desc::aux, sensor_device_t::func, sensor_desc::hal, imu3000_event(), imu3000_ioctl(), imu3000_read(), sensor_funcs_t::read, SENSOR_CAPS_3_AXIS, SENSOR_CAPS_AUX_ACCEL, SENSOR_CAPS_AUX_TEMP, SENSOR_UNITS_deg_per_sec, SENSOR_VENDOR_INVENSENSE, and status.
|
static |
IMU3000 ioctl control entry point.
This function provides a general-purpose interface for performing various control operations on the sensor device.
sensor | Address of an initialized sensor device descriptor. |
cmd | Command to execute |
arg | Argument for command (varies) |
References sensor_data_t::axis, sensor_desc::err, sensor_desc::hal, imu3000_event(), imu3000_get_rotation(), imu3000_set_bandwidth(), imu3000_set_range(), imu3000_set_sample_rate(), imu3000_set_state(), sensor_data_t::scaled, SENSOR_DISABLE_EVENT, SENSOR_ENABLE_EVENT, SENSOR_ERR_UNSUPPORTED, SENSOR_READ_VECTOR, SENSOR_SET_BANDWIDTH, SENSOR_SET_RANGE, SENSOR_SET_SAMPLE_RATE, SENSOR_SET_STATE, vector3_t::x, vector3_t::y, and vector3_t::z.
Referenced by imu3000_init().
|
static |
Invensense IMU3000 driver interrupt service routine.
This is the interrupt service routine for enabled IMU3000 interrupt events. Only the new data ("raw data ready") interrupt is supported.
arg | The address of the driver sensor_hal_t descriptor. |
References sensor_event_callback_t::arg, sensor_data_t::axis, sensor_axis_vec_t::axis, sensor_hal::burst_addr, sensor_hal::bus, sensor_event_data_t::data, sensor_event_data_t::event, sensor_event_callback_t::handler, bus_desc_t::no_wait, sensor_hal::orientation, scale_lsb_per_dps, sensor_data_t::scaled, sensor_bus_read, SENSOR_EVENT_NEW_DATA, sensor_fs_sel, sensor_timestamp(), sensor_axis_vec_t::sign, bus_desc_t::status, STATUS_OK, sensor_data_t::timestamp, sensor_orient_t::x, imu3000_event_t::x_hi, imu3000_event_t::x_lo, sensor_orient_t::y, imu3000_event_t::y_hi, imu3000_event_t::y_lo, sensor_orient_t::z, imu3000_event_t::z_hi, and imu3000_event_t::z_lo.
|
static |
Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device.
sensor | Address of an initialized sensor device descriptor. |
type | Type of sensor data to read. |
data | The address where data values are returned. |
References sensor_desc::err, sensor_desc::hal, imu3000_device_id(), imu3000_get_rotation(), imu3000_get_temperature(), SENSOR_ERR_FUNCTION, SENSOR_READ_ID, SENSOR_READ_ROTATION, and SENSOR_READ_TEMPERATURE.
Referenced by imu3000_init().
|
static |
Set the IMU-3000 low-pass filter bandwidth.
This routine sets the IMU-3000 low-pass filter bandwidth and the internal sample rate used by the device. This internal sample rate is then further scaled by the sample rate divider (SMPLRT_DIV) value to produce the gyro sample rate according to the formula:
F_sample = F_internal / (divider + 1)
Valid filter bandwidths and the associated internal sample rate are as follows:
hal | Address of an initialized sensor device descriptor. |
band | The index of a driver-specific bandwidth table entry. |
References DLPF_CFG_FIELD, IMU3000_DLPF_FS, sensor_bus_get, sensor_bus_put, and sensor_dlpf_cfg.
Referenced by imu3000_ioctl().
|
static |
Set the IMU-3000 full scale range.
This routine sets the IMU-3000 full scale range using an index to a table of valid ranges: +/-250, +/-500, +/-1000, and +/-2000 deg/sec.
hal | Address of an initialized sensor device descriptor. |
range | The index o a driver-specific range table entry. |
References FS_SEL_FIELD, IMU3000_DLPF_FS, sensor_bus_get, sensor_bus_put, and sensor_fs_sel.
Referenced by imu3000_ioctl().
|
static |
Set the IMU3000 sample rate.
This routine sets the externally visible IMU3000 sample rate for the device. This sets a divider that scaled down the internal 1Khz or 8 KHz sample rate to the specified frequency, according to the formula:
The internal sampling rate is 1KHz for all filter bandwidths except 256Hz, which uses an 8KHz internal rate.
hal | Address of an initialized sensor device descriptor. |
rate | The externally visible sampling rate to be set |
References sensor_hal::bandwidth, IMU3000_SMPLRT_DIV, and sensor_bus_put.
Referenced by imu3000_ioctl().
|
static |
Set the IMU-3000 execution mode.
This routine sets a specified IMU-3000 execution state to one of the following:
SENSOR_STATE_SLEEP or SENSOR_STATE_LOWEST_POWER Setting the sleep mode puts the device into very low power sleep mode. In this mode, only the serial interface and internal registers remain active.
SENSOR_STATE_NORMAL or SENSOR_STATE_HIGHEST_POWER Sets the device to a normal operational state.
SENSOR_STATE_RESET Sets the device and internal registers to the power-up default settings.
sensor | Address of an initialized sensor device descriptor. |
state | A specified sensor operational state. |
Update sensor device descriptor operational settings.
References delay_ms, imu3000_default_init(), IMU3000_PWR_MGM, PWR_MGM_SLEEP, sensor_reg_bitclear, sensor_reg_bitset, SENSOR_STATE_HIGHEST_POWER, SENSOR_STATE_LOWEST_POWER, SENSOR_STATE_NORMAL, SENSOR_STATE_RESET, and SENSOR_STATE_SLEEP.
Referenced by imu3000_ioctl().
|
static |
InvenSense IMU-3000 low-pass Bandwidth Table (hertz, register value)
|
static |
Sensor Event Callback Descriptor.
|
static |
InvenSense IMU-3000 Range Table (deg/sec, register value)
int16_t const scale_lsb_per_dps[] |
Sensitivity Scale Factors.
Referenced by imu3000_get_rotation(), and imu3000_isr().
|
static |
The digital low-pass filter table index defaults to 42 Hz.
Referenced by imu3000_default_init(), and imu3000_set_bandwidth().
|
static |
The range table index defaults to 2000 deg/sec full-scale.
Referenced by imu3000_default_init(), imu3000_get_rotation(), imu3000_isr(), and imu3000_set_range().