Skip to content

Commit faf912d

Browse files
JordanYateskartben
authored andcommitted
sensor: tmp108: fix one-shot mode for as6212
When configuring the device to run in one-shot mode, the AS6212 requires the sleep mode bit to be set. From the datasheet: ``` The sleep mode is activated by setting the bit SM in the configuration register to 1. This shuts the device down immediately and reduces the power consumption to a minimum value. Entering the sleep mode will take some time (120 ms maximum) and the first conversion after the sleep mode has been entered takes longer than the values specified in Figure 7. It is therefore recommended when entering sleep mode to trigger a single shot conversion at the same time. After 150 ms (max), the device has then entered the sleep mode and subsequent conversion times are as specified in Figure 7. ``` Signed-off-by: Jordan Yates <[email protected]>
1 parent f5434c1 commit faf912d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/sensor/ti/tmp108/tmp108.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
.CONF_HYS0 = TI_TMP108_CONF_NA,\
2525
.CONF_CR0 = 0x0040, \
2626
.CONF_CR1 = 0x0080, \
27+
.CONF_SLEEP = 0x0100, \
2728
.CONF_M1 = 0x0000, \
2829
.CONF_TM = 0x0200, \
2930
.CONF_POL = 0x0400, \
@@ -47,9 +48,11 @@
4748
.WAKEUP_TIME_IN_MS = 30 }
4849

4950
#define TI_TMP108_MODE_SHUTDOWN(x) 0
50-
#define TI_TMP108_MODE_ONE_SHOT(x) TI_TMP108_CONF_M0(x)
51+
#define TI_TMP108_MODE_ONE_SHOT(x) (TI_TMP108_CONF_M0(x) | TI_TMP108_CONF_SLEEP(x))
5152
#define TI_TMP108_MODE_CONTINUOUS(x) TI_TMP108_CONF_M1(x)
52-
#define TI_TMP108_MODE_MASK(x) ~(TI_TMP108_CONF_M0(x) | TI_TMP108_CONF_M1(x))
53+
#define TI_TMP108_MODE_MASK(x) ~(TI_TMP108_CONF_M0(x) | \
54+
TI_TMP108_CONF_M1(x) | \
55+
TI_TMP108_CONF_SLEEP(x))
5356

5457
#define TI_TMP108_FREQ_4_SECS(x) 0
5558
#define TI_TMP108_FREQ_1_HZ(x) TI_TMP108_GET_CONF(x, CONF_CR0)
@@ -77,6 +80,7 @@
7780

7881
#define TI_TMP108_CONF_M1(x) TI_TMP108_GET_CONF(x, CONF_M1)
7982
#define TI_TMP108_CONF_M0(x) TI_TMP108_GET_CONF(x, CONF_M0)
83+
#define TI_TMP108_CONF_SLEEP(x) TI_TMP108_GET_CONF(x, CONF_SLEEP)
8084

8185
#define TMP108_TEMP_MULTIPLIER(x) TI_TMP108_GET_CONF(x, TEMP_MULT)
8286
#define TMP108_TEMP_DIVISOR(x) TI_TMP108_GET_CONF(x, TEMP_DIV)
@@ -88,6 +92,7 @@
8892
struct tmp_108_reg_def {
8993
uint16_t CONF_M0; /** Mode 1 configuration bit */
9094
uint16_t CONF_M1; /** Mode 2 configuration bit */
95+
uint16_t CONF_SLEEP; /** Sleep mode configuration bit */
9196
uint16_t CONF_CR0; /** Conversion rate 1 configuration bit */
9297
uint16_t CONF_CR1; /** Conversion rate 2 configuration bit */
9398
uint16_t CONF_POL; /** Alert pin Polarity configuration bit */

0 commit comments

Comments
 (0)