mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-23 12:14:10 +08:00
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>
This commit is contained in:
parent
c36212b261
commit
3ec83a377a
@ -42,6 +42,7 @@ static char *input_file;
|
|||||||
static char *output_file;
|
static char *output_file;
|
||||||
static uint32_t speed = 500000;
|
static uint32_t speed = 500000;
|
||||||
static uint16_t delay;
|
static uint16_t delay;
|
||||||
|
static uint16_t word_delay;
|
||||||
static int verbose;
|
static int verbose;
|
||||||
static int transfer_size;
|
static int transfer_size;
|
||||||
static int iterations;
|
static int iterations;
|
||||||
@ -124,6 +125,7 @@ static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
|
|||||||
.rx_buf = (unsigned long)rx,
|
.rx_buf = (unsigned long)rx,
|
||||||
.len = len,
|
.len = len,
|
||||||
.delay_usecs = delay,
|
.delay_usecs = delay,
|
||||||
|
.word_delay_usecs = word_delay,
|
||||||
.speed_hz = speed,
|
.speed_hz = speed,
|
||||||
.bits_per_word = bits,
|
.bits_per_word = bits,
|
||||||
};
|
};
|
||||||
@ -172,11 +174,12 @@ static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
|
|||||||
|
|
||||||
static void print_usage(const char *prog)
|
static void print_usage(const char *prog)
|
||||||
{
|
{
|
||||||
printf("Usage: %s [-2348CDFHILMNORSZbdilopsv]\n", prog);
|
printf("Usage: %s [-2348CDFHILMNORSZbdilopsvw]\n", prog);
|
||||||
puts("general device settings:\n"
|
puts("general device settings:\n"
|
||||||
" -D --device device to use (default /dev/spidev1.1)\n"
|
" -D --device device to use (default /dev/spidev1.1)\n"
|
||||||
" -s --speed max speed (Hz)\n"
|
" -s --speed max speed (Hz)\n"
|
||||||
" -d --delay delay (usec)\n"
|
" -d --delay delay (usec)\n"
|
||||||
|
" -w --word-delay word delay (usec)\n"
|
||||||
" -l --loop loopback\n"
|
" -l --loop loopback\n"
|
||||||
"spi mode:\n"
|
"spi mode:\n"
|
||||||
" -H --cpha clock phase\n"
|
" -H --cpha clock phase\n"
|
||||||
@ -213,6 +216,7 @@ static void parse_opts(int argc, char *argv[])
|
|||||||
{ "device", 1, 0, 'D' },
|
{ "device", 1, 0, 'D' },
|
||||||
{ "speed", 1, 0, 's' },
|
{ "speed", 1, 0, 's' },
|
||||||
{ "delay", 1, 0, 'd' },
|
{ "delay", 1, 0, 'd' },
|
||||||
|
{ "word-delay", 1, 0, 'w' },
|
||||||
{ "loop", 0, 0, 'l' },
|
{ "loop", 0, 0, 'l' },
|
||||||
{ "cpha", 0, 0, 'H' },
|
{ "cpha", 0, 0, 'H' },
|
||||||
{ "cpol", 0, 0, 'O' },
|
{ "cpol", 0, 0, 'O' },
|
||||||
@ -237,7 +241,7 @@ static void parse_opts(int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3ZFMNR248p:vS:I:",
|
c = getopt_long(argc, argv, "D:s:d:w:b:i:o:lHOLC3ZFMNR248p:vS:I:",
|
||||||
lopts, NULL);
|
lopts, NULL);
|
||||||
|
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
@ -253,6 +257,9 @@ static void parse_opts(int argc, char *argv[])
|
|||||||
case 'd':
|
case 'd':
|
||||||
delay = atoi(optarg);
|
delay = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
word_delay = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
bits = atoi(optarg);
|
bits = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user