LIS3DH / STMicroelectronics / MEMS motion sensor, 3-axis accelerometer library
Dependents: GR-PEACH_test_wo_rtos GR-PEACH_test_on_rtos_works_well Skywire_Demo_3 Skywire_Kinetis_K64_demo ... more
LIS3DH Class Reference
Interface for STMicronics MEMS motion sensor: 3-axis "nano" accelerometer Chip: LIS3DH. More...
#include <LIS3DH.h>
Public Member Functions | |
LIS3DH (PinName p_sda, PinName p_scl, uint8_t addr, uint8_t data_rate, uint8_t fullscale) | |
Configure data pin. | |
LIS3DH (PinName p_sda, PinName p_scl, uint8_t addr) | |
Configure data pin. | |
LIS3DH (I2C &p_i2c, uint8_t addr, uint8_t data_rate, uint8_t fullscale) | |
Configure data pin (with other devices on I2C line) | |
LIS3DH (I2C &p_i2c, uint8_t addr) | |
Configure data pin (with other devices on I2C line) | |
void | read_data (float *dt_usr) |
Read a float type data from acc. | |
void | read_mg_data (float *dt_usr) |
Read a float type data from acc. | |
uint8_t | read_id () |
Read a acc 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 "nano" accelerometer Chip: LIS3DH.
#include "mbed.h" // I2C Communication LIS3DH acc(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 LIS3DH acc(i2c, chip_addr, datarate, bandwidth, fullscale); int main() { float f[3]; if (acc.read_id() == I_AM_LIS3DH){ acc.read_data(f); } }
Definition at line 147 of file LIS3DH.h.
Constructor & Destructor Documentation
LIS3DH | ( | PinName | p_sda, |
PinName | p_scl, | ||
uint8_t | addr, | ||
uint8_t | data_rate, | ||
uint8_t | fullscale | ||
) |
Configure data pin.
- Parameters:
-
data SDA and SCL pins device address LIS3DH(SA0=0 or 1), LIS3DH_G_CHIP_ADDR or LIS3DH_V_CHIP_ADDR output data rate selection, power down mode, 1Hz to 5KHz full scale selection, +/-2g to +/-16g
Definition at line 15 of file LIS3DH.cpp.
LIS3DH | ( | PinName | p_sda, |
PinName | p_scl, | ||
uint8_t | addr | ||
) |
Configure data pin.
- Parameters:
-
data SDA and SCL pins device address LIS3DH(SA0=0 or 1), LIS3DH_G_CHIP_ADDR or LIS3DH_V_CHIP_ADDR output data rate selection = 50Hz full scale selection = +/-8g
Definition at line 23 of file LIS3DH.cpp.
LIS3DH | ( | I2C & | p_i2c, |
uint8_t | addr, | ||
uint8_t | data_rate, | ||
uint8_t | fullscale | ||
) |
Configure data pin (with other devices on I2C line)
- Parameters:
-
I2C previous definition other parameters -> please see LIS3DH(PinName p_sda, PinName p_scl,...)
Definition at line 30 of file LIS3DH.cpp.
LIS3DH | ( | I2C & | p_i2c, |
uint8_t | addr | ||
) |
Configure data pin (with other devices on I2C line)
- Parameters:
-
I2C previous definition other parameters -> please see LIS3DH(PinName p_sda, PinName p_scl,...) output data rate selection = 50Hz full scale selection = +/-8g
Definition at line 38 of file LIS3DH.cpp.
Member Function Documentation
uint8_t data_ready | ( | ) |
void frequency | ( | int | hz ) |
void read_data | ( | float * | dt_usr ) |
Read a float type data from acc.
- Parameters:
-
float type of three arry's address, e.g. float dt_usr[3];
- Returns:
- acc motion data unit: m/s/s(m/s2)
- dt_usr[0]->x, dt_usr[1]->y, dt_usr[2]->z
Definition at line 122 of file LIS3DH.cpp.
uint8_t read_id | ( | ) |
Read a acc ID number.
- Parameters:
-
none
- Returns:
- if STM MEMS acc, it should be I_AM_ LIS3DH(0x33)
Definition at line 145 of file LIS3DH.cpp.
void read_mg_data | ( | float * | dt_usr ) |
Read a float type data from acc.
- Parameters:
-
float type of three arry's address, e.g. float dt_usr[3];
- Returns:
- acc motion data unit: mg
- dt_usr[0]->x, dt_usr[1]->y, dt_usr[2]->z
Definition at line 99 of file LIS3DH.cpp.
uint8_t read_reg | ( | uint8_t | addr ) |
Read register (general purpose)
- Parameters:
-
register's address
- Returns:
- register data
Definition at line 171 of file LIS3DH.cpp.
void write_reg | ( | uint8_t | addr, |
uint8_t | data | ||
) |
Write register (general purpose)
- Parameters:
-
register's address data
- Returns:
- none
Definition at line 183 of file LIS3DH.cpp.
Generated on Tue Jul 12 2022 14:29:02 by 1.7.2