Reference

API Description

/**
 * @fn begin
 * @brief Initialize UART communication and the sensor
 * @return bool
 * @retval true  Initialization succeeded
 * @retval false Initialization failed
 */
bool begin(void);

/**
 * @fn setSensorMode
 * @brief Set the sensor operating mode
 * @param mode Sensor operating mode (refer to eSensorMode_t)
 * @n Available modes:
 * @n - eSleepMode:           Sleep mode (minimum power consumption, sensor stops working)
 * @n - eLowPowerMode:        Low power mode (reduced sampling rate, power saving)
 * @n - eNormalMode:          Normal mode (balanced power consumption and performance)
 * @n - eHighPerformanceMode: High performance mode (highest sampling rate and accuracy, maximum power consumption)
 * @return bool
 * @retval true  Setting succeeded
 * @retval false Setting failed
 */
bool setSensorMode(eSensorMode_t mode);

/**
 * @fn reset
 * @brief Restore factory settings
 * @return bool
 * @retval true  Factory reset succeeded
 * @retval false Factory reset failed
 */
bool reset(void);

/**
 * @fn setAccelRange
 * @brief Set the accelerometer range
 * @param range Accelerometer range (refer to eAccelRange_t)
 * @n Available ranges:
 * @n - eAccelRange2G:  ±2g range
 * @n - eAccelRange4G:  ±4g range
 * @n - eAccelRange8G:  ±8g range
 * @n - eAccelRange16G: ±16g range
 * @return bool
 * @retval true  Setting succeeded
 * @retval false Setting failed
 */
bool setAccelRange(eAccelRange_t range);

/**
 * @fn setGyroRange
 * @brief Set the gyroscope range
 * @param range Gyroscope range (refer to eGyroRange_t)
 * @n Available ranges:
 * @n - eGyroRange125DPS:  ±125dps range
 * @n - eGyroRange250DPS:  ±250dps range
 * @n - eGyroRange500DPS:  ±500dps range
 * @n - eGyroRange1000DPS: ±1000dps range
 * @n - eGyroRange2000DPS: ±2000dps range
 * @return bool
 * @retval true  Setting succeeded
 * @retval false Setting failed
 */
bool setGyroRange(eGyroRange_t range);

/**
 * @fn get6dofData
 * @brief Read 6-axis IMU data (physical quantities)
 * @param accel Pointer to sSensorData_t structure for storing acceleration data (unit: g)
 * @param gyro Pointer to sSensorData_t structure for storing gyroscope data (unit: dps)
 * @return bool
 * @retval true  Reading succeeded
 * @retval false Reading failed
 */
bool get6dofData(sSensorData_t *accel, sSensorData_t *gyro);

/**
 * @fn get9dofData
 * @brief Read 9-axis IMU data (physical quantities)
 * @param accel Pointer to sSensorData_t structure for storing acceleration data (unit: g)
 * @param gyro Pointer to sSensorData_t structure for storing gyroscope data (unit: dps)
 * @param mag Pointer to sSensorData_t structure for storing magnetometer data (unit: uT)
 * @return bool
 * @retval true  Reading succeeded
 * @retval false Reading failed
 */
bool get9dofData(sSensorData_t *accel, sSensorData_t *gyro, sSensorData_t *mag);

/**
 * @fn setInt
 * @brief Configure interrupt (unified API)
 * @param pin Interrupt pin (refer to eImuIntPin_t)
 * @n Available pins:
 * @n - eImuIntPin1: INT1 pin (6-axis sensor, supports multiple interrupt types)
 * @n - eImuIntPin2: INT2 pin (6-axis sensor, supports multiple interrupt types)
 * @n - eImuIntPin3: INT3 pin (9-axis sensor - magnetometer, only supports data ready interrupt)
 * @param intType Interrupt type (uint8_t)
 * @n Interrupt types supported by INT1/INT2 (eInt1_2Type_t):
 * @n - eInt1_2Disable (0x00): Disable interrupt
 * @n - eInt1_2DataReady (0x01): Data ready interrupt
 * @n - eInt1_2AnyMotion (0x02): Any motion interrupt
 * @n - eInt1_2NoMotion (0x03): No motion interrupt
 * @n - eInt1_2SigMotion (0x04): Significant motion interrupt
 * @n - eInt1_2StepCounter (0x05): Step counter interrupt
 * @n - eInt1_2Flat (0x06): Flat interrupt
 * @n - eInt1_2Orientation (0x07): Orientation interrupt
 * @n - eInt1_2Tap (0x08): Tap interrupt
 * @n - eInt1_2Tilt (0x09): Tilt interrupt
 * @n Interrupt types supported by INT3 (eInt3Type_t):
 * @n - eInt3Disable (0x00): Disable interrupt
 * @n - eInt3DataReady (0x01): Data ready interrupt
 */
bool setInt(eImuIntPin_t pin, uint8_t intType);

/**
 * @fn getIntStatus
 * @brief Read interrupt status (unified API)
 * @param pin Interrupt pin (refer to eImuIntPin_t)
 * @return uint16_t Interrupt status
 * @n Can perform bitwise AND operation with corresponding interrupt status macros to determine the interrupt type
 * @retval 0 No interrupt or read failed
 */
uint16_t getIntStatus(eImuIntPin_t pin);

/**
 * @fn getStepCount
 * @brief Read step counter data
 * @details Read the current accumulated step count
 * @n Call this function to read the accumulated step count after detecting a step interrupt
 * @return uint32_t Accumulated step count (32-bit)
 * @retval 0 No step data or read failed
 */
uint32_t getStepCount(void);

/**
 * @fn getTap
 * @brief Read tap data
 * @details Call this function to read the specific tap type after detecting a tap interrupt
 * @return uint16_t Tap data
 * @n Return values:
 * @n - TAP_TYPE_SINGLE (0x0001): Single tap
 * @n - TAP_TYPE_DOUBLE (0x0002): Double tap
 * @n - TAP_TYPE_TRIPLE (0x0003): Triple tap
 * @retval 0 No tap data or read failed
 */
uint16_t getTap(void);

/**
 * @fn getOrientation
 * @brief Read orientation data
 * @details Call this function to read the specific orientation and face direction after detecting an orientation interrupt
 * @return uint16_t Orientation data
 * @n High byte: Orientation type
 * @n - ORIENT_TYPE_PORTRAIT_UP (0x01): Portrait up
 * @n - ORIENT_TYPE_LANDSCAPE_LEFT (0x02): Landscape left
 * @n - ORIENT_TYPE_LANDSCAPE_RIGHT (0x03): Landscape right
 * @n - ORIENT_TYPE_PORTRAIT_DOWN (0x04): Portrait down
 * @n Low byte: Face direction type
 * @n - ORIENT_FACE_UP (0x00): Face up
 * @n - ORIENT_FACE_DOWN (0x01): Face down
 * @retval 0 No orientation data or read failed
 */
uint16_t getOrientation(void);

Was this article helpful?

ON THIS PAGE

TOP