MPU9250.c
static void read_AK8963(uint8_t address, uint8_t *buffer, uint8_t bytes_count) {
	const uint16_t microsec = 500;
	uint8_t CTRL_reg = 0x80 + bytes_count;
	bytewrite_MPU(MPUREG_I2C_SLV0_ADDR, AK8963_I2C_ADDR|0x80);
	delay_micro(microsec);
	bytewrite_MPU(MPUREG_I2C_SLV0_REG, address);
	delay_micro(microsec);
	bytewrite_MPU(MPUREG_I2C_SLV0_CTRL, CTRL_reg);
	delay_micro(microsec);
	read_MPU(MPUREG_EXT_SENS_DATA_00, buffer, bytes_count);
	delay_micro(100);
}
// bytes_count should be less than 8.

bytes_count should be less than 8.
bytes_count should be less than 8 .
static void read_AK8963(uint8_t address, uint8_t *buffer, uint8_t bytes_count) {
	const uint16_t microsec = 500;
	uint8_t CTRL_reg = 0x80 + bytes_count;
	bytewrite_MPU(MPUREG_I2C_SLV0_ADDR, AK8963_I2C_ADDR|0x80);
	delay_micro(microsec);
	bytewrite_MPU(MPUREG_I2C_SLV0_REG, address);
	delay_micro(microsec);
	bytewrite_MPU(MPUREG_I2C_SLV0_CTRL, CTRL_reg);
	delay_micro(microsec);
	read_MPU(MPUREG_EXT_SENS_DATA_00, buffer, bytes_count);
	delay_micro(100);
}
static void read_AK8963 ( uint8_t address , uint8_t * buffer , uint8_t bytes_count ) { const uint16_t microsec = 500 ; uint8_t CTRL_reg = 0x80 + bytes_count ; bytewrite_MPU ( MPUREG_I2C_SLV0_ADDR , AK8963_I2C_ADDR | 0x80 ) ; delay_micro ( microsec ) ; bytewrite_MPU ( MPUREG_I2C_SLV0_REG , address ) ; delay_micro ( microsec ) ; bytewrite_MPU ( MPUREG_I2C_SLV0_CTRL , CTRL_reg ) ; delay_micro ( microsec ) ; read_MPU ( MPUREG_EXT_SENS_DATA_00 , buffer , bytes_count ) ; delay_micro ( 100 ) ; }
bytes_count should be less than 8.
bytes_count should be less than 8 .