[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200725041955.9985-18-warthog618@gmail.com>
Date: Sat, 25 Jul 2020 12:19:54 +0800
From: Kent Gibson <warthog618@...il.com>
To: linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org,
bgolaszewski@...libre.com, linus.walleij@...aro.org
Cc: Kent Gibson <warthog618@...il.com>
Subject: [PATCH v2 17/18] tools: gpio: add debounce support to gpio-event-mon
Add support for debouncing monitored lines to gpio-event-mon.
Signed-off-by: Kent Gibson <warthog618@...il.com>
---
tools/gpio/gpio-event-mon.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
index 5da980f78881..b64427d78942 100644
--- a/tools/gpio/gpio-event-mon.c
+++ b/tools/gpio/gpio-event-mon.c
@@ -129,11 +129,12 @@ void print_usage(void)
" -s Set line as open source\n"
" -r Listen for rising edges\n"
" -f Listen for falling edges\n"
+ " -b <n> Debounce the line with period n microseconds\n"
" [-c <n>] Do <n> loops (optional, infinite loop if not stated)\n"
" -? This helptext\n"
"\n"
"Example:\n"
- "gpio-event-mon -n gpiochip0 -o 4 -r -f\n"
+ "gpio-event-mon -n gpiochip0 -o 4 -r -f -b 10000\n"
);
}
@@ -147,11 +148,11 @@ int main(int argc, char **argv)
unsigned int line = -1;
unsigned int loops = 0;
struct gpioline_config config;
- int c;
+ int c, attr;
memset(&config, 0, sizeof(config));
config.flags = GPIOLINE_FLAG_V2_INPUT;
- while ((c = getopt(argc, argv, "c:n:o:dsrf?")) != -1) {
+ while ((c = getopt(argc, argv, "c:n:o:b:dsrf?")) != -1) {
switch (c) {
case 'c':
loops = strtoul(optarg, NULL, 10);
@@ -162,6 +163,14 @@ int main(int argc, char **argv)
case 'o':
line = strtoul(optarg, NULL, 10);
break;
+ case 'b':
+ attr = config.num_attrs;
+ config.num_attrs++;
+ gpiotools_set_bit(config.attrs[attr].mask, 0);
+ config.attrs[attr].attr.id = GPIOLINE_ATTR_ID_DEBOUNCE;
+ config.attrs[attr].attr.debounce_period =
+ strtoul(optarg, NULL, 10);
+ break;
case 'd':
config.flags |= GPIOLINE_FLAG_V2_OPEN_DRAIN;
break;
--
2.27.0
Powered by blists - more mailing lists