Example #1
0
static void mpu9150_int_event_handler(eventid_t id) {
	(void) id;

	mpu9150_a_read_x_y_z(mpu9150_driver.i2c_instance, &mpu9150_current_read.accel_xyz);

	mpu9150_g_read_x_y_z(mpu9150_driver.i2c_instance, &mpu9150_current_read.gyro_xyz);

	mpu9150_current_read.celsius =  mpu9150_a_g_read_temperature(mpu9150_driver.i2c_instance) ;

	// broadcast event to data_udp thread for enet transmit to FC
	chEvtBroadcast(&mpu9150_data_event);

	// clear the interrupt status bits on mpu9150
	mpu9150_a_g_read_int_status(mpu9150_driver.i2c_instance);

#ifdef	DEBUG_SENSOR_MPU
	BaseSequentialStream *chp =  (BaseSequentialStream *)&SDU_PSAS;
	static uint16_t     count = 0;

	++count;
	if (count > 2000) {
        		chprintf(chp, "\r\n*** MPU9150 ***\r\n");
				chprintf(chp, "raw_temp: %d C\r\n", mpu9150_temp_to_dC(mpu9150_current_read.celsius));
				chprintf(chp, "ACCL:  x: %d\ty: %d\tz: %d\r\n", mpu9150_current_read.accel_xyz.x, mpu9150_current_read.accel_xyz.y, mpu9150_current_read.accel_xyz.z);
				chprintf(chp, "GRYO:  x: 0x%x\ty: 0x%x\tz: 0x%x\r\n", mpu9150_current_read.gyro_xyz.x, mpu9150_current_read.gyro_xyz.y, mpu9150_current_read.gyro_xyz.z);
				count = 0;
	}
#endif

}
Example #2
0
static void mpu9150_int_event_handler(eventid_t id UNUSED) {

	mpu9150_a_read_x_y_z(mpu9150_driver.i2c_instance, &mpu9150_current_read.accel_xyz);

	mpu9150_g_read_x_y_z(mpu9150_driver.i2c_instance, &mpu9150_current_read.gyro_xyz);

	mpu9150_current_read.celsius =  mpu9150_a_g_read_temperature(mpu9150_driver.i2c_instance) ;

	/* broadcast event to data_udp thread for enet transmit to FC */
	chEvtBroadcast(&mpu9150_data_event);

	/* clear the interrupt status bits on mpu9150 */
	mpu9150_a_g_read_int_status(mpu9150_driver.i2c_instance);

#if	DEBUG_MPU9150

    static uint16_t     count = 0;

    BaseSequentialStream *chp = getUsbStream();

	++count;
	if (count > 5000) {
				chprintf(chp, "\r\nraw_temp: %d C\r\n", mpu9150_temp_to_dC(mpu9150_current_read.celsius));
				chprintf(chp, "ACCL:  x: %d\ty: %d\tz: %d\r\n", mpu9150_current_read.accel_xyz.x, mpu9150_current_read.accel_xyz.y, mpu9150_current_read.accel_xyz.z);
				chprintf(chp, "GRYO:  x: 0x%x\ty: 0x%x\tz: 0x%x\r\n", mpu9150_current_read.gyro_xyz.x, mpu9150_current_read.gyro_xyz.y, mpu9150_current_read.gyro_xyz.z);
				count = 0;
	}
#endif

}