Skip to content

Conversation

robertperkel
Copy link
Contributor

Added new driver for MTCH9010 liquid leak detector along with test patterns.

@robertperkel
Copy link
Contributor Author

If possible, could we add this for v4.2

Comment on lines 724 to 726
#define MTCH9010_OPERATING_MODE_INIT(inst) \
COND_CODE_1(DT_INST_ENUM_HAS_VALUE(inst, mtch9010_operating_mode,\
capacitive), (MTCH9010_CONDUCTIVE), (MTCH9010_CAPACITIVE))
Copy link
Contributor

Choose a reason for hiding this comment

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

unless i'm mistaken:

Suggested change
#define MTCH9010_OPERATING_MODE_INIT(inst) \
COND_CODE_1(DT_INST_ENUM_HAS_VALUE(inst, mtch9010_operating_mode,\
capacitive), (MTCH9010_CONDUCTIVE), (MTCH9010_CAPACITIVE))
#define MTCH9010_OPERATING_MODE_INIT(inst) \
COND_CODE_1(DT_INST_ENUM_HAS_VALUE(inst, mtch9010_operating_mode,\
capacitive), (MTCH9010_CAPACITIVE), (MTCH9010_CONDUCTIVE))

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 seem to remember a test error before I swapped it ... I'll look at it again

Comment on lines 338 to 340
gpio_pin_set_dt(&config->enableUARTLine, GPIO_OUTPUT_LOW);
} else {
gpio_pin_set_dt(&config->enableUARTLine, GPIO_OUTPUT_HIGH);
Copy link
Contributor

Choose a reason for hiding this comment

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

copy-paste error from previous block

Copy link
Contributor Author

@robertperkel robertperkel Jun 18, 2025

Choose a reason for hiding this comment

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

Ah, I see. UART EN is active LOW. Clarified intention in comments

Copy link
Contributor

Choose a reason for hiding this comment

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

no the issue is basically the same thing @msalau commented on. You want to be controlling enableCFGLine here, not enableUARTLine??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - I think I see the issue now

{
/* Note: nRESET is handled in device reset function */
int rtn = 0;

Copy link
Contributor

Choose a reason for hiding this comment

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

you're missing gpio_pin_configure_dt steps for the enableUARTLine and enableCFGLine output pins

{
int ret = 0;
const struct mtch9010_config_t *config = dev->config;
struct mtch9010_data_t *devData = dev->data;
Copy link
Contributor

Choose a reason for hiding this comment

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

val->val1 = data->heartbeatErrorState;
break;
}
default: {
Copy link
Contributor

Choose a reason for hiding this comment

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

you're missing SENSOR_CHAN_MTCH9010_MEAS_RESULT_AND_DELTA case?

.reference = MTCH9010_REF_VAL_INIT(inst), \
.threshold = DT_INST_PROP(inst, mtch9010_detect_value), \
.heartbeatErrorState = false, \
.lastResult = {0, 0}}; \
Copy link
Contributor

Choose a reason for hiding this comment

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

lastWake also needs to be initialized to zero to not have issues w/ first sample reading

mtch9010_command_send(uartDev, config, tBuffer);

#ifdef CONFIG_MTCH9010_LOCK_ON_STARTUP
mtch9010_lock_device(dev);
Copy link
Contributor

Choose a reason for hiding this comment

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

undeclared function? did you mean mtch9010_lock_settings?

Comment on lines 358 to 359
/* Keep LOW until ready to configure */
gpio_pin_configure_dt(&config->lockLine, GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH);
Copy link
Contributor

Choose a reason for hiding this comment

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

comment doesn't match the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment is incorrect - fixed

@robertperkel robertperkel force-pushed the add_mtch9010_rel_v1 branch 3 times, most recently from cf24bb0 to e4ac4a3 Compare June 19, 2025 04:08
@robertperkel robertperkel requested a review from kartben June 19, 2025 04:15
@robertperkel
Copy link
Contributor Author

@kartben I'm looking at the twister failures, and it doesn't seem related to my PR, as I don't utilize with the file system. Can you confirm or rerun/ignore that twister error?

@robertperkel robertperkel requested a review from msalau June 19, 2025 04:16
@kartben
Copy link
Contributor

kartben commented Jun 19, 2025

@kartben I'm looking at the twister failures, and it doesn't seem related to my PR, as I don't utilize with the file system. Can you confirm or rerun/ignore that twister error?

yep, had nothing to do with you, and fixed now :)

data->last_heartbeat = k_uptime_get();

/* Wait for boot-up */
k_msleep(CONFIG_MTCH9010_BOOT_TIME_MS);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just highlighting that this will delay boot up process for all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, things stop working when I remove this delay. I have some theories, but for now, I'd like to keep this.

LOG_INST_DBG(config->log, "UART setup not enabled");

#ifdef CONFIG_MTCH9010_LOCK_ON_STARTUP
BUILD_ASSERT(true, "MTCH9010_LOCK_ON_STARTUP cannot be set without UART enabled");
Copy link
Contributor

Choose a reason for hiding this comment

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

Location of this BUILD_ASSERT() is somewhat strange to me. It is not a part of the initialization routine. I think it should be closer to MTCH9010_DEFINE() and be checked at build time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved assertion to define section 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not resolve comments. This is for the reviewers to do

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad - thanks for letting me know

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The BUILD_ASSERT keeps causing issues, and since this is an optional feature anyway, I've removed the BUILD_ASSERT.

@robertperkel robertperkel force-pushed the add_mtch9010_rel_v1 branch 3 times, most recently from 511c14e to 3b46797 Compare June 19, 2025 19:17
@robertperkel robertperkel requested a review from msalau June 19, 2025 19:50
@robertperkel
Copy link
Contributor Author

Looks like everything is good to go on our side 👍 Local test bench is functioning as expected

@robertperkel
Copy link
Contributor Author

Hi @msalau @kartben ,
Since the feature freeze date for v4.2 is this Friday, could you let me know any remaining changes and/or approve the PR?

Additionally - do I need to notify anyone of this for v4.2, or is it automatic?

Thanks for your feedback!
Robert

@kartben kartben added this to the v4.2.0 milestone Jun 23, 2025
@kartben
Copy link
Contributor

kartben commented Jun 23, 2025

Hi @msalau @kartben , Since the feature freeze date for v4.2 is this Friday, could you let me know any remaining changes and/or approve the PR?

Additionally - do I need to notify anyone of this for v4.2, or is it automatic?

Thanks for your feedback! Robert

I am marking it as tentative for 4.2 but my guess is that it will be tight as it is quite a significant PR and it will take time for reviewers to go through it. Thanks!

@robertperkel robertperkel force-pushed the add_mtch9010_rel_v1 branch 3 times, most recently from 41e0e14 to c0647db Compare August 18, 2025 21:08
@robertperkel
Copy link
Contributor Author

Removed mtch9010 tags from .yaml testing files

@robertperkel robertperkel force-pushed the add_mtch9010_rel_v1 branch 2 times, most recently from dd2232d to d0c5dbf Compare August 19, 2025 21:58
Copy link
Contributor

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

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

Still missing the split into 2 commits.

@robertperkel robertperkel force-pushed the add_mtch9010_rel_v1 branch 4 times, most recently from 1c6709c to f694931 Compare August 20, 2025 01:50
@JarmouniA JarmouniA dismissed their stale review August 20, 2025 07:51

addressed

@JarmouniA
Copy link
Contributor

Sonar Qube issue needs attention
https://sonarcloud.io/project/issues?sinceLeakPeriod=true&issueStatuses=OPEN%2CCONFIRMED&pullRequest=91812&id=zephyrproject-rtos_zephyr&open=AZhIWhdx99fIPT0PFtnv

In general, you should not be validating the value of DT properties that have enum/range in binding, bcz it's done during DT parsing.

@robertperkel robertperkel force-pushed the add_mtch9010_rel_v1 branch 4 times, most recently from bb79968 to 1386716 Compare August 20, 2025 19:43
Added support for MTCH9010 and applied edits from reviewers.

Signed-off-by: Robert Perkel <robert.perkel@microchip.com>
Added testsuite to verify MTCH9010 sensor driver

Signed-off-by: Robert Perkel <robert.perkel@microchip.com>
Copy link

@robertperkel
Copy link
Contributor Author

SonarQube now passing

@robertperkel
Copy link
Contributor Author

@msalau @kartben @MaureenHelm

All of the requested changes have been made - can you review and approve, so we can close this PR?

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.

5 participants