Loading...
Searching...
No Matches
itg320x.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
40#ifndef ITG320X_H
41#define ITG320X_H
42
43#ifdef __cplusplus
44extern "C"
45{
46#endif
47
48#include <stdbool.h>
49#include <stdint.h>
50
51#include "periph/gpio.h"
52#include "periph/i2c.h"
53
58#define ITG320X_I2C_ADDRESS_1 (0x68)
59#define ITG320X_I2C_ADDRESS_2 (0x69)
63#define ITG320X_ID (0x68)
64
75
94
98typedef enum {
102
110
122
126typedef struct {
127 int16_t x;
128 int16_t y;
129 int16_t z;
131
139typedef struct {
140 int16_t x;
141 int16_t y;
142 int16_t z;
144
148typedef struct {
150 uint8_t addr;
152 uint8_t isr_div;
162#if MODULE_ITG320X_INT || DOXYGEN
163 gpio_t int_pin;
169#endif /* MODULE_ITG320X_INT || DOXYGEN */
171
175typedef struct {
177} itg320x_t;
178
179#if MODULE_ITG320X_INT || DOXYGEN
189typedef void (*itg320x_drdy_int_cb_t)(void *);
190
191#endif /* MODULE_ITG320X_INT || DOXYGEN */
192
206int itg320x_init(itg320x_t *dev, const itg320x_params_t *params);
207
208#if MODULE_ITG320X_INT || DOXYGEN
225int itg320x_init_int(const itg320x_t *dev, itg320x_drdy_int_cb_t cb, void *arg);
226
227#endif /* MODULE_ITG320X_INT || DOXYGEN */
228
242
257int itg320x_read(const itg320x_t *dev, itg320x_data_t *data);
258
270
281int itg320x_read_temp(const itg320x_t *dev, int16_t* temp);
282
296
310
311#ifdef __cplusplus
312}
313#endif
314
315#endif /* ITG320X_H */
Low-level GPIO peripheral driver interface definitions.
int itg320x_read(const itg320x_t *dev, itg320x_data_t *data)
Read one sample of angular rates in tenths of a degree per second.
itg320x_lpf_bw_t
Low pass filter bandwidth.
Definition itg320x.h:85
int itg320x_init_int(const itg320x_t *dev, itg320x_drdy_int_cb_t cb, void *arg)
Initialize and activate the DRDY interrupt of ITG320X sensor device.
int itg320x_power_up(itg320x_t *dev)
Power up the sensor.
int itg320x_read_temp(const itg320x_t *dev, int16_t *temp)
Read temperature in tenths of a degree Celsius.
itg320x_clk_sel_t
Clock source selection (ITG320X_REG_PWR_MGM<2:0>)
Definition itg320x.h:114
int itg320x_read_raw(const itg320x_t *dev, itg320x_raw_data_t *raw)
Read one sample of raw sensor data as 16 bit two's complements.
void(* itg320x_drdy_int_cb_t)(void *)
ITG320X data ready interrupt (DRDY) callback function type.
Definition itg320x.h:189
int itg320x_init(itg320x_t *dev, const itg320x_params_t *params)
Initialize the ITG320X sensor device.
itg320x_int_drive_t
Drive type for INT output pin (ITG320X_REG_INT_CFG<6>)
Definition itg320x.h:106
int itg320x_data_ready(const itg320x_t *dev)
Data-ready status function.
itg320x_error_codes_t
Named return values.
Definition itg320x.h:68
itg320x_int_level_t
Logic level for INT output pin (ITG320X_REG_INT_CFG<7>)
Definition itg320x.h:98
int itg320x_power_down(itg320x_t *dev)
Power down the sensor.
@ ITG320X_LPF_BW_20
20 Hz, ISR = 1 kHz
Definition itg320x.h:90
@ ITG320X_LPF_BW_98
98 Hz, ISR = 1 kHz
Definition itg320x.h:88
@ ITG320X_LPF_BW_10
10 Hz, ISR = 1 kHz
Definition itg320x.h:91
@ ITG320X_LPF_BW_42
42 Hz, ISR = 1 kHz
Definition itg320x.h:89
@ ITG320X_LPF_BW_5
5 Hz, ISR = 1 kHz (default)
Definition itg320x.h:92
@ ITG320X_LPF_BW_256
256 Hz, ISR = 8 kHz
Definition itg320x.h:86
@ ITG320X_LPF_BW_188
188 Hz, ISR = 1 kHz
Definition itg320x.h:87
@ ITG320X_CLK_PLL_19M
PLL with external 19.2 MHz reference.
Definition itg320x.h:120
@ ITG320X_CLK_PLL_Y_GYRO
PLL with X Gyro reference.
Definition itg320x.h:117
@ ITG320X_CLK_INTERNAL
Internal oscillator.
Definition itg320x.h:115
@ ITG320X_CLK_PLL_Z_GYRO
PLL with X Gyro reference.
Definition itg320x.h:118
@ ITG320X_CLK_PLL_X_GYRO
PLL with X Gyro reference (default)
Definition itg320x.h:116
@ ITG320X_CLK_PLL_32K
PLL with external 32.768 kHz reference.
Definition itg320x.h:119
@ ITG320X_INT_PUSH_PULL
INT output is of type push/pull (default)
Definition itg320x.h:107
@ ITG320X_INT_OPEN_DRAIN
INT output is of type open drain.
Definition itg320x.h:108
@ ITG320X_ERROR_I2C
I2C communication error.
Definition itg320x.h:70
@ ITG320X_OK
success
Definition itg320x.h:69
@ ITG320X_ERROR_RAW_DATA
reading raw data failed
Definition itg320x.h:73
@ ITG320X_ERROR_NO_DATA
no data are available
Definition itg320x.h:72
@ ITG320X_ERROR_WRONG_ID
wrong id read
Definition itg320x.h:71
@ ITG320X_INT_LOW
INT output is active low.
Definition itg320x.h:100
@ ITG320X_INT_HIGH
INT output is active high (default)
Definition itg320x.h:99
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
Angular rate values in tenths of a degree per second.
Definition itg320x.h:126
int16_t z
angular rate y-axis (yaw)
Definition itg320x.h:129
int16_t x
angular rate x-axis (roll)
Definition itg320x.h:127
int16_t y
angular rate y-axis (pitch)
Definition itg320x.h:128
ITG320X device initialization parameters.
Definition itg320x.h:148
itg320x_int_level_t int_level
Logic level for INT output pin (default ITG320X_INT_LOW)
Definition itg320x.h:165
uint8_t addr
I2C slave address (default ITG320X_I2C_ADDRESS_1)
Definition itg320x.h:150
uint8_t isr_div
Internal sample rate divider ISR_DIV (default 99) ODR = ISR / (ISR_DIV + 1) where internal sample rat...
Definition itg320x.h:152
gpio_t int_pin
DRDY interrupt pin: GPIO_UNDEF if not used.
Definition itg320x.h:163
i2c_t dev
I2C device (default I2C_DEV(0))
Definition itg320x.h:149
itg320x_int_drive_t int_drive
Drive type for INT output pin (default ITG320X_INT_PUSH_PULL.
Definition itg320x.h:167
itg320x_clk_sel_t clk_sel
Clock source selection (default ITG320X_CLK_PLL_X_GYRO)
Definition itg320x.h:159
itg320x_lpf_bw_t lpf_bw
Low pass filter bandwidth (default ITG320X_LPF_BW_5, ISR 1 kHz)
Definition itg320x.h:157
Raw data set as two complements.
Definition itg320x.h:139
int16_t x
angular rate x-axis as 16 bit two's complements (roll)
Definition itg320x.h:140
int16_t y
angular rate y-axis as 16 bit two's complements (pitch)
Definition itg320x.h:141
int16_t z
angular rate z-axis as 16 bit two's complements (yaw)
Definition itg320x.h:142
ITG320X sensor device data structure type.
Definition itg320x.h:175
itg320x_params_t params
device initialization parameters
Definition itg320x.h:176