From d40015a41a21db308c355c1a5a65f0a5b2e5dda7 Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Mon, 10 Feb 2020 22:26:19 +0100 Subject: [PATCH] mtd_spi_nor: Add chip wait timings to debug output --- drivers/mtd_spi_nor/mtd_spi_nor.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mtd_spi_nor/mtd_spi_nor.c b/drivers/mtd_spi_nor/mtd_spi_nor.c index af1b39a472..7ea54f483b 100644 --- a/drivers/mtd_spi_nor/mtd_spi_nor.c +++ b/drivers/mtd_spi_nor/mtd_spi_nor.c @@ -272,6 +272,9 @@ static inline void wait_for_write_complete(const mtd_spi_nor_t *dev, uint32_t us { unsigned i = 0, j = 0; uint32_t div = 2; +#if ENABLE_DEBUG && defined(MODULE_XTIMER) + uint32_t diff = xtimer_now_usec(); +#endif do { uint8_t status; mtd_spi_cmd_read(dev, dev->opcode->rdsr, &status, sizeof(status)); @@ -304,7 +307,12 @@ static inline void wait_for_write_complete(const mtd_spi_nor_t *dev, uint32_t us thread_yield(); #endif } while (1); - DEBUG("wait loop %u times, yield %u times\n", i, j); + DEBUG("wait loop %u times, yield %u times", i, j); +#if ENABLE_DEBUG && defined(MODULE_XTIMER) + diff = xtimer_now_usec() - diff; + DEBUG(", total wait %"PRIu32"us", diff); +#endif + DEBUG("\n"); } static int mtd_spi_nor_init(mtd_dev_t *mtd)