From 4afee85638257d71600e8ad8c74f0a2d7b35ad0c Mon Sep 17 00:00:00 2001 From: Alexandru M Stan Date: Tue, 16 Sep 2014 12:31:40 -0700 Subject: stm32/spi: Print packet on bad data Just after a bad data error the EC will print the packet(pretty much the whole thing): in_msg=[02 00 0f 03 f4 09 00 00 ] I found it very helpful when debugging SPI TX/RX to know what the EC sees. BUG=chrome-os-partner:31390 TEST=Load spidev and send the EC bytes manually(malformed packets) BRANCH=None Change-Id: I037ab909076dc454379040e2e927dc6a0b5c5ea9 Signed-off-by: Alexandru M Stan Reviewed-on: https://chromium-review.googlesource.com/218442 Reviewed-by: Alec Berg Reviewed-by: Randall Spangler --- chip/stm32/spi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c index 2b62a977c0..ccae485e7b 100644 --- a/chip/stm32/spi.c +++ b/chip/stm32/spi.c @@ -22,6 +22,7 @@ /* Console output macros */ #define CPUTS(outstr) cputs(CC_SPI, outstr) #define CPRINTS(format, args...) cprints(CC_SPI, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_SPI, format, ## args) /* DMA channel option */ static const struct dma_option dma_tx_option = { @@ -429,6 +430,7 @@ void spi_event(enum gpio_signal signal) stm32_dma_chan_t *rxdma; uint16_t *nss_reg; uint32_t nss_mask; + uint16_t i; /* If not enabled, ignore glitches on NSS */ if (!enabled) @@ -570,6 +572,11 @@ void spi_event(enum gpio_signal signal) tx_status(EC_SPI_RX_BAD_DATA); state = SPI_STATE_RX_BAD; CPRINTS("SPI rx bad data"); + + CPRINTF("in_msg=["); + for (i = 0; i < dma_bytes_done(rxdma, sizeof(in_msg)); i++) + CPRINTF("%02x ", in_msg[i]); + CPRINTF("]\n"); } static void spi_chipset_startup(void) -- cgit v1.2.1