From 63d59b0acf398293e2b76d3813ce6b9b64d4a5d2 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Mon, 26 Apr 2021 14:52:09 -0300 Subject: [PATCH] system/spi: Print sent data in the same way as received. This eases the comparison for testing SPI with looped back MOSI and MISO signals. --- system/spi/spi_exch.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/system/spi/spi_exch.c b/system/spi/spi_exch.c index 6bdee9e98..3616d6f7e 100644 --- a/system/spi/spi_exch.c +++ b/system/spi/spi_exch.c @@ -132,6 +132,21 @@ int spicmd_exch(FAR struct spitool_s *spitool, int argc, FAR char **argv) argndx += 1; } + spitool_printf(spitool, "Sending:\t"); + for (d = 0; d < spitool->count; d++) + { + if (spitool->width <= 8) + { + spitool_printf(spitool, "%02X ", txdata[d]); + } + else + { + spitool_printf(spitool, "%04X ", ((uint16_t *)txdata)[d]); + } + } + + spitool_printf(spitool, "\n"); + /* Get a handle to the SPI bus */ fd = spidev_open(spitool->bus); @@ -168,7 +183,7 @@ int spicmd_exch(FAR struct spitool_s *spitool, int argc, FAR char **argv) return ret; } - spitool_printf(spitool, "Received: "); + spitool_printf(spitool, "Received:\t"); for (d = 0; d < spitool->count; d++) { if (spitool->width <= 8)