Ejemplo n.º 1
0
void imu_hbmini_event(void)
{
  uint32_t now_ts = get_sys_time_usec();

  max1168_event();

  if (max1168_status == MAX1168_DATA_AVAILABLE) {
    imu.gyro_unscaled.p  = max1168_values[IMU_GYRO_P_CHAN];
    imu.gyro_unscaled.q  = max1168_values[IMU_GYRO_Q_CHAN];
    imu.gyro_unscaled.r  = max1168_values[IMU_GYRO_R_CHAN];
    imu.accel_unscaled.x = max1168_values[IMU_ACCEL_X_CHAN];
    imu.accel_unscaled.y = max1168_values[IMU_ACCEL_Y_CHAN];
    imu.accel_unscaled.z = max1168_values[IMU_ACCEL_Z_CHAN];
    max1168_status = MAX1168_IDLE;
    imu_scale_gyro(&imu);
    imu_scale_accel(&imu);
    AbiSendMsgIMU_GYRO_INT32(IMU_BOARD_ID, now_ts, &imu.gyro);
    AbiSendMsgIMU_ACCEL_INT32(IMU_BOARD_ID, now_ts, &imu.accel);
  }

  // HMC58XX event task
  hmc58xx_event(&imu_hbmini.hmc);
  if (imu_hbmini.hmc.data_available) {
    imu.mag_unscaled.z = imu_hbmini.hmc.data.value[IMU_MAG_X_CHAN];
    imu.mag_unscaled.y = imu_hbmini.hmc.data.value[IMU_MAG_Y_CHAN];
    imu.mag_unscaled.x = imu_hbmini.hmc.data.value[IMU_MAG_Z_CHAN];

    imu_hbmini.hmc.data_available = FALSE;
    imu_scale_mag(&imu);
    AbiSendMsgIMU_MAG_INT32(IMU_BOARD_ID, now_ts, &imu.mag);
  }

}
Ejemplo n.º 2
0
void imu_hbmini_event(void)
{

  max1168_event();


  if (max1168_status == MAX1168_DATA_AVAILABLE) {
    imu.gyro_unscaled.p  = max1168_values[IMU_GYRO_P_CHAN];
    imu.gyro_unscaled.q  = max1168_values[IMU_GYRO_Q_CHAN];
    imu.gyro_unscaled.r  = max1168_values[IMU_GYRO_R_CHAN];
    imu.accel_unscaled.x = max1168_values[IMU_ACCEL_X_CHAN];
    imu.accel_unscaled.y = max1168_values[IMU_ACCEL_Y_CHAN];
    imu.accel_unscaled.z = max1168_values[IMU_ACCEL_Z_CHAN];
    max1168_status = MAX1168_IDLE;
    imu_hbmini.gyr_valid = TRUE;
    imu_hbmini.acc_valid = TRUE;
  }

  // HMC58XX event task
  hmc58xx_event(&imu_hbmini.hmc);
  if (imu_hbmini.hmc.data_available) {
    imu.mag_unscaled.z = imu_hbmini.hmc.data.value[IMU_MAG_X_CHAN];
    imu.mag_unscaled.y = imu_hbmini.hmc.data.value[IMU_MAG_Y_CHAN];
    imu.mag_unscaled.x = imu_hbmini.hmc.data.value[IMU_MAG_Z_CHAN];

    imu_hbmini.hmc.data_available = FALSE;
    imu_hbmini.mag_valid = TRUE;
  }

}
Ejemplo n.º 3
0
uint8_t
imu_event_task(void)
{
    uint8_t valid = 0;

    if ( max1168_event() )
    {
        valid = IMU_ACC | IMU_GYR;

        booz_imu.gyro_unscaled.p = max1168_values[IMU_GYRO_P_CHAN];
        booz_imu.gyro_unscaled.q = max1168_values[IMU_GYRO_Q_CHAN];
        booz_imu.gyro_unscaled.r = max1168_values[IMU_GYRO_R_CHAN];
        booz_imu.accel_unscaled.x = max1168_values[IMU_ACCEL_X_CHAN];
        booz_imu.accel_unscaled.y = max1168_values[IMU_ACCEL_Y_CHAN];
        booz_imu.accel_unscaled.z = max1168_values[IMU_ACCEL_Z_CHAN];

        imu_scale_gyro();
        imu_scale_accel();

        max1168_reset();
    }

    if (do_max1168_read && imu_spi_selected == SPI_NONE) 
    {
        Booz2ImuSetSpi16bits();
        imu_spi_selected = SPI_SLAVE_MAX1168;
        do_max1168_read = FALSE;

        max1168_read();
    }
    if (do_micromag_read && imu_spi_selected == SPI_NONE) 
    {
        Booz2ImuSetSpi8bits();
        imu_spi_selected = SPI_SLAVE_MM;
        do_micromag_read = FALSE;
    }
    if (imu_spi_selected == SPI_SLAVE_MM)
        micromag_read();


    if ( micromag_event() )
    {
        valid |= IMU_MAG;

        booz_imu.mag_unscaled.x = micromag_values[IMU_MAG_X_CHAN];
        booz_imu.mag_unscaled.y = micromag_values[IMU_MAG_Y_CHAN];
        booz_imu.mag_unscaled.z = micromag_values[IMU_MAG_Z_CHAN];

        imu_scale_mag();

        micromag_reset();
    }

    return valid;
}