/* this is called from a timer interrupt to read data from the MPU6000 and add it to _sum[] */ void MPU6000::read () { if (_new_data == 0) { // no new data is ready from the MPU6000 return; } _new_data = 0; // now read the data digitalWrite(_cs_pin, LOW); byte addr = MPUREG_ACCEL_XOUT_H | 0x80; SPI.transfer(addr); for (uint8_t i=0; i<7; i++) { _sum[i] += spi_transfer_16(); } _count++; if (_count == 0) { // rollover - v unlikely memset((void*)_sum, 0, sizeof(_sum)); } digitalWrite(_cs_pin, HIGH); // should also read FIFO data if enabled if( _dmp_initialised ) { if( FIFO_ready() ) { FIFO_getPacket(); } } }
/* this is called from a timer interrupt to read data from the MPU6000 and add it to _sum[] */ void AP_InertialSensor_MPU6000::read(uint32_t ) { if (_new_data == 0) { // no new data is ready from the MPU6000 return; } _new_data = 0; // now read the data digitalWrite(_cs_pin, LOW); byte addr = MPUREG_ACCEL_XOUT_H | 0x80; SPI.transfer(addr); for (uint8_t i=0; i<7; i++) { _sum[i] += spi_transfer_16(); } _count++; if (_count == 0) { // rollover - v unlikely memset((void*)_sum, 0, sizeof(_sum)); } digitalWrite(_cs_pin, HIGH); }