Skip to content

Commit

Permalink
Move timer intialization to the init function.
Browse files Browse the repository at this point in the history
  • Loading branch information
advaitjain committed May 28, 2021
1 parent 0b515c3 commit 5f37769
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions tensorflow/lite/micro/cortex_m_corstone_300/system_setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,7 @@ constexpr int kClocksPerSecond = 25e6;

int32_t ticks_per_second() { return kClocksPerSecond; }

int32_t GetCurrentTimeTicks() {
static bool is_initialized = false;
if (!is_initialized) {
KIN1_UnlockAccessToDWT();
KIN1_InitCycleCounter();
KIN1_ResetCycleCounter();
KIN1_EnableCycleCounter();
is_initialized = true;
}
return KIN1_GetCycleCounter();
}
int32_t GetCurrentTimeTicks() { return KIN1_GetCycleCounter(); }

#ifdef ETHOS_U
void ethosuIrqHandler0() { ethosu_irq_handler(); }
Expand All @@ -86,6 +76,11 @@ void uart_init(void);
void InitializeTarget() {
uart_init();

KIN1_UnlockAccessToDWT();
KIN1_InitCycleCounter();
KIN1_ResetCycleCounter();
KIN1_EnableCycleCounter();

#ifdef ETHOS_U
constexpr int ethosu_base_address = 0x48102000;
constexpr int ethosu_irq = 56;
Expand All @@ -95,7 +90,7 @@ void InitializeTarget() {
MicroPrintf("Failed to initialize Ethos-U driver");
}
NVIC_SetVector(static_cast<IRQn_Type>(ethosu_irq),
(uint32_t)&ethosuIrqHandler0);
(uint32_t)&ethosuIrqHandler0);
NVIC_EnableIRQ(static_cast<IRQn_Type>(ethosu_irq));
#endif
}
Expand Down

0 comments on commit 5f37769

Please sign in to comment.