Exemplo n.º 1
0
int main(int argc, char** argv){
	uart_init();
	stdout = stdin = &uart_str;
	MPU9150_init();
	calibrateMPU9150();
	while(1){
	}
}
Exemplo n.º 2
0
/* --------------------- Functions ----------------------- */
void imu_setup(void)
{
	uint8_t i;


	MPU9150_init();

	// gyroscope offset

	// Find accelerometer and gyroscope offset
	accelerometer = 0;
	gyro_offset = 0;
	for(i = 0; i < NSAMPLES; i++)
	{
	accelerometer += (float)MPU9150_readSensor_2byte(MPU9150_ACCEL_ZOUT_L, MPU9150_ACCEL_ZOUT_H);
	gyro_offset += (float)MPU9150_readSensor_2byte(MPU9150_GYRO_XOUT_L, MPU9150_GYRO_XOUT_H);
	}
	// average
	upright_value_accelerometer = accelerometer/NSAMPLES;
	safe_restart_acc = upright_value_accelerometer;
	gyro_offset /= NSAMPLES;
}