int config_gy80(struct config *c) { // return value is a 4-bit number: AGCB, indicating // the return values of accel, gyro, compass, and barometer i2c.frequency(c->frequency); int ret = config_accelerometer(); ret |= config_gyro(); ret |= config_compass(); ret |= config_barometer(); return ret; }
/* initialize the accelerometer */ void initializeAccelerometer( ) { // initialize SPI spi_init(); // send a soft reset to the accelerometer uint8_t data[1] = {RESET_CODE}; spi_write_reg(SOFT_RESET, data, 1); //wait for device to be reset for (int i = 0; i < 100; i++); // the accel_init function only configs the 0x2D reg, no others // SO, configure the rest of the accelerometer settings before // doing the power control register (which turns measurment on) // (0x20 - 0x26 regs) config_accelerometer(); // configure interrupts to be off, default mode (for now) - (0x27 reg) adxl362_config_interrupt_mode( adxl362_INTERRUPT_DEFAULT, 0, 0 ); // configure FIFO mode to be off so we sample in real-time (0x28, 0x29 regs) adxl362_config_FIFO( adxl362_DISABLE_FIFO, 0, 0 ); // setup data ready interrupt to int pin 1 (maps data ready status to int1 pin) // (0x2A, 0x2B registers) adxl362_interrupt_map_t dataReadyIntMap; memset(&dataReadyIntMap, 0, sizeof dataReadyIntMap); dataReadyIntMap.DATA_READY = true; adxl362_config_INTMAP(&dataReadyIntMap, true); // set measurement range to 2G (0x2C reg) adxl362_config_measurement_range( adxl362_MEAS_RANGE_2G ); // initialize accel to measurement mode (with normal noise levels) //adxl362_accelerometer_init( adxl362_NOISE_NORMAL, 1, 0, 0 ); // DOING IT MANUALLY SO SOFTRESET NOT DONE AT END: data[0] = MEASUREMENT_MODE; data[0] = data[0] | (adxl362_NOISE_NORMAL << 4); spi_write_reg(POWER_CTL, data, 1); // RANDOM STUFF: //adxl362_activity_inactivity_interrupt_enable(); // read X axis to clear data ready interrupt // readAxisX(); }