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

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Cross-compile with cross-gcc -I/path/to/cross-kernel/include
72 while (length-- > 0) {
92 * Unescape - process hexadecimal escape character
93 * converts shell input "\x23" -> 0x23
107 pabort("malformed input string");
119 static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
125 .rx_buf = (unsigned long)rx,
164 ret = write(out_fd, rx, len);
172 hex_dump(rx, len, 32, "RX");
177 printf("Usage: %s [-2348CDFHILMNORSZbdilopsvw]\n", prog);
179 " -D --device device to use (default /dev/spidev1.1)\n"
180 " -s --speed max speed (Hz)\n"
181 " -d --delay delay (usec)\n"
182 " -w --word-delay word delay (usec)\n"
183 " -l --loop loopback\n"
185 " -H --cpha clock phase\n"
186 " -O --cpol clock polarity\n"
187 " -F --rx-cpha-flip flip CPHA on Rx only xfer\n"
189 " -2 --dual dual transfer\n"
190 " -4 --quad quad transfer\n"
191 " -8 --octal octal transfer\n"
192 " -3 --3wire SI/SO signals shared\n"
193 " -Z --3wire-hiz high impedance turnaround\n"
195 " -i --input input data from a file (e.g. \"test.bin\")\n"
196 " -o --output output data to a file (e.g. \"results.bin\")\n"
197 " -p Send data (e.g. \"1234\\xde\\xad\")\n"
198 " -S --size transfer size\n"
199 " -I --iter iterations\n"
201 " -b --bpw bits per word\n"
202 " -L --lsb least significant bit first\n"
203 " -C --cs-high chip select active high\n"
204 " -N --no-cs no chip select\n"
205 " -R --ready slave pulls low to pause\n"
206 " -M --mosi-idle-low leave mosi line low when idle\n"
208 " -v --verbose Verbose (show tx buffer)\n");
219 { "word-delay", 1, 0, 'w' },
223 { "rx-cpha-flip", 0, 0, 'F' },
228 { "3wire-hiz", 0, 0, 'Z' },
229 { "input", 1, 0, 'i' },
235 { "cs-high", 0, 0, 'C' },
236 { "no-cs", 0, 0, 'N' },
238 { "mosi-idle-low", 0, 0, 'M' },
247 if (c == -1)
296 case 'M':
344 uint8_t *rx;
350 rx = malloc(size);
351 if (!rx)
352 pabort("can't allocate rx buffer");
355 transfer(fd, tx, rx, size);
356 free(rx);
366 uint8_t *rx;
368 if (stat(filename, &sb) == -1)
369 pabort("can't stat input file");
373 pabort("can't open input file");
379 rx = malloc(sb.st_size);
380 if (!rx)
381 pabort("can't allocate rx buffer");
385 pabort("failed to read input file");
387 transfer(fd, tx, rx, sb.st_size);
388 free(rx);
401 rx_rate = ((_read_count - prev_read_count) * 8) / (interval*1000.0);
402 tx_rate = ((_write_count - prev_write_count) * 8) / (interval*1000.0);
404 printf("rate: tx %.1fkbps, rx %.1fkbps\n", rx_rate, tx_rate);
413 uint8_t *rx;
422 rx = malloc(len);
423 if (!rx)
424 pabort("can't allocate rx buffer");
426 transfer(fd, tx, rx, len);
432 if (memcmp(tx, rx, len)) {
435 hex_dump(rx, len, 32, "RX");
440 free(rx);
453 pabort("only one of -p and --input may be selected");
465 if (ret == -1)
470 if (ret == -1)
484 if (ret == -1)
488 if (ret == -1)
495 if (ret == -1)
499 if (ret == -1)
515 while (iterations-- > 0) {
521 if (current.tv_sec - last_stat.tv_sec > interval) {
526 printf("total: tx %.1fKB, rx %.1fKB\n",