Skip to content

Commit

Permalink
use e2p/array access function in lm75 driver
Browse files Browse the repository at this point in the history
  • Loading branch information
breaker27 committed Mar 10, 2014
1 parent ef82580 commit d863310
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions firmware/shc_envsensor/lm75.c
Expand Up @@ -19,6 +19,7 @@
#include "lm75.h"

#include "i2c.h"
#include "../src_common/e2p_access.h"

#ifdef LM92_TYPE
#define MASK_TEMP_L 0xf0
Expand Down Expand Up @@ -74,29 +75,19 @@ int16_t lm75_get_tmp(void)
lm75_receive(LM75_TEMP_REG, 2, temp_raw);

#ifdef LM92_TYPE
// Mask sign bit and put the two uint8 together
temp = ((temp_raw[0] & 0b01111111) << 8) | temp_raw[1];
// Divide by 8
temp = temp >> 3;
// 13 bit signed value shifted to the left in two's complement
temp = array_read_IntValue32(0, 0, 13, -4096, 4095, temp_raw);
#endif
#ifdef DS7505_TYPE
// Mask sign bit and put the two uint8 together
temp = ((temp_raw[0] & 0b01111111) << 8) | (temp_raw[1] & MASK_TEMP_L);
// Divide by 8
temp = temp >> 4;
// 12 bit signed value shifted to the left in two's complement
temp = array_read_IntValue32(0, 0, 12, -2048, 2047, temp_raw);
#endif
// Calc temp in 1/10000 Celsius
temp = temp * 625;
// Calc temp in centi Celsius;
temp = temp / 100;

if ((temp_raw[0] & 0b10000000) > 0)
{
// Temperature is negative
temp = temp * -1;
}

return (temp);
return temp;
}

void lm75_shutdown(void)
Expand Down
2 changes: 1 addition & 1 deletion firmware/shc_envsensor/lm75.h
Expand Up @@ -59,7 +59,7 @@ void lm75_shutdown(void);
*/
static inline uint16_t lm75_get_meas_time_ms(void)
{
return(CONV_TIME);
return CONV_TIME;
}

/*
Expand Down

0 comments on commit d863310

Please sign in to comment.