Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LIS3DH by
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 151 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 19 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 27 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 39 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 47 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 154 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 177 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 131 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 203 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 215 of file LIS3DH.cpp.
Generated on Sun Jul 24 2022 15:23:42 by
1.7.2
