Skip to content

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

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

Conversation

jeremydick
Copy link

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.

@github-actions github-actions bot added the area: Input Input Subsystem and Drivers label May 5, 2025
@github-actions github-actions bot requested a review from fabiobaltieri May 5, 2025 20:53
@kartben kartben requested a review from Copilot May 6, 2025 00:46
Copy link

@Copilot Copilot AI left a 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>
@jeremydick jeremydick force-pushed the cap12xx_sensitivity branch from aae2d31 to 05c2674 Compare May 6, 2025 15:35
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), \
Copy link
Member

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), \
Copy link
Member

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));
Copy link
Member

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;
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Input Input Subsystem and Drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants