Example #1
0
void imu_impl_init(void) {

  imu_aspirin.status = AspirinStatusUninit;
  imu_aspirin.gyro_available_blaaa = FALSE;
  imu_aspirin.mag_available = FALSE;
  imu_aspirin.accel_available = FALSE;

  aspirin_adxl345.select = SPISelectUnselect;
  aspirin_adxl345.cpol = SPICpolIdleHigh;
  aspirin_adxl345.cpha = SPICphaEdge2;
  aspirin_adxl345.dss = SPIDss8bit;
  aspirin_adxl345.bitorder = SPIMSBFirst;
  aspirin_adxl345.cdiv = SPIDiv64;
  aspirin_adxl345.slave_idx = ADXL345_SLAVE_IDX;
  aspirin_adxl345.output_length = 7;
  aspirin_adxl345.input_length = 7;
  aspirin_adxl345.after_cb = adxl345_trans_cb;
  aspirin_adxl345.input_buf = &imu_aspirin.accel_rx_buf[0];
  aspirin_adxl345.output_buf = &imu_aspirin.accel_tx_buf[0];

  imu_aspirin.i2c_trans_gyro.type = I2CTransTxRx;
  imu_aspirin.i2c_trans_gyro.buf[0] = ITG3200_REG_GYRO_XOUT_H;
  imu_aspirin.i2c_trans_gyro.slave_addr = ITG3200_ADDR;
  imu_aspirin.i2c_trans_gyro.len_w = 1;
  imu_aspirin.i2c_trans_gyro.len_r = 6;
  imu_aspirin.i2c_trans_gyro.status = I2CTransFailed;

  imu_aspirin_arch_init();
  hmc5843_init();

}
Example #2
0
void imu_impl_init(void) {

  imu_aspirin.status = AspirinStatusUninit;
  imu_aspirin.gyro_available = FALSE;
  imu_aspirin.gyro_available_blaaa = FALSE;
  imu_aspirin.mag_ready_for_read = FALSE;
  imu_aspirin.mag_available = FALSE;
  imu_aspirin.accel_available = FALSE;

  imu_aspirin_arch_init();
  hmc5843_init();

}
Example #3
0
void imu_impl_init(void) {

  imu_aspirin.status = AspirinStatusUninit;
  imu_aspirin.gyro_available_blaaa = FALSE;
  imu_aspirin.mag_available = FALSE;
  imu_aspirin.accel_available = FALSE;

  imu_aspirin.i2c_trans_gyro.type = I2CTransTxRx;
  imu_aspirin.i2c_trans_gyro.buf[0] = ITG3200_REG_GYRO_XOUT_H;
  imu_aspirin.i2c_trans_gyro.slave_addr = ITG3200_ADDR;
  imu_aspirin.i2c_trans_gyro.len_w = 1;
  imu_aspirin.i2c_trans_gyro.len_r = 6;
  imu_aspirin.i2c_trans_gyro.status = I2CTransFailed;

  imu_aspirin_arch_init();
  hmc5843_init();

}
Example #4
0
void imu_impl_init(void)
{
  imu_aspirin.accel_valid = FALSE;
  imu_aspirin.gyro_valid = FALSE;
  imu_aspirin.mag_valid = FALSE;

  /* Set accel configuration */
  adxl345_spi_init(&imu_aspirin.acc_adxl, &(ASPIRIN_SPI_DEV), ASPIRIN_SPI_SLAVE_IDX);
  // set the data rate
  imu_aspirin.acc_adxl.config.rate = ASPIRIN_ACCEL_RATE;
  /// @todo drdy int handling for adxl345
  //imu_aspirin.acc_adxl.config.drdy_int_enable = TRUE;

  /* Gyro configuration and initalization */
  itg3200_init(&imu_aspirin.gyro_itg, &(ASPIRIN_I2C_DEV), ITG3200_ADDR);
  /* change the default config */
  // Aspirin sample rate divider defaults to 533Hz
  imu_aspirin.gyro_itg.config.smplrt_div = ASPIRIN_GYRO_SMPLRT_DIV;
  // aspirin defaults to 8kHz internal with 256Hz low pass
  imu_aspirin.gyro_itg.config.dlpf_cfg = ASPIRIN_GYRO_LOWPASS;

  /// @todo eoc interrupt for itg3200, polling for now (including status reg)
  /* interrupt on data ready, idle high, latch until read any register */
  //itg_conf.int_cfg = (0x01 | (0x1<<4) | (0x1<<5) | 0x01<<7);

  /* initialize mag and set default options */
  hmc58xx_init(&imu_aspirin.mag_hmc, &(ASPIRIN_I2C_DEV), HMC58XX_ADDR);
#ifdef IMU_ASPIRIN_VERSION_1_0
  imu_aspirin.mag_hmc.type = HMC_TYPE_5843;
#endif

#if ASPIRIN_ARCH_INDEP
TODO("Arch dependent functions (accel and gyro eoc interrupt) not used for aspirin!")
#else
  imu_aspirin_arch_init();
#endif
}