From 1b57bc39c0707a117246c192439f65c905331aac Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Thu, 15 Nov 2018 14:12:17 +0100 Subject: [PATCH] [ion] Discard micros() as those aren't used for now --- ion/include/ion/timing.h | 1 - ion/src/device/device.cpp | 21 --------------------- ion/src/shared/timing.cpp | 5 ----- 3 files changed, 27 deletions(-) diff --git a/ion/include/ion/timing.h b/ion/include/ion/timing.h index 028d4e588..871819ef6 100644 --- a/ion/include/ion/timing.h +++ b/ion/include/ion/timing.h @@ -10,7 +10,6 @@ void usleep(long us); #endif EXTERNC uint32_t millis(); -EXTERNC uint32_t micros(); EXTERNC void msleep(long ms); diff --git a/ion/src/device/device.cpp b/ion/src/device/device.cpp index a140a8abc..b28dbd8bd 100644 --- a/ion/src/device/device.cpp +++ b/ion/src/device/device.cpp @@ -45,27 +45,6 @@ uint32_t Ion::millis() { return millis_elapsed; } -uint32_t Ion::micros() { - // Here, we can use the current value of the systick counter to get a - // microsecond resolution counter. The problem is that the systick interrupt - // may occur between reading millis_elapsed and reading the current value - // of the systick counter. To cope with this, we do two consecutive reading - // of both values. Do not forget that the counter counts backwards down to zero. - uint32_t c1 = CM4.SYST_CVR()->getCURRENT(); - uint32_t ms1 = millis_elapsed; - uint32_t c2 = CM4.SYST_CVR()->getCURRENT(); - uint32_t ms2 = millis_elapsed; - uint32_t load = CM4.SYST_RVR()->getRELOAD(); - // If c1 > c2, then no systick interrupt occured between reading c1 and ms1, so ms1 - // value is correct, else an interrupt occured and ms2 value is correct. So we - // have the milliseconds part : "((c1 > c2) ? ms1 : ms2) * 1000" - // Then, we just add and scale the value of c2, as it is correct in both case. - // We do "(load - c2)" to convert from a backward count to a forward count, - // and then scale it to microseconds "* 1000) / (load + 1)" (as load is - // the number of ticks per milliseconds minus one) - return ((c1 > c2) ? ms1 : ms2) * 1000 + ((load - c2) * 1000) / (load + 1); -} - uint32_t Ion::crc32(const uint32_t * data, size_t length) { bool initialCRCEngineState = RCC.AHB1ENR()->getCRCEN(); RCC.AHB1ENR()->setCRCEN(true); diff --git a/ion/src/shared/timing.cpp b/ion/src/shared/timing.cpp index ac3180fd4..63a856086 100644 --- a/ion/src/shared/timing.cpp +++ b/ion/src/shared/timing.cpp @@ -7,8 +7,3 @@ uint32_t Ion::millis() { auto elapsed = std::chrono::high_resolution_clock::now() - start; return std::chrono::duration_cast(elapsed).count(); } - -uint32_t Ion::micros() { - auto elapsed = std::chrono::high_resolution_clock::now() - start; - return std::chrono::duration_cast(elapsed).count(); -}