LittleBrain-STM32F4-Sensorboard
LittleBrain-STM32F4-Sensorboard copied to clipboard
SPI NSS for gyro and accelerometer being pulled low at the same time.
I've faced an issue with gyro and accelerometer CS pins being pulled low simultaneously, making the retrieved data contain garbage values once a while (about every 1~2 seconds). There needs to be a mechanism to prevent this like using while() to wait for its turn to read.
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
if (GPIO_Pin == INT_ACC_Pin) {
while(imu.readingGyr);
BMI088_ReadAccelerometerDMA(&imu);
} else if (GPIO_Pin == INT_GYR_Pin) {
while(imu.readingAcc);
BMI088_ReadGyroscopeDMA(&imu);
}
}
and in the BMI088.c file the imu.readingGyr and imu.readingAcc flags should be set before pulling the CS low (and unset after pulling CS to high) to prevent race condition.