Skip to content

Commit 3ec83a3

Browse files
jonrebmbroonie
authored andcommitted
spi: spidev_test: add support for word delay
Support setting the word delay using the -w/--word-delay command line parameter. Note that spidev exposes word delay only as an u8, allowing for a maximum of 255us of delay to be inserted. Signed-off-by: Jonas Rebmann <jre@pengutronix.de> Link: https://patch.msgid.link/20241107-spidev-test-word-delay-v1-1-d4bba5569e39@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c36212b commit 3ec83a3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/spi/spidev_test.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static char *input_file;
4242
static char *output_file;
4343
static uint32_t speed = 500000;
4444
static uint16_t delay;
45+
static uint16_t word_delay;
4546
static int verbose;
4647
static int transfer_size;
4748
static int iterations;
@@ -124,6 +125,7 @@ static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
124125
.rx_buf = (unsigned long)rx,
125126
.len = len,
126127
.delay_usecs = delay,
128+
.word_delay_usecs = word_delay,
127129
.speed_hz = speed,
128130
.bits_per_word = bits,
129131
};
@@ -172,11 +174,12 @@ static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
172174

173175
static void print_usage(const char *prog)
174176
{
175-
printf("Usage: %s [-2348CDFHILMNORSZbdilopsv]\n", prog);
177+
printf("Usage: %s [-2348CDFHILMNORSZbdilopsvw]\n", prog);
176178
puts("general device settings:\n"
177179
" -D --device device to use (default /dev/spidev1.1)\n"
178180
" -s --speed max speed (Hz)\n"
179181
" -d --delay delay (usec)\n"
182+
" -w --word-delay word delay (usec)\n"
180183
" -l --loop loopback\n"
181184
"spi mode:\n"
182185
" -H --cpha clock phase\n"
@@ -213,6 +216,7 @@ static void parse_opts(int argc, char *argv[])
213216
{ "device", 1, 0, 'D' },
214217
{ "speed", 1, 0, 's' },
215218
{ "delay", 1, 0, 'd' },
219+
{ "word-delay", 1, 0, 'w' },
216220
{ "loop", 0, 0, 'l' },
217221
{ "cpha", 0, 0, 'H' },
218222
{ "cpol", 0, 0, 'O' },
@@ -237,7 +241,7 @@ static void parse_opts(int argc, char *argv[])
237241
};
238242
int c;
239243

240-
c = getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3ZFMNR248p:vS:I:",
244+
c = getopt_long(argc, argv, "D:s:d:w:b:i:o:lHOLC3ZFMNR248p:vS:I:",
241245
lopts, NULL);
242246

243247
if (c == -1)
@@ -253,6 +257,9 @@ static void parse_opts(int argc, char *argv[])
253257
case 'd':
254258
delay = atoi(optarg);
255259
break;
260+
case 'w':
261+
word_delay = atoi(optarg);
262+
break;
256263
case 'b':
257264
bits = atoi(optarg);
258265
break;

0 commit comments

Comments
 (0)