62
62
63
63
#define ICM42605_RA_GYRO_DATA_X1 0x25
64
64
#define ICM42605_RA_ACCEL_DATA_X1 0x1F
65
+ #define ICM42605_RA_TEMP_DATA1 0x1D
65
66
66
67
#define ICM42605_RA_INT_CONFIG 0x14
67
68
#define ICM42605_INT1_MODE_PULSED (0 << 2)
@@ -321,6 +322,20 @@ static bool icm42605GyroRead(gyroDev_t *gyro)
321
322
return true;
322
323
}
323
324
325
+ static bool icm42605ReadTemperature (gyroDev_t * gyro , int16_t * temp )
326
+ {
327
+ uint8_t data [2 ];
328
+
329
+ const bool ack = busReadBuf (gyro -> busDev , ICM42605_RA_TEMP_DATA1 , data , 2 );
330
+ if (!ack ) {
331
+ return false;
332
+ }
333
+ // From datasheet: Temperature in Degrees Centigrade = (TEMP_DATA / 132.48) + 25
334
+ * temp = ( int16_val_big_endian (data , 0 ) / 13.248 ) + 250 ; // Temperature stored as degC*10
335
+
336
+ return true;
337
+ }
338
+
324
339
bool icm42605GyroDetect (gyroDev_t * gyro )
325
340
{
326
341
gyro -> busDev = busDeviceInit (BUSTYPE_ANY , DEVHW_ICM42605 , gyro -> imuSensorToUse , OWNER_MPU );
@@ -340,7 +355,7 @@ bool icm42605GyroDetect(gyroDev_t *gyro)
340
355
gyro -> initFn = icm42605AccAndGyroInit ;
341
356
gyro -> readFn = icm42605GyroRead ;
342
357
gyro -> intStatusFn = gyroCheckDataReady ;
343
- gyro -> temperatureFn = NULL ;
358
+ gyro -> temperatureFn = icm42605ReadTemperature ;
344
359
gyro -> scale = 1.0f / 16.4f ; // 16.4 dps/lsb scalefactor
345
360
gyro -> gyroAlign = gyro -> busDev -> param ;
346
361
0 commit comments