L3GD20 & L3G4200D / STMicroelectronics / MEMS motion sensor, three-axis gyroscope library
Dependents: GR-PEACH_test_wo_rtos GR-PEACH_test_on_rtos_works_well
L3GX_GYRO Class Reference
Interface for STMicronics MEMS motion sensor: 3-axis digital gyroscope Chip: L3GD20 (new one) and L3G4200 (old one) More...
#include <L3GD20.h>
Public Member Functions | |
L3GX_GYRO (PinName p_sda, PinName p_scl, uint8_t addr, uint8_t data_rate, uint8_t bandwidth, uint8_t fullscale) | |
Configure data pin. | |
L3GX_GYRO (PinName p_sda, PinName p_scl, uint8_t addr) | |
Configure data pin. | |
L3GX_GYRO (I2C &p_i2c, uint8_t addr, uint8_t data_rate, uint8_t bandwidth, uint8_t fullscale) | |
Configure data pin (with other devices on I2C line) | |
L3GX_GYRO (I2C &p_i2c, uint8_t addr) | |
Configure data pin (with other devices on I2C line) | |
int8_t | read_temp () |
Read a tow's complemet type data from Gyro. | |
void | read_data (float *dt_usr) |
Read a float type data from Gyro. | |
uint8_t | read_id () |
Read a Gyro ID number. | |
uint8_t | data_ready () |
Read Data Ready flag. | |
void | frequency (int hz) |
Set I2C clock frequency. | |
uint8_t | read_reg (uint8_t addr) |
Read register (general purpose) | |
void | write_reg (uint8_t addr, uint8_t data) |
Write register (general purpose) |
Detailed Description
Interface for STMicronics MEMS motion sensor: 3-axis digital gyroscope Chip: L3GD20 (new one) and L3G4200 (old one)
#include "mbed.h" // I2C Communication L3GX_GYRO gyro(p_sda, p_scl, chip_addr, datarate, bandwidth, fullscale); // If you connected I2C line not only this device but also other devices, // you need to declare following method. I2C i2c(dp5,dp27); // SDA, SCL L3GX_GYRO gyro(i2c, chip_addr, datarate, bandwidth, fullscale); int main() { float f[3]; int8_t t; if (gyro.read_id() == I_AM_L3G4200D){ t = gyro.read_temp(); gyro.read_data(f); } }
Definition at line 129 of file L3GD20.h.
Constructor & Destructor Documentation
L3GX_GYRO | ( | PinName | p_sda, |
PinName | p_scl, | ||
uint8_t | addr, | ||
uint8_t | data_rate, | ||
uint8_t | bandwidth, | ||
uint8_t | fullscale | ||
) |
Configure data pin.
- Parameters:
-
data SDA and SCL pins device address L3G4200D(SA0=0 or 1) or L3GD20(SA0=0 or 1) ->L3G4200D_G_CHIP_ADDR to L3GD20_V_CHIP_ADDR output data rate selection, DR_100HZ/DR_95HZ to DR_800HZ/DR_760HZ bandwidth selection, BW_LOW to BW_HI full scale selection, FS_250DPS, FS_500DPS, FS_2000DPS
Definition at line 19 of file L3GD20.cpp.
L3GX_GYRO | ( | PinName | p_sda, |
PinName | p_scl, | ||
uint8_t | addr | ||
) |
Configure data pin.
- Parameters:
-
data SDA and SCL pins device address L3G4200D(SA0=0 or 1) or L3GD20(SA0=0 or 1) ->L3G4200D_G_CHIP_ADDR to L3GD20_V_CHIP_ADDR output data rate selection = DR_100HZ/DR_95HZ bandwidth selection = BW_HI full scale selection = FS_250DPS
Definition at line 27 of file L3GD20.cpp.
L3GX_GYRO | ( | I2C & | p_i2c, |
uint8_t | addr, | ||
uint8_t | data_rate, | ||
uint8_t | bandwidth, | ||
uint8_t | fullscale | ||
) |
Configure data pin (with other devices on I2C line)
- Parameters:
-
I2C previous definition other parameters -> please see L3GX_GYRO(PinName p_sda, PinName p_scl,...)
Definition at line 34 of file L3GD20.cpp.
L3GX_GYRO | ( | I2C & | p_i2c, |
uint8_t | addr | ||
) |
Configure data pin (with other devices on I2C line)
- Parameters:
-
I2C previous definition other parameters -> please see L3GX_GYRO(PinName p_sda, PinName p_scl,...) output data rate selection = DR_100HZ/DR_95HZ bandwidth selection = BW_HI full scale selection = FS_250DPS
Definition at line 42 of file L3GD20.cpp.
Member Function Documentation
uint8_t data_ready | ( | ) |
void frequency | ( | int | hz ) |
void read_data | ( | float * | dt_usr ) |
Read a float type data from Gyro.
- Parameters:
-
float type of three arry's address, e.g. float dt_usr[3];
- Returns:
- Gyro motion data unit in param array:dps(degree per second)
- dt_usr[0]->x, dt_usr[1]->y, dt_usr[2]->z
Definition at line 96 of file L3GD20.cpp.
uint8_t read_id | ( | ) |
Read a Gyro ID number.
- Parameters:
-
none
- Returns:
- if STM MEMS Gyro, it should be I_AM_L3G4200D(0xd3) or I_AM_L3GD20(0xd4)
Definition at line 133 of file L3GD20.cpp.
uint8_t read_reg | ( | uint8_t | addr ) |
Read register (general purpose)
- Parameters:
-
register's address
- Returns:
- register data
Definition at line 159 of file L3GD20.cpp.
int8_t read_temp | ( | ) |
Read a tow's complemet type data from Gyro.
- Parameters:
-
none
- Returns:
- temperature unit:degreeC(Celsius)
Definition at line 121 of file L3GD20.cpp.
void write_reg | ( | uint8_t | addr, |
uint8_t | data | ||
) |
Write register (general purpose)
- Parameters:
-
register's address data
- Returns:
- none
Definition at line 171 of file L3GD20.cpp.
Generated on Wed Jul 27 2022 22:57:45 by 1.7.2