Skip to content

Commit

Permalink
Merge branch 'fix-lis3dh-temp-bit' into 'dev'
Browse files Browse the repository at this point in the history
fix: lis3dh: Use 8 bit temperature value in low power mode

Closes zephyrproject-rtos#31

See merge request blik/embedded/zephyr!46
  • Loading branch information
frasa committed Nov 14, 2018
2 parents 6c90ea6 + bfa0fd9 commit 23830a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/sensor/lis3dh/lis3dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ int lis3dh_sample_fetch_temp(struct device *dev)
s16_t raw = ((buf[1] << 8) | buf [0]);

/*
* The data is represented as 10bit left-aligned 2's
* complement, where the conversion rate is 1 digit/°C.
* The data is represented as left-aligned 2's
* complement.
* In low power mode the value is 8 bit,
* in normal mode 10 bit.
* The conversion rate is 1 digit/°C.
*/
drv_data->temp_sample = raw / LIS3DH_TEMP_MAG;

Expand Down
4 changes: 4 additions & 0 deletions drivers/sensor/lis3dh/lis3dh.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
#define LIS3DH_TEMP_EN_BIT BIT(6)
#define LIS3DH_ADC_EN_BIT BIT(7)

#if defined(CONFIG_LIS3DH_POWER_MODE_LOW)
#define LIS3DH_TEMP_MAG 256
#elif defined(CONFIG_LIS3DH_POWER_MODE_NORMAL)
#define LIS3DH_TEMP_MAG 64
#endif

#if defined(CONFIG_LIS3DH_POWER_MODE_LOW)
#define LIS3DH_LP_EN_BIT BIT(3)
Expand Down

0 comments on commit 23830a3

Please sign in to comment.