Skip to content

Commit

Permalink
Added BMI088 self test. Closes #575
Browse files Browse the repository at this point in the history
The gyro-self test runs every startup but the acc self-test only during
manufacturing test as no external accelerations should be applied during
the test.
  • Loading branch information
tobbeanton committed Apr 24, 2020
1 parent f7616f9 commit 17c8f86
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 6 deletions.
41 changes: 40 additions & 1 deletion src/hal/src/sensors_bmi088_bmp388.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,25 @@ void sensorsBmi088Bmp388Init(void)
bool sensorsBmi088Bmp388Test(void)
{
bool testStatus = true;
int8_t gyroResult = 0;

if (!isInit)
{
DEBUG_PRINT("Uninitialized\n");
testStatus = false;
}

bmi088_perform_gyro_selftest(&gyroResult, &bmi088Dev);
if (gyroResult == BMI088_SELFTEST_PASS)
{
DEBUG_PRINT("BMI088 gyro self-test [OK]\n");
}
else
{
DEBUG_PRINT("BMI088 gyro self-test [FAILED]\n");
testStatus = false;
}

return testStatus;
}

Expand Down Expand Up @@ -770,7 +782,34 @@ static bool sensorsFindBiasValue(BiasObj* bias)

bool sensorsBmi088Bmp388ManufacturingTest(void)
{
return true;

bool testStatus = true;
int8_t gyroResult = 0;
int8_t accResult = 0;

bmi088_perform_gyro_selftest(&gyroResult, &bmi088Dev);
if (gyroResult == BMI088_SELFTEST_PASS)
{
DEBUG_PRINT("BMI088 gyro self-test [OK]\n");
}
else
{
DEBUG_PRINT("BMI088 gyro self-test [FAILED]\n");
testStatus = false;
}

bmi088_perform_accel_selftest(&accResult, &bmi088Dev);
if (accResult == BMI088_SELFTEST_PASS)
{
DEBUG_PRINT("BMI088 acc self-test [OK]\n");
}
else
{
DEBUG_PRINT("BMI088 acc self-test [FAILED]\n");
testStatus = false;
}

return testStatus;
}

/**
Expand Down
48 changes: 43 additions & 5 deletions src/hal/src/sensors_bmi088_spi_bmp388.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,12 +854,24 @@ void sensorsBmi088SpiBmp388Init(void)
bool sensorsBmi088SpiBmp388Test(void)
{
bool testStatus = true;
int8_t gyroResult = 0;

if (!isInit)
{
DEBUG_PRINT("Uninitialized\n");
testStatus = false;
}
{
DEBUG_PRINT("Uninitialized\n");
testStatus = false;
}

bmi088_perform_gyro_selftest(&gyroResult, &bmi088Dev);
if (gyroResult == BMI088_SELFTEST_PASS)
{
DEBUG_PRINT("BMI088 gyro self-test [OK]\n");
}
else
{
DEBUG_PRINT("BMI088 gyro self-test [FAILED]\n");
testStatus = false;
}

return testStatus;
}
Expand Down Expand Up @@ -1063,7 +1075,33 @@ static bool sensorsFindBiasValue(BiasObj* bias)

bool sensorsBmi088SpiBmp388ManufacturingTest(void)
{
return true;
bool testStatus = true;
int8_t gyroResult = 0;
int8_t accResult = 0;

bmi088_perform_gyro_selftest(&gyroResult, &bmi088Dev);
if (gyroResult == BMI088_SELFTEST_PASS)
{
DEBUG_PRINT("BMI088 gyro self-test [OK]\n");
}
else
{
DEBUG_PRINT("BMI088 gyro self-test [FAILED]\n");
testStatus = false;
}

bmi088_perform_accel_selftest(&accResult, &bmi088Dev);
if (accResult == BMI088_SELFTEST_PASS)
{
DEBUG_PRINT("BMI088 acc self-test [OK]\n");
}
else
{
DEBUG_PRINT("BMI088 acc self-test [FAILED]\n");
testStatus = false;
}

return testStatus;
}

/**
Expand Down

0 comments on commit 17c8f86

Please sign in to comment.