static void configure_accel(void) { /* set data rate to 800Hz and bandwidth to 400Hz (unless set otherwise) */ adxl345_write_to_reg(ADXL345_REG_BW_RATE, ASPIRIN_ACCEL_RATE); /* switch to measurememnt mode */ adxl345_write_to_reg(ADXL345_REG_POWER_CTL, 1<<3); /* enable data ready interrupt */ adxl345_write_to_reg(ADXL345_REG_INT_ENABLE, 1<<7); /* Enable full res with +-16g range and interrupt active low */ adxl345_write_to_reg(ADXL345_REG_DATA_FORMAT, ADXL345_FULL_RES|ADXL345_RANGE_16G|ADXL345_INT_INVERT); }
static void configure_accel(void) { /* set data rate to 800Hz */ adxl345_write_to_reg(ADXL345_REG_BW_RATE, 0x0D); /* switch to measurememnt mode */ adxl345_write_to_reg(ADXL345_REG_POWER_CTL, 1<<3); /* enable data ready interrupt */ adxl345_write_to_reg(ADXL345_REG_INT_ENABLE, 1<<7); /* Enable full res and interrupt active low */ adxl345_write_to_reg(ADXL345_REG_DATA_FORMAT, 1<<3|1<<5); /* clear spi rx reg to make DMA happy */ adxl345_clear_rx_buf(); /* reads data once to bring interrupt line up */ adxl345_start_reading_data(); }