-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers: sensor: tmp112: Add default device initialization
This allow to have a smaller driver footprint when a single configuration is required. Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
- Loading branch information
1 parent
cd207ca
commit 4c986a2
Showing
4 changed files
with
134 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2020 Innoseis BV | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_DRIVERS_SENSOR_TMP112_TMP112_H_ | ||
#define ZEPHYR_DRIVERS_SENSOR_TMP112_TMP112_H_ | ||
|
||
#include <device.h> | ||
#include <sys/util.h> | ||
|
||
#define TMP112_REG_TEMPERATURE 0x00 | ||
#define TMP112_DATA_INVALID_BIT (BIT(1) | BIT(2)) | ||
#define TMP112_DATA_EXTENDED (BIT(0)) | ||
#define TMP112_DATA_EXTENDED_SHIFT 3 | ||
#define TMP112_DATA_NORMAL_SHIFT 4 | ||
|
||
|
||
#define TMP112_REG_CONFIG 0x01 | ||
#define TMP112_CONFIG_EM BIT(4) | ||
|
||
#define TMP112_ALERT_EN_BIT BIT(5) | ||
#define TMP112_CONV_RATE_SHIFT 6 | ||
#define TMP112_CONV_RATE_MASK (BIT_MASK(2) << TMP112_CONV_RATE_SHIFT) | ||
#define TMP112_CONV_RATE_025 0 | ||
#define TMP112_CONV_RATE_1000 1 | ||
#define TMP112_CONV_RATE_4 2 | ||
#define TMP112_CONV_RATE_8 3 | ||
|
||
#define TMP112_CONV_RATE(cr) ((cr) << TMP112_CONV_RATE_SHIFT) | ||
|
||
#define TMP112_CONV_RES_SHIFT 13 | ||
#define TMP112_CONV_RES_MASK (BIT_MASK(2) << TMP112_CONV_RES_SHIFT) | ||
|
||
#define TMP112_ONE_SHOT BIT(15) | ||
|
||
#define TMP112_REG_TLOW 0x02 | ||
#define TMP112_REG_THIGH 0x03 | ||
|
||
/* scale in micro degrees Celsius */ | ||
#define TMP112_TEMP_SCALE 62500 | ||
|
||
struct tmp112_data { | ||
int16_t sample; | ||
uint16_t config_reg; | ||
}; | ||
|
||
struct tmp112_config { | ||
const struct i2c_dt_spec bus; | ||
uint8_t cr; | ||
bool extended_mode : 1; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters