mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-06 04:51:36 -07:00
added a ticks delta function, handles overflow situations much better
This commit is contained in:
parent
392c251c81
commit
6edd1b9de2
2 changed files with 10 additions and 0 deletions
|
@ -309,6 +309,14 @@ uint32_t GetTicks(void) {
|
||||||
return (hi << 16) | lo;
|
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.
|
// Wait - Spindelay in ticks.
|
||||||
// if called with a high number, this will trigger the WDT...
|
// if called with a high number, this will trigger the WDT...
|
||||||
void WaitTicks(uint32_t ticks) {
|
void WaitTicks(uint32_t ticks) {
|
||||||
|
@ -328,3 +336,4 @@ void StopTicks(void) {
|
||||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
|
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
|
||||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
|
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
void StartTicks(void);
|
void StartTicks(void);
|
||||||
uint32_t GetTicks(void);
|
uint32_t GetTicks(void);
|
||||||
|
uint32_t RAMFUNC GetTicksDelta(uint32_t start);
|
||||||
void WaitUS(uint32_t us);
|
void WaitUS(uint32_t us);
|
||||||
void WaitTicks(uint32_t ticks);
|
void WaitTicks(uint32_t ticks);
|
||||||
void StartCountUS(void);
|
void StartCountUS(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue