-
Notifications
You must be signed in to change notification settings - Fork 8.1k
driver: sensor: Add Omron 2SMPB-02E digital barometric pressure sensor #96284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7cc7a3b
to
7398769
Compare
oki Oki Electric Industry Co., Ltd. | ||
olimex OLIMEX Ltd. | ||
olpc One Laptop Per Child | ||
omron OMRON Corporation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nashif please help review vendor prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good.
samples/sensor/2smpb_02e/src/main.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd rather have this sensor work with a generic sensor sample than having one sample per sensor, as it wouldn't scale.
I suggest looking at other tph-related samples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've removed the sample.
9d1eda4
to
63948a2
Compare
27df2a8
to
f20fa0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this sensor to tests/drivers/build_all/sensor
#define COEFFICIENT_A1_A -6.3E-03 | ||
#define COEFFICIENT_A1_S 4.3E-04 | ||
#define COEFFICIENT_A2_A -1.9E-11 | ||
#define COEFFICIENT_A2_S 1.2E-10 | ||
#define COEFFICIENT_BT1_A 1.0E-01 | ||
#define COEFFICIENT_BT1_S 9.1E-02 | ||
#define COEFFICIENT_BT2_A 1.2E-08 | ||
#define COEFFICIENT_BT2_S 1.2E-06 | ||
#define COEFFICIENT_BP1_A 3.3E-02 | ||
#define COEFFICIENT_BP1_S 1.9E-02 | ||
#define COEFFICIENT_B11_A 2.1E-07 | ||
#define COEFFICIENT_B11_S 1.4E-07 | ||
#define COEFFICIENT_BP2_A -6.3E-10 | ||
#define COEFFICIENT_BP2_S 3.5E-10 | ||
#define COEFFICIENT_B12_A 2.9E-13 | ||
#define COEFFICIENT_B12_S 7.6E-13 | ||
#define COEFFICIENT_B21_A 2.1E-15 | ||
#define COEFFICIENT_B21_S 1.2E-14 | ||
#define COEFFICIENT_BP3_A 1.3E-16 | ||
#define COEFFICIENT_BP3_S 7.9E-17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment to document where these coefficients come from
static int o2smpb_02e_attr_set(const struct device *dev, enum sensor_channel chan, | ||
enum sensor_attribute attr, const struct sensor_value *val) | ||
{ | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
val->val1 = (int32_t)temp; | ||
val->val2 = (int32_t)((temp - val->val1) * 1000000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use sensor_value_from_float
val->val1 = (int32_t)press; | ||
val->val2 = (int32_t)((press - val->val1) * 1000000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use sensor_value_from_float
}; | ||
|
||
#define O2SMPB_02E_INIT(n) \ | ||
static struct o2smpb_02e_config o2smpb_02e_config_##n = { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this const
.i2c = I2C_DT_SPEC_INST_GET(n), \ | ||
}; \ | ||
static struct o2smpb_02e_data o2smpb_02e_data_##n; \ | ||
DEVICE_DT_INST_DEFINE(n, o2smpb_02e_init, NULL, &o2smpb_02e_data_##n, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use SENSOR_DEVICE_DT_DEFINE
#define O2SMPB_02_REG_TEMP_TXD0 0xFC | ||
#define O2SMPB_02_REG_TEMP_TXD1 0xFB | ||
#define O2SMPB_02_REG_TEMP_TXD2 0xFA | ||
#define O2SMPB_02_REG_PRESS_TXD0 0xF9 | ||
#define O2SMPB_02_REG_PRESS_TXD1 0xF8 | ||
#define O2SMPB_02_REG_PRESS_TXD2 0xF7 | ||
#define O2SMPB_02_REG_RESET 0xE0 | ||
#define O2SMPB_02_REG_CTRL_MEAS 0xF4 | ||
#define O2SMPB_02_REG_CHIP_ID 0xD1 | ||
#define O2SMPB_02_REG_COE_b00_1 0xA0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really enough to justify having a separate private include. Move the defines to the .c file
compatible: "omron,2smpb-02e" | ||
|
||
include: [sensor-device.yaml] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include: [sensor-device.yaml] | |
include: [sensor-device.yaml, i2c-device.yaml] |
f20fa0f
to
6ffe42d
Compare
Support for the OMRON 2SMPB_02E digital barometric pressure sensor. Signed-off-by: Clément Laigle <[email protected]>
Co-authored-by: Luis Ubieda <[email protected]> Signed-off-by: Clément Laigle <[email protected]>
6ffe42d
to
929548e
Compare
|
This pull request adds support for the Omron 2SMPB-02E digital barometric pressure sensor, including the driver and a sample application.
Omron 2SMPB-02E sensor driver integration:
drivers/sensor/omron/2smpb_02e/
, including the main driver code (2smpb_02e.c
), header (2smpb_02e.h
), Kconfig, and CMakeLists.txt.Device tree and vendor bindings:
omron,2smpb-02e.yaml
) and registered theomron
vendor prefix (vendor-prefixes.txt
).Sample application and documentation: