From a5482a5c2b0216aec14446e424a95997f994f4f2 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Tue, 1 Sep 2015 23:32:26 +0200 Subject: [PATCH] LP-108 - Fix Temp calculation, get rid of floatin point operations within ISR --- flight/pios/common/pios_mpu6000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flight/pios/common/pios_mpu6000.c b/flight/pios/common/pios_mpu6000.c index d30a8af64..92a4054b0 100644 --- a/flight/pios/common/pios_mpu6000.c +++ b/flight/pios/common/pios_mpu6000.c @@ -598,7 +598,8 @@ static bool PIOS_MPU6000_HandleData() queue_data->sample[0].z = -1 - (GET_SENSOR_DATA(mpu6000_data, Accel_Z)); queue_data->sample[1].z = -1 - (GET_SENSOR_DATA(mpu6000_data, Gyro_Z)); const int16_t temp = GET_SENSOR_DATA(mpu6000_data, Temperature); - queue_data->temperature = 3500 + ((float)(temp + 512)) * (1.0f / 3.4f); + // Temperature in degrees C = (TEMP_OUT Register Value as a signed quantity)/340 + 36.53 + queue_data->temperature = 3653 + (temp * 100) / 340; BaseType_t higherPriorityTaskWoken; xQueueSendToBackFromISR(dev->queue, (void *)queue_data, &higherPriorityTaskWoken);