Lines Matching +full:rx +full:- +full:input

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Cross-compile with cross-gcc -I/path/to/cross-kernel/include
71 while (length-- > 0) { in hex_dump()
91 * Unescape - process hexadecimal escape character
92 * converts shell input "\x23" -> 0x23
106 pabort("malformed input string"); in unescape()
118 static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len) in transfer() argument
124 .rx_buf = (unsigned long)rx, in transfer()
162 ret = write(out_fd, rx, len); in transfer()
170 hex_dump(rx, len, 32, "RX"); in transfer()
175 printf("Usage: %s [-2348CDFHILMNORSZbdilopsv]\n", prog); in print_usage()
177 " -D --device device to use (default /dev/spidev1.1)\n" in print_usage()
178 " -s --speed max speed (Hz)\n" in print_usage()
179 " -d --delay delay (usec)\n" in print_usage()
180 " -l --loop loopback\n" in print_usage()
182 " -H --cpha clock phase\n" in print_usage()
183 " -O --cpol clock polarity\n" in print_usage()
184 " -F --rx-cpha-flip flip CPHA on Rx only xfer\n" in print_usage()
186 " -2 --dual dual transfer\n" in print_usage()
187 " -4 --quad quad transfer\n" in print_usage()
188 " -8 --octal octal transfer\n" in print_usage()
189 " -3 --3wire SI/SO signals shared\n" in print_usage()
190 " -Z --3wire-hiz high impedance turnaround\n" in print_usage()
192 " -i --input input data from a file (e.g. \"test.bin\")\n" in print_usage()
193 " -o --output output data to a file (e.g. \"results.bin\")\n" in print_usage()
194 " -p Send data (e.g. \"1234\\xde\\xad\")\n" in print_usage()
195 " -S --size transfer size\n" in print_usage()
196 " -I --iter iterations\n" in print_usage()
198 " -b --bpw bits per word\n" in print_usage()
199 " -L --lsb least significant bit first\n" in print_usage()
200 " -C --cs-high chip select active high\n" in print_usage()
201 " -N --no-cs no chip select\n" in print_usage()
202 " -R --ready slave pulls low to pause\n" in print_usage()
203 " -M --mosi-idle-low leave mosi line low when idle\n" in print_usage()
205 " -v --verbose Verbose (show tx buffer)\n"); in print_usage()
219 { "rx-cpha-flip", 0, 0, 'F' }, in parse_opts()
224 { "3wire-hiz", 0, 0, 'Z' }, in parse_opts()
225 { "input", 1, 0, 'i' }, in parse_opts()
231 { "cs-high", 0, 0, 'C' }, in parse_opts()
232 { "no-cs", 0, 0, 'N' }, in parse_opts()
234 { "mosi-idle-low", 0, 0, 'M' }, in parse_opts()
243 if (c == -1) in parse_opts()
337 uint8_t *rx; in transfer_escaped_string() local
343 rx = malloc(size); in transfer_escaped_string()
344 if (!rx) in transfer_escaped_string()
345 pabort("can't allocate rx buffer"); in transfer_escaped_string()
348 transfer(fd, tx, rx, size); in transfer_escaped_string()
349 free(rx); in transfer_escaped_string()
359 uint8_t *rx; in transfer_file() local
361 if (stat(filename, &sb) == -1) in transfer_file()
362 pabort("can't stat input file"); in transfer_file()
366 pabort("can't open input file"); in transfer_file()
372 rx = malloc(sb.st_size); in transfer_file()
373 if (!rx) in transfer_file()
374 pabort("can't allocate rx buffer"); in transfer_file()
378 pabort("failed to read input file"); in transfer_file()
380 transfer(fd, tx, rx, sb.st_size); in transfer_file()
381 free(rx); in transfer_file()
394 rx_rate = ((_read_count - prev_read_count) * 8) / (interval*1000.0); in show_transfer_rate()
395 tx_rate = ((_write_count - prev_write_count) * 8) / (interval*1000.0); in show_transfer_rate()
397 printf("rate: tx %.1fkbps, rx %.1fkbps\n", rx_rate, tx_rate); in show_transfer_rate()
406 uint8_t *rx; in transfer_buf() local
415 rx = malloc(len); in transfer_buf()
416 if (!rx) in transfer_buf()
417 pabort("can't allocate rx buffer"); in transfer_buf()
419 transfer(fd, tx, rx, len); in transfer_buf()
425 if (memcmp(tx, rx, len)) { in transfer_buf()
428 hex_dump(rx, len, 32, "RX"); in transfer_buf()
433 free(rx); in transfer_buf()
446 pabort("only one of -p and --input may be selected"); in main()
458 if (ret == -1) in main()
463 if (ret == -1) in main()
477 if (ret == -1) in main()
481 if (ret == -1) in main()
488 if (ret == -1) in main()
492 if (ret == -1) in main()
508 while (iterations-- > 0) { in main()
514 if (current.tv_sec - last_stat.tv_sec > interval) { in main()
519 printf("total: tx %.1fKB, rx %.1fKB\n", in main()