From ed2df885a00b2d184f5656b241c6f6720a4d7db0 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Sat, 7 Dec 2024 19:59:58 +0000 Subject: [PATCH] AP_Logger: add performance debug to W25NXX logger --- libraries/AP_Logger/AP_Logger_W25NXX.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libraries/AP_Logger/AP_Logger_W25NXX.cpp b/libraries/AP_Logger/AP_Logger_W25NXX.cpp index df3e8bcea2d894..e2fd073d9b81b0 100644 --- a/libraries/AP_Logger/AP_Logger_W25NXX.cpp +++ b/libraries/AP_Logger/AP_Logger_W25NXX.cpp @@ -247,6 +247,11 @@ void AP_Logger_W25NXX::PageToBuffer(uint32_t pageNum) } } +//#define AP_W25NXX_DEBUG +#ifdef AP_W25NXX_DEBUG +static uint32_t block_writes; +static uint32_t last_write_msg_ms; +#endif void AP_Logger_W25NXX::BufferToPage(uint32_t pageNum) { if (pageNum == 0 || pageNum > df_NumPages+1) { @@ -283,6 +288,15 @@ void AP_Logger_W25NXX::BufferToPage(uint32_t pageNum) WITH_SEMAPHORE(dev_sem); send_command_addr(JEDEC_PROGRAM_EXECUTE, PageAdr); } + +#ifdef AP_W25NXX_DEBUG + block_writes++; + if (AP_HAL::millis() - last_write_msg_ms > 5000) { + hal.console->printf("W25NXX: writes %lukB/s, pages %lu/s\n", (block_writes*df_PageSize)/(5*1024), block_writes/5); + block_writes = 0; + last_write_msg_ms = AP_HAL::millis(); + } +#endif } /*