First Commit as a new library
Dependents: Host_Software_MAX32664GWEB_HR_wrist Host_Software_MAX32664GWEC_SpO2_HR Host_Software_MAX32664GWEB_HR_EXTENDED Host_Software_MAX32664GWEC_SpO2_HR-_EXTE ... more
Revision 6:9615aa90087d, committed 2016-12-15
- Comitter:
- j3
- Date:
- Thu Dec 15 00:38:04 2016 +0000
- Parent:
- 5:35e032c8d8aa
- Child:
- 7:9848196cb65e
- Commit message:
- Fixed Temperature fx
Changed in this revision
| bmi160.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/bmi160.cpp Wed Dec 14 23:48:07 2016 +0000
+++ b/bmi160.cpp Thu Dec 15 00:38:04 2016 +0000
@@ -66,11 +66,20 @@
int32_t BMI160::getTemperature(float *temp)
{
uint8_t data[2];
+ uint16_t rawTemp;
int32_t rtnVal = readBlock(TEMPERATURE_0, TEMPERATURE_1, data);
if(rtnVal == RTN_NO_ERROR)
{
- *temp = (((data[1] << 8) | data[0])/512.0);
+ rawTemp = ((data[1] << 8) | data[0]);
+ if(rawTemp & 0x8000)
+ {
+ *temp = (23.0F - (((0xFFFF - rawTemp) + 1)/512.0F));
+ }
+ else
+ {
+ *temp = ((rawTemp/512.0F) + 23.0F);
+ }
}
return rtnVal;