mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
FIX: Even the US clock had the issues with not resetting properly. Now its always ZERO when you call StartCountUS.
This commit is contained in:
parent
ad5bc8cc8c
commit
5d15891e2b
2 changed files with 17 additions and 7 deletions
|
@ -340,9 +340,11 @@ void StartCountUS() {
|
|||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS; // timer disable
|
||||
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_XC1; // from timer 0
|
||||
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN;
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN;
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TCB->TCB_BCR = 1;
|
||||
|
||||
while (AT91C_BASE_TC1->TC_CV >= 1);
|
||||
}
|
||||
|
||||
uint32_t RAMFUNC GetCountUS(){
|
||||
|
@ -350,6 +352,13 @@ uint32_t RAMFUNC GetCountUS(){
|
|||
// By suggestion from PwPiwi, http://www.proxmark.org/forum/viewtopic.php?pid=17548#p17548
|
||||
//return (AT91C_BASE_TC1->TC_CV * 0x8000) + ((AT91C_BASE_TC0->TC_CV * 2) / 3);
|
||||
return (AT91C_BASE_TC1->TC_CV * 0x8000) + ((AT91C_BASE_TC0->TC_CV << 1) / 3);
|
||||
//return (AT91C_BASE_TC1->TC_CV << 16) | ((AT91C_BASE_TC0->TC_CV << 1) / 3);
|
||||
}
|
||||
void ResetUSClock(void) {
|
||||
//enable clock of timer and software trigger
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
while (AT91C_BASE_TC1->TC_CV >= 1);
|
||||
}
|
||||
|
||||
// static uint32_t GlobalUsCounter = 0;
|
||||
|
@ -424,9 +433,9 @@ void StartCountSspClk() {
|
|||
}
|
||||
void ResetSspClk(void) {
|
||||
//enable clock of timer and software trigger
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TC2->TC_CCR = AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
AT91C_BASE_TC2->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
}
|
||||
|
||||
uint32_t RAMFUNC GetCountSspClk(){
|
||||
|
|
|
@ -64,6 +64,7 @@ uint32_t RAMFUNC GetTickCount();
|
|||
|
||||
void StartCountUS();
|
||||
uint32_t RAMFUNC GetCountUS();
|
||||
void ResetUSClock(void);
|
||||
//uint32_t RAMFUNC GetDeltaCountUS();
|
||||
|
||||
void StartCountSspClk();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue