mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
tests/perpih_spi: update to new API
This commit is contained in:
parent
732cbd969c
commit
198046e167
@ -214,23 +214,16 @@ int cmd_init(int argc, char **argv)
|
|||||||
puts("error: unable to initialize the given chip select line");
|
puts("error: unable to initialize the given chip select line");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
tmp = spi_acquire(spiconf.dev, spiconf.cs, spiconf.mode, spiconf.clk);
|
if (IS_ACTIVE(NDEBUG)) {
|
||||||
if (tmp == SPI_NOMODE) {
|
puts("cannot test configuration without assert()ions enabled");
|
||||||
puts("error: given SPI mode is not supported");
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (tmp == SPI_NOCLK) {
|
else {
|
||||||
puts("error: targeted clock speed is not supported");
|
printf("Trying to initialize SPI_DEV(%i): mode: %i, clk: %i, cs_port: %i, cs_pin: %i\n",
|
||||||
return 1;
|
dev, mode, clk, port, pin);
|
||||||
|
puts("Note: Failed assertion (crash) means configuration not supported");
|
||||||
|
spi_acquire(spiconf.dev, spiconf.cs, spiconf.mode, spiconf.clk);
|
||||||
|
spi_release(spiconf.dev);
|
||||||
}
|
}
|
||||||
else if (tmp != SPI_OK) {
|
|
||||||
puts("error: unable to acquire bus with given parameters");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
spi_release(spiconf.dev);
|
|
||||||
|
|
||||||
printf("SPI_DEV(%i) initialized: mode: %i, clk: %i, cs_port: %i, cs_pin: %i\n",
|
|
||||||
dev, mode, clk, port, pin);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -250,11 +243,7 @@ int cmd_transfer(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get bus access */
|
/* get bus access */
|
||||||
if (spi_acquire(spiconf.dev, spiconf.cs,
|
spi_acquire(spiconf.dev, spiconf.cs, spiconf.mode, spiconf.clk);
|
||||||
spiconf.mode, spiconf.clk) != SPI_OK) {
|
|
||||||
puts("error: unable to acquire the SPI bus");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* transfer data */
|
/* transfer data */
|
||||||
len = strlen(argv[1]);
|
len = strlen(argv[1]);
|
||||||
@ -293,11 +282,7 @@ int cmd_bench(int argc, char **argv)
|
|||||||
memset(bench_wbuf, BENCH_PAYLOAD, BENCH_LARGE);
|
memset(bench_wbuf, BENCH_PAYLOAD, BENCH_LARGE);
|
||||||
|
|
||||||
/* get access to the bus */
|
/* get access to the bus */
|
||||||
if (spi_acquire(spiconf.dev, spiconf.cs,
|
spi_acquire(spiconf.dev, spiconf.cs, spiconf.mode, spiconf.clk);
|
||||||
spiconf.mode, spiconf.clk) != SPI_OK) {
|
|
||||||
puts("error: unable to acquire the SPI bus");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
puts("### Running some benchmarks, all values in [us] ###");
|
puts("### Running some benchmarks, all values in [us] ###");
|
||||||
puts("### Test\t\t\t\tTransfer time\tuser time\n");
|
puts("### Test\t\t\t\tTransfer time\tuser time\n");
|
||||||
@ -517,10 +502,7 @@ int cmd_bench(int argc, char **argv)
|
|||||||
start = xtimer_now_usec();
|
start = xtimer_now_usec();
|
||||||
for (int i = 0; i < BENCH_REDOS; i++) {
|
for (int i = 0; i < BENCH_REDOS; i++) {
|
||||||
spi_release(spiconf.dev);
|
spi_release(spiconf.dev);
|
||||||
if (spi_acquire(spiconf.dev, spiconf.cs, spiconf.mode, spiconf.clk) != SPI_OK) {
|
spi_acquire(spiconf.dev, spiconf.cs, spiconf.mode, spiconf.clk);
|
||||||
puts("ERROR - spi_acquire() failed.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stop = xtimer_now_usec();
|
stop = xtimer_now_usec();
|
||||||
sched_stop = _sched_ticks();
|
sched_stop = _sched_ticks();
|
||||||
|
Loading…
Reference in New Issue
Block a user