Skip to content
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

drivers: sensor: tmp1075: Add tmp1075 sensor driver and sample #75324

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Paplewski
Copy link

@Paplewski Paplewski commented Jul 2, 2024

TI tmp1075 driver implemented based on tmp108 driver. The driver initializes the sensor based on the DTS. See sample app.overlay.

Added sample to show example driver usage.
To see default DTS configuration option inspect ti,tmp1075.yaml bindings file.

@zephyrbot zephyrbot added area: Samples Samples area: Sensors Sensors platform: TI SimpleLink Texas Instruments SimpleLink MCU area: Devicetree Binding PR modifies or adds a Device Tree binding labels Jul 2, 2024
Copy link

github-actions bot commented Jul 2, 2024

Hello @Paplewski, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Please use the existing samples/sensor/thermometer instead of introducing a driver-specific sample.

const struct gpio_dt_spec *alert_gpio = &config->alert_gpio;
int result;

if (!device_is_ready(alert_gpio->port)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use gpio_is_ready_dt

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
#endif

int tmp1075_init(const struct device *dev)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int tmp1075_init(const struct device *dev)
static int tmp1075_init(const struct device *dev)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

const struct tmp1075_config *cfg = dev->config;
struct tmp1075_data *data = dev->data;

if (!device_is_ready(cfg->bus.bus)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use i2c_is_ready_dt

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


if (trig->type == SENSOR_TRIG_THRESHOLD) {
drv_data->temp_alert_handler = handler;
drv_data->temp_alert_trigger = *trig;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save the address of the trigger, not a copy of the trigger.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

conversion-rate:
description: Conversion rate in ms.
type: int
default: 220
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to explain in the description why the default value was selected
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#dt-bindings-default-rules

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed default value and updated overlay file

type: int
default: 220
enum:
- 275 # 27.5ms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make sense

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to microseconds

consecutive-fault-measurements:
description: Number of consecutive measured faults that will trigger the alert.
type: int
default: 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to explain in the description why the default value was selected
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#dt-bindings-default-rules

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed default value and updated overlay file

lower-threshold:
description: Lower threshold for alert interrupt. Expressed in degrees C.
type: int
default: 28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to explain in the description why the default value was selected
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#dt-bindings-default-rules

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed default value and updated overlay file

upper-threshold:
description: Upper threshold for alert interrupt. Expressed in degrees C.
type: int
default: 29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to explain in the description why the default value was selected
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#dt-bindings-default-rules

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed default value and updated overlay file

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added Stale and removed Stale labels Sep 18, 2024
TI tmp1075 driver implemented based on tmp108 driver.
The driver initializes the sensor based on the DTS.

Added tmp1075 example overlay file to thermometer sample.
All you need to do to use the sensor is to connect the I2C and
optionally interrupt line.
To see default DTS configuration option inspect `ti,tmp1075.yaml`
bindings file and sensor spec.

Signed-off-by: Paweł Czaplewski <[email protected]>
@@ -1113,3 +1113,14 @@ test_i2c_mmc56x3: mmc56x3@92 {
magn-odr = <0>;
auto-self-reset;
};

test_i2c_tmp1075: tmp1075@91 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address should be 0x98. The previous node is incorrect and should be 0x97, but that can be fixed in a separate patch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated both addresses in a separate commit

Fixed incorrect I2C register definitions in the test file
tests/drivers/build_all/sensor/i2c.dtsi.

Signed-off-by: Paweł Czaplewski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Samples Samples area: Sensors Sensors platform: TI SimpleLink Texas Instruments SimpleLink MCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants