-
Notifications
You must be signed in to change notification settings - Fork 7.9k
drivers: sensor: microchip: mtch9010 Added MTCH9010 Device Support #91812
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
base: main
Are you sure you want to change the base?
drivers: sensor: microchip: mtch9010 Added MTCH9010 Device Support #91812
Conversation
If possible, could we add this for v4.2 |
#define MTCH9010_OPERATING_MODE_INIT(inst) \ | ||
COND_CODE_1(DT_INST_ENUM_HAS_VALUE(inst, mtch9010_operating_mode,\ | ||
capacitive), (MTCH9010_CONDUCTIVE), (MTCH9010_CAPACITIVE)) |
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.
unless i'm mistaken:
#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)) |
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.
I seem to remember a test error before I swapped it ... I'll look at it again
gpio_pin_set_dt(&config->enableUARTLine, GPIO_OUTPUT_LOW); | ||
} else { | ||
gpio_pin_set_dt(&config->enableUARTLine, GPIO_OUTPUT_HIGH); |
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.
copy-paste error from previous block
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.
Ah, I see. UART EN is active LOW. Clarified intention in comments
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.
no the issue is basically the same thing @msalau commented on. You want to be controlling enableCFGLine here, not enableUARTLine??
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.
Thanks - I think I see the issue now
{ | ||
/* Note: nRESET is handled in device reset function */ | ||
int rtn = 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.
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; |
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.
no camel case please -- apply everywhere in the PR
https://docs.zephyrproject.org/latest/contribute/style/code.html#:~:text=Use%20snake%20case%20for%20code%20and%20variables.
val->val1 = data->heartbeatErrorState; | ||
break; | ||
} | ||
default: { |
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.
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}}; \ |
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.
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); |
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.
undeclared function? did you mean mtch9010_lock_settings?
/* Keep LOW until ready to configure */ | ||
gpio_pin_configure_dt(&config->lockLine, GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH); |
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.
comment doesn't match the code
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.
Comment is incorrect - fixed
tests/drivers/sensor/mtch9010/test_configs/data_format/current.overlay
Outdated
Show resolved
Hide resolved
cf24bb0
to
e4ac4a3
Compare
@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); |
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.
Just highlighting that this will delay boot up process for all.
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.
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"); |
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.
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.
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.
Moved assertion to define section 👍
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.
Please do not resolve comments. This is for the reviewers to do
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.
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.
My bad - thanks for letting me know
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.
The BUILD_ASSERT keeps causing issues, and since this is an optional feature anyway, I've removed the BUILD_ASSERT.
511c14e
to
3b46797
Compare
Looks like everything is good to go on our side 👍 Local test bench is functioning as expected |
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! |
41e0e14
to
c0647db
Compare
Removed mtch9010 tags from .yaml testing files |
8f1ac42
to
34eb5a1
Compare
dd2232d
to
d0c5dbf
Compare
d0c5dbf
to
d79bafd
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.
Still missing the split into 2 commits.
1c6709c
to
f694931
Compare
f694931
to
44966a4
Compare
Sonar Qube issue needs attention 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. |
bb79968
to
1386716
Compare
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>
1386716
to
b73a750
Compare
|
SonarQube now passing |
All of the requested changes have been made - can you review and approve, so we can close this PR? |
Added new driver for MTCH9010 liquid leak detector along with test patterns.