mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-01-09 19:57:54 -05:00
added a ticks delta function, handles overflow situations much better
This commit is contained in:
@@ -309,6 +309,14 @@ uint32_t GetTicks(void) {
|
||||
return (hi << 16) | lo;
|
||||
}
|
||||
|
||||
uint32_t RAMFUNC GetTicksDelta(uint32_t start) {
|
||||
uint32_t stop = GetTicks();
|
||||
if (stop >= start) {
|
||||
return stop - start;
|
||||
}
|
||||
return (UINT32_MAX - start) + stop;
|
||||
}
|
||||
|
||||
// Wait - Spindelay in ticks.
|
||||
// if called with a high number, this will trigger the WDT...
|
||||
void WaitTicks(uint32_t ticks) {
|
||||
@@ -328,3 +336,4 @@ void StopTicks(void) {
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
void StartTicks(void);
|
||||
uint32_t GetTicks(void);
|
||||
uint32_t RAMFUNC GetTicksDelta(uint32_t start);
|
||||
void WaitUS(uint32_t us);
|
||||
void WaitTicks(uint32_t ticks);
|
||||
void StartCountUS(void);
|
||||
|
||||
Reference in New Issue
Block a user