Device driver for InvenSense ITG320X 3-axis gyroscope.
More...
Device driver for InvenSense ITG320X 3-axis gyroscope.
The driver can be used with InvenSense ITG3200, ITG3205, and MPU3050. The latter one can be used only with reduced feature set.
The driver implements polling mode as well as interrupt mode. Thus, the application may use two different approaches to retrieve new data, either
- periodically fetching the data at a rate lower than the sensor's output data rate (ODR), or
- fetching the data when the data-ready interrupt is triggered.
To use the latter approach, module itg320x_int
has to be enabled and the GPIO to which the sensor's INT output pin is connected has to be configured.
This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.
|
file | itg320x.h |
| Device driver for InvenSense ITG320X 3-axis gyroscope.
|
|
file | itg320x_params.h |
| Default configuration for InvenSense ITG320X 3-axis gyroscope.
|
|
file | itg320x_regs.h |
| Register definitions for InvenSense ITG320X 3-axis gyroscope.
|
|
|
#define | ITG320X_ID (0x68) |
| ITG320X chip id defined in Who Am I.
|
|
|
enum | itg320x_error_codes_t {
ITG320X_OK = 0,
ITG320X_ERROR_I2C = -1,
ITG320X_ERROR_WRONG_ID = -2,
ITG320X_ERROR_NO_DATA = -3,
ITG320X_ERROR_RAW_DATA = -4
} |
| Named return values. More...
|
|
enum | itg320x_lpf_bw_t {
ITG320X_LPF_BW_256 = 0,
ITG320X_LPF_BW_188,
ITG320X_LPF_BW_98,
ITG320X_LPF_BW_42,
ITG320X_LPF_BW_20,
ITG320X_LPF_BW_10,
ITG320X_LPF_BW_5
} |
| Low pass filter bandwidth. More...
|
|
enum | itg320x_int_level_t { ITG320X_INT_HIGH = 0x00,
ITG320X_INT_LOW = 0x80
} |
| Logic level for INT output pin (ITG320X_REG_INT_CFG<7>) More...
|
|
enum | itg320x_int_drive_t { ITG320X_INT_PUSH_PULL = 0x00,
ITG320X_INT_OPEN_DRAIN = 0x40
} |
| Drive type for INT output pin (ITG320X_REG_INT_CFG<6>) More...
|
|
enum | itg320x_clk_sel_t {
ITG320X_CLK_INTERNAL = 0,
ITG320X_CLK_PLL_X_GYRO,
ITG320X_CLK_PLL_Y_GYRO,
ITG320X_CLK_PLL_Z_GYRO,
ITG320X_CLK_PLL_32K,
ITG320X_CLK_PLL_19M
} |
| Clock source selection (ITG320X_REG_PWR_MGM<2:0>) More...
|
|
◆ itg320x_drdy_int_cb_t
typedef void(* itg320x_drdy_int_cb_t) (void *) |
ITG320X data ready interrupt (DRDY) callback function type.
Function prototype for the function which is called on DRDY interrupt if the interrupt is activated by itg320x_init_int
- Note
- The
cb
function is called in interrupt context. The application should do nothing time consuming and not directly access sensor data.
Definition at line 189 of file itg320x.h.
◆ itg320x_clk_sel_t
Clock source selection (ITG320X_REG_PWR_MGM<2:0>)
Enumerator |
---|
ITG320X_CLK_INTERNAL | Internal oscillator.
|
ITG320X_CLK_PLL_X_GYRO | PLL with X Gyro reference (default)
|
ITG320X_CLK_PLL_Y_GYRO | PLL with X Gyro reference.
|
ITG320X_CLK_PLL_Z_GYRO | PLL with X Gyro reference.
|
ITG320X_CLK_PLL_32K | PLL with external 32.768 kHz reference.
|
ITG320X_CLK_PLL_19M | PLL with external 19.2 MHz reference.
|
Definition at line 114 of file itg320x.h.
◆ itg320x_error_codes_t
Named return values.
Enumerator |
---|
ITG320X_OK | success
|
ITG320X_ERROR_I2C | I2C communication error.
|
ITG320X_ERROR_WRONG_ID | wrong id read
|
ITG320X_ERROR_NO_DATA | no data are available
|
ITG320X_ERROR_RAW_DATA | reading raw data failed
|
Definition at line 68 of file itg320x.h.
◆ itg320x_int_drive_t
Drive type for INT output pin (ITG320X_REG_INT_CFG<6>)
Enumerator |
---|
ITG320X_INT_PUSH_PULL | INT output is of type push/pull (default)
|
ITG320X_INT_OPEN_DRAIN | INT output is of type open drain.
|
Definition at line 106 of file itg320x.h.
◆ itg320x_int_level_t
Logic level for INT output pin (ITG320X_REG_INT_CFG<7>)
Enumerator |
---|
ITG320X_INT_HIGH | INT output is active high (default)
|
ITG320X_INT_LOW | INT output is active low.
|
Definition at line 98 of file itg320x.h.
◆ itg320x_lpf_bw_t
Low pass filter bandwidth.
- Note
- Low pass filter bandwidth determines the internal sample rate (ISR). The internal sample rate (ISR) together with sample rate divider (ISR_DIV) determines the output data rate ODR = ISR / (ISR_DIV + 1) where internal sample rate (ISR) is 8 kHz for ITG320X_LPF_BW_256, or 1 kHz otherwise.
Enumerator |
---|
ITG320X_LPF_BW_256 | 256 Hz, ISR = 8 kHz
|
ITG320X_LPF_BW_188 | 188 Hz, ISR = 1 kHz
|
ITG320X_LPF_BW_98 | 98 Hz, ISR = 1 kHz
|
ITG320X_LPF_BW_42 | 42 Hz, ISR = 1 kHz
|
ITG320X_LPF_BW_20 | 20 Hz, ISR = 1 kHz
|
ITG320X_LPF_BW_10 | 10 Hz, ISR = 1 kHz
|
ITG320X_LPF_BW_5 | 5 Hz, ISR = 1 kHz (default)
|
Definition at line 85 of file itg320x.h.
◆ itg320x_data_ready()
int itg320x_data_ready |
( |
const itg320x_t * |
dev | ) |
|
Data-ready status function.
The function checks the status register and returns
- Parameters
-
[in] | dev | device descriptor of ITG320X sensor |
- Return values
-
ITG320X_OK | new data available |
ITG320X_ERROR_NO_DATA | no new data available |
ITG320X_ERROR_* | negative error code, see itg320x_error_codes_t |
◆ itg320x_init()
Initialize the ITG320X sensor device.
This function resets the sensor and initializes the sensor according to given initialization parameters. All registers are reset to default values.
- Parameters
-
[in] | dev | device descriptor of ITG320X sensor to be initialized |
[in] | params | ITG320X initialization parameters |
- Return values
-
◆ itg320x_init_int()
Initialize and activate the DRDY interrupt of ITG320X sensor device.
This function activates the DRDY interrupt and initializes the pin defined as the interrupt pin in the initialization parameters of the device. The cb
parameter specifies the function, along with an optional argument arg
, which is called when a DRDY interrupt is triggered.
- Warning
- The given callback function
cb
is executed in interrupt context. Make sure not to call any driver API function in that context.
- Note
- This function is only available when module
itg320x_int
is enabled.
- Parameters
-
[in] | dev | device descriptor of ITG320X sensor |
[in] | cb | function called when DRDY interrupt is triggered |
[in] | arg | argument for the callback function |
◆ itg320x_power_down()
Power down the sensor.
Changes the sensor operation mode to sleep mode in which almost all including the gyros are switched off.
- Parameters
-
[in] | dev | Device descriptor of ITG320X device to read from |
- Return values
-
◆ itg320x_power_up()
Power up the sensor.
Swichtes the sensor back into active operation mode. It takes up to 20 ms since the gyros have to be switched on again.
- Parameters
-
[in] | dev | Device descriptor of ITG320X device to read from |
- Return values
-
◆ itg320x_read()
Read one sample of angular rates in tenths of a degree per second.
Raw magnetometer data are read from the sensor and normalized with respect to full scale +-2000 dps. Angular rate values are given in tenths of a degrees per second:
- Parameters
-
[in] | dev | device descriptor of ITG320X sensor |
[out] | data | result vector in tenths of a degrees per second |
- Return values
-
◆ itg320x_read_raw()
Read one sample of raw sensor data as 16 bit two's complements.
- Parameters
-
[in] | dev | device descriptor of ITG320X sensor |
[out] | raw | raw data vector |
- Return values
-
◆ itg320x_read_temp()
int itg320x_read_temp |
( |
const itg320x_t * |
dev, |
|
|
int16_t * |
temp |
|
) |
| |
Read temperature in tenths of a degree Celsius.
- Parameters
-
[in] | dev | device descriptor of ITG320X sensor |
[out] | temp | temperature tenths of a degree Celsius |
- Return values
-