-
Notifications
You must be signed in to change notification settings - Fork 7.3k
drivers: input: cap12xx Add properties for sensitivity and guard signal #89503
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?
Conversation
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.
Pull Request Overview
This PR adds new properties and handling for configurable sensor sensitivity and signal guard functionality for the Microchip CAP12xx series.
- Extends device tree bindings to include sensor-gain, sensitivity-delta-sense, signal-guard, and calib-sensitivity properties.
- Updates driver code to configure analog gain, sensitivity, calibration sensitivities, and signal guard based on the new properties.
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
dts/bindings/input/microchip,cap12xx.yaml | Adds new properties to configure sensor gain, sensitivity, signal guard, and calibration sensitivity. |
drivers/input/input_cap12xx.c | Implements new functions and updates initialization to set the sensor's analog gain, sensitivity, calibration configuration, and signal guard. |
Files not reviewed (1)
- tests/drivers/build_all/input/app.overlay: Language not supported
The Microchip CAP12xx series has a configurable sensitivity and can drive an optional guard signal to reduce noise sensitivity. Signed-off-by: Jeremy Dick <jdick@pivotint.com>
aae2d31
to
05c2674
Compare
static const struct cap12xx_config cap12xx_config_##index = { \ | ||
.i2c = I2C_DT_SPEC_INST_GET(index), \ | ||
.input_channels = DT_INST_PROP_LEN(index, input_codes), \ | ||
.input_codes = cap12xx_input_codes_##index, \ | ||
IF_ENABLED(DT_INST_NODE_HAS_PROP(index, int_gpios), ( \ | ||
.int_gpio = &cap12xx_int_gpio_##index,)) \ | ||
.repeat = DT_INST_PROP(index, repeat), \ | ||
.poll_interval_ms = DT_INST_PROP_OR(index, poll_interval_ms, 10)}; \ | ||
.poll_interval_ms = DT_INST_PROP_OR(index, poll_interval_ms, 10), \ | ||
.analog_gain = DT_INST_PROP_OR(index, sensor_gain, 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.
it's usually a good idea to match the config field name with the corresponding property, either analog_gain
and analog-gain
or sensor_gain
and sensor-gain
, pick one (the one in the datasheet I guess)
.poll_interval_ms = DT_INST_PROP_OR(index, poll_interval_ms, 10)}; \ | ||
.poll_interval_ms = DT_INST_PROP_OR(index, poll_interval_ms, 10), \ | ||
.analog_gain = DT_INST_PROP_OR(index, sensor_gain, 0), \ | ||
.sensitivity_delta_sense = DT_INST_PROP_OR(index, sensitivity, 32), \ |
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.
same, also consider using a default in the binding file rather than here, then all the information, including the default values, would be contained in the binding file
/* Convert the enumerated sensitivity to the corresponding register value, | ||
* which is in reverse order | ||
*/ | ||
r = cap12xx_set_sensitivity(&config->i2c, 7 - ilog2(config->sensitivity_delta_sense)); |
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 define for 7
static int cap12xx_set_calsens(const struct i2c_dt_spec *i2c, const uint8_t *calsens, | ||
uint8_t channels) | ||
{ | ||
int r = 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.
int ret
(sorry I know the rest of the file uses r
but let's nudge this in the right direction, it's C not Go :-))
Also drop the initializer and close the function with return 0
, can even move this declaration inside the loop scope if you fancy it
The Microchip CAP12xx series has a configurable sensitivity and can drive an optional guard signal to reduce noise sensitivity.
This adds properties to enable the guard signals and adjust the sensitivities.