diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-04-25 20:33:30 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-04-25 20:33:30 +0300 |
commit | 59b942eae8cca6762a6033d7115ee2663a2dd395 (patch) | |
tree | 1ad823532d46c5000bc6bba422442b69edff288a /src/Libraries | |
parent | 05154ccc07c71d37699769e7f8f6e70c52702a6a (diff) |
Removed 5-point bed compensation, added longest SD read time
Removed support for 5-point bed compensation
Added a separate diagnostic report section for storage
Changed SD card longestWriteTime to be the actual block transfer time,
ignoring CRC calculations and delays between retries
Added SD card longestReadTime
Diffstat (limited to 'src/Libraries')
-rw-r--r-- | src/Libraries/Fatfs/diskio.cpp | 52 | ||||
-rw-r--r-- | src/Libraries/Fatfs/diskio.h | 5 |
2 files changed, 53 insertions, 4 deletions
diff --git a/src/Libraries/Fatfs/diskio.cpp b/src/Libraries/Fatfs/diskio.cpp index 84f5eb53..7fc77750 100644 --- a/src/Libraries/Fatfs/diskio.cpp +++ b/src/Libraries/Fatfs/diskio.cpp @@ -50,10 +50,13 @@ #include "RepRapFirmware.h" #include "RepRap.h" #include "Tasks.h" +#include <Movement/StepTimer.h> #include <cstring> static unsigned int highestSdRetriesDone = 0; +static uint32_t longestWriteTime = 0; +static uint32_t longestReadTime = 0; unsigned int DiskioGetAndClearMaxRetryCount() noexcept { @@ -62,6 +65,20 @@ unsigned int DiskioGetAndClearMaxRetryCount() noexcept return ret; } +float DiskioGetAndClearLongestReadTime() noexcept +{ + const float ret = (float)longestReadTime * StepTimer::StepClocksToMillis; + longestReadTime = 0; + return ret; +} + +float DiskioGetAndClearLongestWriteTime() noexcept +{ + const float ret = (float)longestWriteTime * StepTimer::StepClocksToMillis; + longestWriteTime = 0; + return ret; +} + //void debugPrintf(const char*, ...); //#if (SAM3S || SAM3U || SAM3N || SAM3XA_SERIES || SAM4S) @@ -192,8 +209,21 @@ DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count) noexcept /* Read the data */ unsigned int retryNumber = 0; uint32_t retryDelay = SdCardRetryDelay; - while (memory_2_ram(drv, sector, buff, count) != CTRL_GOOD) + for (;;) { + uint32_t time = StepTimer::GetTimerTicks(); + const Ctrl_status ret = memory_2_ram(drv, sector, buff, count); + time = StepTimer::GetTimerTicks() - time; + if (time > longestReadTime) + { + longestReadTime = time; + } + + if (ret == CTRL_GOOD) + { + break; + } + lock.Release(); ++retryNumber; if (retryNumber == MaxSdCardTries) @@ -250,7 +280,7 @@ DRESULT disk_write(BYTE drv, BYTE const *buff, DWORD sector, BYTE count) noexcep return RES_ERROR; } - /* Check valid address */ + // Check valid address uint32_t ul_last_sector_num; mem_read_capacity(drv, &ul_last_sector_num); if ((sector + count * uc_sector_size) > (ul_last_sector_num + 1) * uc_sector_size) @@ -258,11 +288,25 @@ DRESULT disk_write(BYTE drv, BYTE const *buff, DWORD sector, BYTE count) noexcep return RES_PARERR; } - /* Write the data */ + // Write the data + unsigned int retryNumber = 0; uint32_t retryDelay = SdCardRetryDelay; - while (ram_2_memory(drv, sector, buff, count) != CTRL_GOOD) + for (;;) { + uint32_t time = StepTimer::GetTimerTicks(); + const Ctrl_status ret = ram_2_memory(drv, sector, buff, count); + time = StepTimer::GetTimerTicks() - time; + if (time > longestWriteTime) + { + longestWriteTime = time; + } + + if (ret == CTRL_GOOD) + { + break; + } + lock.Release(); ++retryNumber; if (retryNumber == MaxSdCardTries) diff --git a/src/Libraries/Fatfs/diskio.h b/src/Libraries/Fatfs/diskio.h index 41e84572..fe092a94 100644 --- a/src/Libraries/Fatfs/diskio.h +++ b/src/Libraries/Fatfs/diskio.h @@ -5,8 +5,13 @@ #ifndef _DISKIO #ifdef __cplusplus + unsigned int DiskioGetAndClearMaxRetryCount() noexcept; +float DiskioGetAndClearLongestReadTime() noexcept; +float DiskioGetAndClearLongestWriteTime() noexcept; + extern "C" { + #endif #define _READONLY 0 /* 1: Remove write functions */ |