Lines Matching +full:lines +full:- +full:initial +full:- +full:states
1 // SPDX-License-Identifier: GPL-2.0-only
3 * gpio-hammer - example swiss army knife to shake GPIO lines on a system
8 * gpio-hammer -n <device-name> -o <offset1> -o <offset2>
23 #include "gpio-utils.h"
25 int hammer_device(const char *device_name, unsigned int *lines, int num_lines, in hammer_device() argument
30 char swirr[] = "-\\|/"; in hammer_device()
39 ret = gpiotools_request_line(device_name, lines, num_lines, in hammer_device()
40 &config, "gpio-hammer"); in hammer_device()
55 fprintf(stdout, "Hammer lines ["); in hammer_device()
57 fprintf(stdout, "%d", lines[i]); in hammer_device()
58 if (i != (num_lines - 1)) in hammer_device()
61 fprintf(stdout, "] on %s, initial states: [", device_name); in hammer_device()
64 if (i != (num_lines - 1)) in hammer_device()
72 /* Invert all lines so we blink */ in hammer_device()
80 /* Re-read values to get status */ in hammer_device()
87 if (j == sizeof(swirr) - 1) in hammer_device()
92 fprintf(stdout, "%d: %d", lines[i], in hammer_device()
94 if (i != (num_lines - 1)) in hammer_device()
115 fprintf(stderr, "Usage: gpio-hammer [options]...\n" in print_usage()
116 "Hammer GPIO lines, 0->1->0->1...\n" in print_usage()
117 " -n <name> Hammer GPIOs on a named device (must be stated)\n" in print_usage()
118 " -o <n> Offset[s] to hammer, at least one, several can be stated\n" in print_usage()
119 " [-c <n>] Do <n> loops (optional, infinite loop if not stated)\n" in print_usage()
120 " -? This helptext\n" in print_usage()
123 "gpio-hammer -n gpiochip0 -o 4\n" in print_usage()
130 unsigned int lines[GPIOHANDLES_MAX]; in main() local
137 while ((c = getopt(argc, argv, "c:n:o:?")) != -1) { in main()
149 * '-o' was given to give an accurate error message in main()
152 lines[i] = strtoul(optarg, NULL, 10); in main()
158 return -1; in main()
164 "Only %d occurrences of '-o' are allowed, %d were found\n", in main()
166 return -1; in main()
173 return -1; in main()
175 return hammer_device(device_name, lines, num_lines, loops); in main()