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.
H3LIS331 Class Reference
H3LIS331 triple axis digital accelerometer. More...
#include <H3LIS331.h>
Public Member Functions | |
| H3LIS331 (PinName sda, PinName scl) | |
| Constructor. | |
| char | getWhoAmI (void) |
| Get the identity of the device. | |
| void | setPowerMode (char power_mode) |
| Set the power mode (power down, low power, normal mode) | |
| char | getPowerMode (void) |
| Get the current power mode. | |
| void | setFullScaleRange400g (void) |
| Set the interrupt configuration. | |
| void | setFullScaleRange200g (void) |
| Set the Full Scale Range to +/- 200g's. | |
| void | setFullScaleRange100g (void) |
| Set the Full Scale Range to +/- 100g's. | |
| float | getAccelX (void) |
| Get the output for the x-axis accelerometer. | |
| float | getAccelY (void) |
| Get the output for the y-axis accelerometer. | |
| float | getAccelZ (void) |
| Get the output on the z-axis accelerometer. | |
Detailed Description
H3LIS331 triple axis digital accelerometer.
Definition at line 61 of file H3LIS331.h.
Constructor & Destructor Documentation
| H3LIS331 | ( | PinName | sda, |
| PinName | scl | ||
| ) |
Constructor.
Includes.
Sets FS_SEL to 0x03 for proper opertaion.
- Parameters:
-
sda - mbed pin to use for the SDA I2C line. scl - mbed pin to use for the SCL I2C line.
Definition at line 7 of file H3LIS331.cpp.
Member Function Documentation
| float getAccelX | ( | void | ) |
Get the output for the x-axis accelerometer.
- Returns:
- The output on the x-axis in engineering units (g's).
Definition at line 154 of file H3LIS331.cpp.
| float getAccelY | ( | void | ) |
Get the output for the y-axis accelerometer.
- Returns:
- The output on the y-axis in engineering units (g's).
Definition at line 170 of file H3LIS331.cpp.
| float getAccelZ | ( | void | ) |
Get the output on the z-axis accelerometer.
- Returns:
- The output on the z-axis in engineering units (g's).
Definition at line 185 of file H3LIS331.cpp.
| char getPowerMode | ( | void | ) |
| char getWhoAmI | ( | void | ) |
Get the identity of the device.
- Returns:
- The contents of the Who Am I register which contains the I2C address of the device.
Definition at line 45 of file H3LIS331.cpp.
| void setFullScaleRange100g | ( | void | ) |
Set the Full Scale Range to +/- 100g's.
Definition at line 127 of file H3LIS331.cpp.
| void setFullScaleRange200g | ( | void | ) |
Set the Full Scale Range to +/- 200g's.
Definition at line 114 of file H3LIS331.cpp.
| void setFullScaleRange400g | ( | void | ) |
Set the interrupt configuration.
See datasheet for configuration byte details.
7 6 5 4 +-------+-------+------+--------+ | IHL | PP_OD | LIR2 | I2_CFG | +-------+-------+------+--------+
3 2 1 0 +---------+------+---------+---------+ | I2_CFG0 | LIR1 | I1_CFG1 | I1-CFG0 | +---------+------+---------+---------+
IHL Interrupt active high or low. 0:active high; 1:active low (default:0) PP_OD Push-pull/Open drain selection on interrupt pad. 0:push-pull; 1:open drain (default:0) LIR2 Latch interupt request on INT2_SRC register, with INT2_SRC register cleared by reading INT2_SRC itself 0: irq not latched; 1:irq latched (default:0) I2_CFG1, I2_CFG0 See datasheet table LIR1 Latch interupt request on INT1_SRC register, with INT1_SRC register cleared by reading INT1_SRC itself 0: irq not latched; 1:irq latched (default:0) I1_CFG1, I1_CFG0 See datasheet table
- Parameters:
-
config Configuration byte to write to INT_CFG register. Check the status register
- Returns:
- Set the Full Scale Range to +/- 400g's.
Definition at line 102 of file H3LIS331.cpp.
| void setPowerMode | ( | char | power_mode ) |
Set the power mode (power down, low power, normal mode)
- Parameters:
-
Power Mode | Output Data Rate (Hz) | Low-pass Filter Cut off (Hz) | define -------------------------------------------------------------------------------- Power-down | -- | -- | POWER_DOWN Normal | 50 | 37 | NORMAL_50HZ Normal | 100 | 74 | NORMAL_100HZ Normal | 400 | 292 | NORMAL_400HZ Normal | 1000 | 780 | NORMAL_1000HZ Low-power | 0.5 | -- | LOW_POWER_0_5HZ Low-power | 1 | -- | LOW_POWER_1HZ Low-power | 2 | -- | LOW_POWER_2HZ Low-power | 5 | -- | LOW_POWER_5HZ Low-power | 10 | -- | LOW_POWER_10HZ
Definition at line 62 of file H3LIS331.cpp.
Generated on Fri Jul 15 2022 09:28:08 by
1.7.2