Contiki-Inga 3.x
Data Structures | Macros | Functions
l3g4200d.h File Reference

 ST L3G4200D 3-axis Gyroscope interface definitions
More...

#include "../dev/i2c.h"
#include <util/delay.h>

Go to the source code of this file.

Data Structures

struct  angle_data_t
 Angle data type. More...
 

Macros

#define l3g4200d_raw_to_dps(raw)   (int16_t) (((int32_t) raw * l3g4200d_dps_scale) / 4000)
 Convert raw values to dps.
 
Register addresses.

Naming convention of the datasheet with prefix L3G4200D_ is used.

#define L3G4200D_WHO_AM_I_REG   0x0F
 Device identification register.
 
#define L3G4200D_CTRL_REG1   0x20
 Control register 1.
 
#define L3G4200D_CTRL_REG2   0x21
 Control register 2.
 
#define L3G4200D_CTRL_REG3   0x22
 Control register 3.
 
#define L3G4200D_CTRL_REG4   0x23
 Control register 4.
 
#define L3G4200D_CTRL_REG5   0x24
 Control register 5.
 
#define L3G4200D_REFERENCE   0x25
 Reference value for Interrupt generation.
 
#define L3G4200D_OUT_TEMP   0x26
 Temperature data.
 
#define L3G4200D_STATUS_REG   0x27
 Status register.
 
#define L3G4200D_OUT_X_L   0x28
 X-axis angular rate data. (low)
 
#define L3G4200D_OUT_X_H   0x29
 X-axis angular rate data. (high)
 
#define L3G4200D_OUT_Y_L   0x2A
 Y-axis angular rate data. (low)
 
#define L3G4200D_OUT_Y_H   0x2B
 Y-axis angular rate data. (high)
 
#define L3G4200D_OUT_Z_L   0x2C
 Z-axis angular rate data. (low)
 
#define L3G4200D_OUT_Z_H   0x2D
 Z-axis angular rate data. (high)
 
#define L3G4200D_FIFO_CTRL_REG   0x2E
 Fifo control register.
 
#define L3G4200D_FIFO_SRC_REG   0x2F
 Fifo source register.
 
Bit addresses for CTRL_REG1
#define L3G4200D_DR1   7
 Output Data Rate selection (higher)
 
#define L3G4200D_DR0   6
 Output Data Rate selection (lower)
 
#define L3G4200D_BW1   5
 Bandwidth selection (higher)
 
#define L3G4200D_BW0   4
 Bandwidth selection (lower)
 
#define L3G4200D_PD   3
 Power down mode enable.
 
#define L3G4200D_ZEN   2
 Z axis enable.
 
#define L3G4200D_YEN   1
 Y axis enable.
 
#define L3G4200D_XEN   0
 X axis enable.
 
Bit addresses for CTRL_REG2.
#define L3G4200D_HPM1   5
 High Pass filter Mode Selection (higher)
 
#define L3G4200D_HPM0   4
 High Pass filter Mode Selection (lower)
 
#define L3G4200D_HPCF3   3
 High Pass filter Cutt Off frequency selection (highest)
 
#define L3G4200D_HPCF2   2
 High Pass filter Cutt Off frequency selection.
 
#define L3G4200D_HPCF1   1
 High Pass filter Cutt Off frequency selection.
 
#define L3G4200D_HPCF0   0
 High Pass filter Cutt Off frequency selection (lowest)
 
Bit addresses for CTRL_REG3.
#define L3G4200D_I1_INT1   7
 Interrupt enable on INT1 pin.
 
#define L3G4200D_I1_BOOT   6
 Boot status available on INT1.
 
#define L3G4200D_H_LACTIVE   5
 Interrupt active configuration on INT1.
 
#define L3G4200D_PP_OD   4
 Push-Pull / Open drain.
 
#define L3G4200D_I2_DRDY   3
 Data Ready on DRDY/INT2.
 
#define L3G4200D_I2_WTM   2
 FIFO Watermark interrupt on DRDY/INT2.
 
#define L3G4200D_I2_ORUN   1
 FIFO Overrun interrupt on DRDY/INT2.
 
#define L3G4200D_I2_EMPTY   0
 FIFO Empty interrupt on DRDY/INT2.
 
Bit addresses for CTRL_REG4.
#define L3G4200D_BDU   7
 Block Data Update.
 
#define L3G4200D_BLE   6
 Big/Little Endian Data Selection.
 
#define L3G4200D_FS1   5
 Full Scale Selection (higher)
 
#define L3G4200D_FS0   4
 Full Scale Selection (lower)
 
#define L3G4200D_ST1   2
 Self Test Enable (higher)
 
#define L3G4200D_ST0   1
 Self Test Enable (lower)
 
#define L3G4200D_SIM   0
 SPI Serial Interface mode selection.
 
Bit addresses for CTRL_REG5.
#define L3G4200D_BOOT   7
 Reboot memory content.
 
#define L3G4200D_FIFO_EN   6
 FIFO enable.
 
#define L3G4200D_HPEN   4
 High Pass filter Enable.
 
#define L3G4200D_INT1_SEL1   3
 INT1 selection configuration (higher)
 
#define L3G4200D_INT1_SEL0   2
 INT1 selection configuration (lower)
 
#define L3G4200D_OUT_SEL1   1
 Out selection configuration (higher)
 
#define L3G4200D_OUT_SEL0   0
 Out selection configuration (lower)
 
Bit addresses for STATUS_REG.
#define L3G4200D_ZYXOR   7
 X, Y, Z-axis data overrun.
 
#define L3G4200D_ZOR   6
 Z axis data overrun.
 
#define L3G4200D_YOR   5
 Y axis data overrun.
 
#define L3G4200D_XOR   4
 X axis data overrun.
 
#define L3G4200D_ZYXDA   3
 X, Y, Z-axis new data available.
 
#define L3G4200D_ZDA   2
 Z axis new data available.
 
#define L3G4200D_YDA   1
 Y axis new data available.
 
#define L3G4200D_XDA   0
 X axis new data available.
 
Bit addresses for FIFO_CTRL_REG.
#define L3G4200D_FM2   7
 FIFO mode selection.
 
#define L3G4200D_FM1   6
 FIFO mode selection.
 
#define L3G4200D_FM0   5
 FIFO mode selection.
 
#define L3G4200D_WTM4   4
 FIFO threshold. Watermark level setting (highest)
 
#define L3G4200D_WTM3   3
 FIFO threshold. Watermark level setting.
 
#define L3G4200D_WTM2   2
 FIFO threshold. Watermark level setting.
 
#define L3G4200D_WTM1   1
 FIFO threshold. Watermark level setting.
 
#define L3G4200D_WTM0   0
 FIFO threshold. Watermark level setting (lowest)
 
Bit addresses for FIFO_SRC_REG.
#define L3G4200D_WTM   7
 Watermark status.
 
#define L3G4200D_OVRN   6
 Overrun bit status.
 
#define L3G4200D_EMPTY   5
 FIFO empty bit.
 
#define L3G4200D_FSS4   4
 FIFO stored data level (highest)
 
#define L3G4200D_FSS3   3
 FIFO stored data level.
 
#define L3G4200D_FSS2   2
 FIFO stored data level.
 
#define L3G4200D_FSS1   1
 FIFO stored data level.
 
#define L3G4200D_FSS0   0
 FIFO stored data level (lowest)
 
Resolution Settings.
#define L3G4200D_250DPS   (0x00 << L3G4200D_FS0)
 
#define L3G4200D_500DPS   (0x01 << L3G4200D_FS0)
 
#define L3G4200D_2000DPS   (0x02 << L3G4200D_FS0)
 
Data rate Settings.
#define L3G4200D_ODR_100HZ   (0x0 << L3G4200D_DR0)
 ODR: 100Hz.
 
#define L3G4200D_ODR_200HZ   (0x1 << L3G4200D_DR0)
 ODR: 200Hz.
 
#define L3G4200D_ODR_400HZ   (0x2 << L3G4200D_DR0)
 ODR: 400Hz.
 
#define L3G4200D_ODR_800HZ   (0x3 << L3G4200D_DR0)
 ODR: 800Hz.
 
Mode Settings.
#define L3G4200D_BYPASS   (0x00 << L3G4200D_FM0)
 
#define L3G4200D_FIFO   (0x01 << L3G4200D_FM0)
 
#define L3G4200D_STREAM   (0x02 << L3G4200D_FM0)
 
#define L3G4200D_STREAM_TO_FIFO   (0x03 << L3G4200D_FM0)
 
#define L3G4200D_BYPASS_TO_STREAM   (0x04 << L3G4200D_FM0)
 

Functions

int8_t l3g4200d_available (void)
 Checks if l3g4200d is avialable. More...
 
int8_t l3g4200d_init (void)
 Inits the gyroscope. More...
 
int8_t l3g4200d_deinit (void)
 Deinit the gyroscope. More...
 
uint8_t l3g4200d_set_dps (uint8_t set)
 Sets the sensitivity value [dps]. More...
 
uint8_t l3g4200d_set_data_rate (uint8_t set)
 Sets the data rate [Hz]. More...
 
void l3g4200d_set_fifomode (uint8_t set)
 Sets the fifo mode. More...
 
void l3g4200d_fifo_enable (void)
 Enables fifo mode.
 
int8_t l3g4200d_fifo_overrun (void)
 Checks for fifo overrun. More...
 
angle_data_t l3g4200d_get_angle (void)
 Reads data for x,y and z angle. More...
 
int8_t l3g4200d_get_angle_fifo (angle_data_t *ret)
 Reads angle values from fifo. More...
 
int16_t l3g4200d_get_x_angle (void)
 Reads x angle value. More...
 
int16_t l3g4200d_get_y_angle (void)
 Reads y angle value. More...
 
int16_t l3g4200d_get_z_angle (void)
 Reads z angle value. More...
 
int8_t l3g4200d_get_temp (void)
 Reads temperature value. More...
 
uint16_t l3g4200d_read16bit (uint8_t addr)
 Reads 2x8 bit register from gyroscopes. More...
 
uint8_t l3g4200d_read8bit (uint8_t addr)
 Reads 8 bit register from gyroscopes. More...
 
void l3g4200d_write8bit (uint8_t addr, uint8_t data)
 Writes 8 bit to gyroscope register. More...
 

Detailed Description

 ST L3G4200D 3-axis Gyroscope interface definitions
Author
Ulf Kulau kulau.nosp@m.@ibr.nosp@m..cs.t.nosp@m.u-bs.nosp@m..de Enrico Jörns e.joe.nosp@m.rns@.nosp@m.tu-bs.nosp@m..de

Definition in file l3g4200d.h.