Skip to content

Commit

Permalink
Update lm75bd.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Shayan925 committed Oct 11, 2023
1 parent 7d53570 commit 54e74e8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lm75bd/lm75bd.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ error_code_t readTempLM75BD(uint8_t devAddr, float *temp)
// and drops the 5 least siginificant bits
int16_t tempData = ((buffer[0] << 8) | buffer[1]) >> 5;

// Temp value is negative
if (tempData & (1 << 10)) {
// Two's complement
tempData = (~(tempData) + 1) & 0b011111111111;
*temp = -(tempData) * 0.125f;
} else {
*temp = (tempData) * 0.125f;
}
*temp = (float)(tempData) * 0.125f;

return ERR_CODE_SUCCESS;
}
Expand Down

0 comments on commit 54e74e8

Please sign in to comment.