mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 05:42:49 +08:00
[boards] imu_krooz: only set flag in isr, read data in event
This should prevent new i2c transactions beeing inserted from the ISR and hence preventing other transactions from beeing properly added to the queue. i2c_submit can currently not be called from ISRs, since the transaction queue is checked before interrupts are disabled.
This commit is contained in:
@@ -28,10 +28,10 @@ void exti9_5_isr(void) {
|
||||
/* clear EXTI */
|
||||
if(EXTI_PR & EXTI6) {
|
||||
exti_reset_request(EXTI6);
|
||||
hmc58xx_read(&imu_krooz.hmc);
|
||||
imu_krooz.hmc_eoc = TRUE;
|
||||
}
|
||||
if(EXTI_PR & EXTI5) {
|
||||
exti_reset_request(EXTI5);
|
||||
mpu60x0_i2c_read(&imu_krooz.mpu);
|
||||
imu_krooz.mpu_eoc = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,9 @@ void imu_impl_init( void )
|
||||
imu_krooz.acc_valid = FALSE;
|
||||
imu_krooz.mag_valid = FALSE;
|
||||
|
||||
imu_krooz.hmc_eoc = FALSE;
|
||||
imu_krooz.mpu_eoc = FALSE;
|
||||
|
||||
imu_krooz_sd_arch_init();
|
||||
}
|
||||
|
||||
@@ -155,6 +158,11 @@ void imu_krooz_downlink_raw( void )
|
||||
|
||||
void imu_krooz_event( void )
|
||||
{
|
||||
if (imu_krooz.mpu_eoc) {
|
||||
mpu60x0_i2c_read(&imu_krooz.mpu);
|
||||
imu_krooz.mpu_eoc = FALSE;
|
||||
}
|
||||
|
||||
// If the MPU6050 I2C transaction has succeeded: convert the data
|
||||
mpu60x0_i2c_event(&imu_krooz.mpu);
|
||||
if (imu_krooz.mpu.data_available) {
|
||||
@@ -164,6 +172,11 @@ void imu_krooz_event( void )
|
||||
imu_krooz.mpu.data_available = FALSE;
|
||||
}
|
||||
|
||||
if (imu_krooz.hmc_eoc) {
|
||||
hmc58xx_read(&imu_krooz.hmc);
|
||||
imu_krooz.hmc_eoc = FALSE;
|
||||
}
|
||||
|
||||
// If the HMC5883 I2C transaction has succeeded: convert the data
|
||||
hmc58xx_event(&imu_krooz.hmc);
|
||||
if (imu_krooz.hmc.data_available) {
|
||||
|
||||
@@ -111,6 +111,8 @@ struct ImuKrooz {
|
||||
volatile bool_t gyr_valid;
|
||||
volatile bool_t acc_valid;
|
||||
volatile bool_t mag_valid;
|
||||
volatile bool_t mpu_eoc;
|
||||
volatile bool_t hmc_eoc;
|
||||
struct Mpu60x0_I2c mpu;
|
||||
struct Hmc58xx hmc;
|
||||
struct Int32Rates rates_sum;
|
||||
|
||||
Reference in New Issue
Block a user