|
Nol.A SDK Library 26.11.2
For IoT System Software Development
|
MMA8452Q accelerometer register driver with optional interrupt GPIOs. Initialize the I2C bus before begin(); communication errors are not reported. More...
#include <MMA8452Q.hpp>
Public Types | |
| enum | ODR_t { ODR_800Hz = 0 , ODR_400Hz = 1 , ODR_200Hz = 2 , ODR_100Hz = 3 , ODR_50Hz = 4 , ODR_12p5Hz = 5 , ODR_6p25Hz = 6 , ODR_1p56Hz = 7 } |
| Output data rate selections in hertz. More... | |
| enum | Mode_t { MODE_NORMAL = 0 , MODE_LOW_NOISE_LOW_POWER = 1 , MODE_HIGH_RESOLUTION = 2 , MODE_LOW_POWER = 3 } |
| Sampling power/noise mode selections. More... | |
Public Member Functions | |
| void | begin (TwoWire &wire, uint8_t addr, int8_t pinInt1=-1, int8_t pinInt2=-1) |
| Bind the bus/address and attach falling-edge interrupt handlers. | |
| uint8_t | readSensorId () |
| Return the WHO_AM_I register byte. | |
| void | readXYZ (int16_t *x, int16_t *y, int16_t *z) |
| Read and assemble signed axis register values without conversion to g. | |
| bool | isActive () |
| Return the ACTIVE bit from the control register. | |
| void | setActive () |
| Set the ACTIVE bit to enable measurements. | |
| void | setStandby () |
| Clear the ACTIVE bit to enter standby. | |
| ODR_t | getODR () |
| Return the configured output data rate. | |
| void | setODR (ODR_t val) |
| Set the output data rate, temporarily entering standby if needed. | |
| void | onDetectTransient (void(*func)(MMA8452Q &)) |
| Register the transient interrupt callback; nullptr disables notification. | |
| void | setTransientDetection (bool enableX, bool enableY, bool enableZ, uint16_t thresholdMilliG, uint32_t durationMicros) |
| Configure transient detection and restore the previous active state. | |
| void | setMode (Mode_t) |
| Write the sampling power/noise mode; put the sensor in standby first. | |
| Mode_t | getMode () |
| Return the configured sampling power/noise mode. | |
MMA8452Q accelerometer register driver with optional interrupt GPIOs. Initialize the I2C bus before begin(); communication errors are not reported.
| enum MMA8452Q::Mode_t |
Sampling power/noise mode selections.
| enum MMA8452Q::ODR_t |
Output data rate selections in hertz.
| void MMA8452Q::begin | ( | TwoWire & | wire, |
| uint8_t | addr, | ||
| int8_t | pinInt1 = -1, | ||
| int8_t | pinInt2 = -1 ) |
Bind the bus/address and attach falling-edge interrupt handlers.
| wire | Initialized I2C bus that outlives the driver. |
| addr | 7-bit sensor address. |
| pinInt1 | Optional INT1 GPIO; -1 disables attachment. |
| pinInt2 | Optional INT2 GPIO; -1 disables attachment. |
| void MMA8452Q::onDetectTransient | ( | void(* | func )(MMA8452Q &) | ) |
Register the transient interrupt callback; nullptr disables notification.
| func | Receives this driver when a transient interrupt is handled. |
| void MMA8452Q::readXYZ | ( | int16_t * | x, |
| int16_t * | y, | ||
| int16_t * | z ) |
Read and assemble signed axis register values without conversion to g.
| x | Optional X output; nullptr skips storing it. |
| y | Optional Y output; nullptr skips storing it. |
| z | Optional Z output; nullptr skips storing it. The current implementation combines each high byte shifted by four with the unshifted low byte, then sign-extends bit 11; it does not normalize the low byte. |
| void MMA8452Q::setODR | ( | ODR_t | val | ) |
Set the output data rate, temporarily entering standby if needed.
| val | Output data rate selection. |
| void MMA8452Q::setTransientDetection | ( | bool | enableX, |
| bool | enableY, | ||
| bool | enableZ, | ||
| uint16_t | thresholdMilliG, | ||
| uint32_t | durationMicros ) |
Configure transient detection and restore the previous active state.
| enableX | Requested X-axis enable; currently not applied independently (X follows enableZ). |
| enableY | Enable Y-axis transient detection. |
| enableZ | Enable Z-axis detection; also controls X in the current implementation. |
| thresholdMilliG | Threshold in milli-g, clamped to 8000 and quantized in 63 milli-g steps. |
| durationMicros | Duration in microseconds, clamped and quantized for the current mode/rate. |