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: Add RRH46410 driver #80139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TotallyOriginalUsername
Copy link
Contributor

Adds Renesas RRH46410 gas sensor module driver.
The reset pin gets used to make sure the sensor starts from suspend mode.

@TotallyOriginalUsername TotallyOriginalUsername force-pushed the rrh46410-driver branch 2 times, most recently from 0bd9869 to b05372a Compare October 24, 2024 13:29
@TotallyOriginalUsername
Copy link
Contributor Author

Hello @MaureenHelm, could you please review this driver?

@kartben
Copy link
Collaborator

kartben commented Jan 18, 2025

@TotallyOriginalUsername could you address the compliance check failures? This will also need to be rebased on main

@TotallyOriginalUsername TotallyOriginalUsername force-pushed the rrh46410-driver branch 5 times, most recently from c8ac9a6 to dafa2f2 Compare January 23, 2025 15:36
@TotallyOriginalUsername
Copy link
Contributor Author

@TotallyOriginalUsername could you address the compliance check failures? This will also need to be rebased on main

The compliance check failures have been addressed, and it has been rebased on main

drivers/sensor/renesas/rrh46410/Kconfig Outdated Show resolved Hide resolved
Comment on lines +244 to +253
k_sleep(K_MSEC(100));

err = gpio_pin_set_dt(&cfg->reset_gpio, 0);
if (err != 0) {
LOG_ERR("Setting GPIO pin level failed: %d\n", err);
}

k_sleep(K_MSEC(600));
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure you want to add 700 ms of boot delay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added the boot delay there to make sure there is no unexpected behavior from the sensor at startup, which sometimes happens when using I2C.
Would it be better to leave it to the user to manually reset the sensor if needed, or to reduce the delay time to the minimum(500ms)/surround it with an if for I2C?

The other things have been adjusted, thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

@MaureenHelm @teburd there are a lot of sensors like this. I'm starting to think that we should have some pattern for a 2+ phase init for sensor drivers. We can kinda fake it right now. We have https://docs.zephyrproject.org/latest/kernel/drivers/index.html#deferred-initialization so we could call device_init() on a SYS_INIT which would kick off the process, then instead of sleeping we could use a timer or a deferred work item to call device_init() again and continue the init process until it finishes. The device would have to maintain an internal state (maybe a place to use the fsm subsystem)?

drivers/sensor/renesas/rrh46410/rrh46410.c Outdated Show resolved Hide resolved
drivers/sensor/renesas/rrh46410/rrh46410.c Outdated Show resolved Hide resolved
drivers/sensor/renesas/rrh46410/rrh46410_i2c.c Outdated Show resolved Hide resolved
Comment on lines 14 to 22
SENSOR_CHAN_IAQ = SENSOR_CHAN_PRIV_START,
/** 2 bytes Total Volatile Organic Compounds */
SENSOR_CHAN_TVOC,
/** 2 bytes Ethanol Equivalent */
SENSOR_CHAN_ETOH,
/** 2 bytes Estimated CO2 */
SENSOR_CHAN_ECO2,
/** 1 byte Relative IAQ */
SENSOR_CHAN_RELIAQ,
Copy link
Member

Choose a reason for hiding this comment

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

These custom enums need to have the sensor name in them. e.g., SENSOR_CHAN_RRH46410_IAQ

Adds Renesas RRH46410 gas sensor module driver.

Signed-off-by: Mariëlle Korthout <[email protected]>
Comment on lines +166 to +167
rc = rrh46410_read_sample(dev, &data->sample_counter, &data->iaq_sample,
&data->tvoc_sample, &data->etoh_sample, &data->eco2_sample, &data->reliaq_sample);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please run clang-format on all .c and .h files

#include <zephyr/drivers/sensor.h>
#include <zephyr/rtio/rtio.h>

#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's no need to #if here, just include the i2c.h it won't hurt anything and it makes the file more readable.

#define RRH46410_MAX_RESPONSE_DELAY 150 /* Add margin to the specified 50 in datasheet */

union rrh46410_bus_cfg {
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please include #define DT_DRV_COMPAT in this file otherwise you're depending on include order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants