/*
 * Copyright (c) 2020 Great Master Wu. All rights reserved.
 * Author    Date          ChangeLog
 * Master    2021-03-17    Initialize version
 */

/** @defgroup DriverIcm426xxSelfTest Icm426xx selftest
 *  @brief Low-level function to run selftest on a Icm426xx device
 *  @ingroup  DriverIcm426xx
 *  @{
 */

/** @file Icm426xxSelfTest.h
 * Low-level function to run selftest on a Icm426xx device
 */

#ifndef _INV_ICM426XX_SELFTEST_H_
#define _INV_ICM426XX_SELFTEST_H_

#ifdef __cplusplus
extern "C" {
#endif

/* forward declaration */
struct inv_icm426xx;

/**
*  @brief      Perform hardware self-test for Accel and Gyro
*  @param[in]  result containing ACCEL_SUCCESS<<1 | GYRO_SUCCESS so 3
*  @return     0 if success, error code if failure
*/
int inv_icm426xx_run_selftest(struct inv_icm426xx * s, int * result);

/**
*  @brief      Retrieve bias collected by self-test.
*  @param[out] st_bias bias scaled by 2^16, accel is gee and gyro is dps.
*                      The buffer will be filled as below.
*                      Gyro LN mode X,Y,Z
*                      Accel LN mode X,Y,Z
*  @return     0 if success, error code if failure
*/
int inv_icm426xx_get_st_bias(struct inv_icm426xx * s, int st_bias[6]);

/**
*  @brief      Apply bias.
*  @param[in] st_bias bias scaled by 2^16, accel is gee and gyro is dps.
*                      The buffer must be filled as below.
*                      Gyro LN mode X,Y,Z
*                      Accel LN mode X,Y,Z
*  @return     0 if success, error code if failure
*/
int inv_icm426xx_set_st_bias(struct inv_icm426xx * s, const int st_bias[6]);

#ifdef __cplusplus
}
#endif

#endif /* _INV_ICM426XX_SELFTEST_H_ */

/** @} */
