• Home
  • Raw
  • Download

Lines Matching +full:data +full:- +full:lines

2  * gpio-hammer - example swiss army knife to shake GPIO lines on a system
11 * gpio-hammer -n <device-name> -o <offset1> -o <offset2>
26 #include "gpio-utils.h"
28 int hammer_device(const char *device_name, unsigned int *lines, int nlines, in hammer_device() argument
31 struct gpiohandle_data data; in hammer_device() local
32 char swirr[] = "-\\|/"; in hammer_device()
38 memset(&data.values, 0, sizeof(data.values)); in hammer_device()
39 ret = gpiotools_request_linehandle(device_name, lines, nlines, in hammer_device()
40 GPIOHANDLE_REQUEST_OUTPUT, &data, in hammer_device()
41 "gpio-hammer"); in hammer_device()
47 ret = gpiotools_get_values(fd, &data); in hammer_device()
51 fprintf(stdout, "Hammer lines ["); in hammer_device()
53 fprintf(stdout, "%d", lines[i]); in hammer_device()
54 if (i != (nlines - 1)) in hammer_device()
59 fprintf(stdout, "%d", data.values[i]); in hammer_device()
60 if (i != (nlines - 1)) in hammer_device()
68 /* Invert all lines so we blink */ in hammer_device()
70 data.values[i] = !data.values[i]; in hammer_device()
72 ret = gpiotools_set_values(fd, &data); in hammer_device()
76 /* Re-read values to get status */ in hammer_device()
77 ret = gpiotools_get_values(fd, &data); in hammer_device()
83 if (j == sizeof(swirr)-1) in hammer_device()
88 fprintf(stdout, "%d: %d", lines[i], data.values[i]); in hammer_device()
89 if (i != (nlines - 1)) in hammer_device()
110 fprintf(stderr, "Usage: gpio-hammer [options]...\n" in print_usage()
111 "Hammer GPIO lines, 0->1->0->1...\n" in print_usage()
112 " -n <name> Hammer GPIOs on a named device (must be stated)\n" in print_usage()
113 " -o <n> Offset[s] to hammer, at least one, several can be stated\n" in print_usage()
114 " [-c <n>] Do <n> loops (optional, infinite loop if not stated)\n" in print_usage()
115 " -? This helptext\n" in print_usage()
118 "gpio-hammer -n gpiochip0 -o 4\n" in print_usage()
125 unsigned int lines[GPIOHANDLES_MAX]; in main() local
132 while ((c = getopt(argc, argv, "c:n:o:?")) != -1) { in main()
144 * '-o' was given to give an accurate error message in main()
147 lines[i] = strtoul(optarg, NULL, 10); in main()
153 return -1; in main()
159 "Only %d occurences of '-o' are allowed, %d were found\n", in main()
161 return -1; in main()
168 return -1; in main()
170 return hammer_device(device_name, lines, nlines, loops); in main()