[ion] Discard micros() as those aren't used for now

This commit is contained in:
Romain Goyet
2018-11-15 14:12:17 +01:00
parent 8d148ce504
commit 1b57bc39c0
3 changed files with 0 additions and 27 deletions

View File

@@ -10,7 +10,6 @@ void usleep(long us);
#endif
EXTERNC uint32_t millis();
EXTERNC uint32_t micros();
EXTERNC void msleep(long ms);

View File

@@ -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);

View File

@@ -7,8 +7,3 @@ uint32_t Ion::millis() {
auto elapsed = std::chrono::high_resolution_clock::now() - start;
return std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
}
uint32_t Ion::micros() {
auto elapsed = std::chrono::high_resolution_clock::now() - start;
return std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count();
}