/** * \brief Initializes SysTick. */ static void _hal_tcInit(void) { uint32_t l_ticks; TIMER_TypeDef* ps_timer = TIMER1; TIMER_Init_TypeDef s_timerInit = TIMER_INIT_DEFAULT; s_timerInit.enable = true; s_timerInit.prescale = timerPrescale2; s_timerInit.riseAction = timerInputActionReloadStart; /* caluclate ticks */ l_ticks = SystemHFClockGet() / 2 / 1000; /* configure timer for 1ms */ TIMER_TopSet( ps_timer, l_ticks ); /* enable timer interrupts */ NVIC_DisableIRQ( TIMER1_IRQn ); NVIC_ClearPendingIRQ( TIMER1_IRQn ); NVIC_EnableIRQ( TIMER1_IRQn ); TIMER_IntEnable( ps_timer, TIMER_IEN_OF ); /* initialize and start timer */ TIMER_Init( ps_timer, &s_timerInit ); } /* _hal_tcInit() */
/***************************************************************************//** * @brief * Get the current core clock frequency. * * @details * Calculate and get the current core clock frequency based on the current * configuration. Assuming that the SystemCoreClock global variable is * maintained, the core clock frequency is stored in that variable as well. * This function will however calculate the core clock based on actual HW * configuration. It will also update the SystemCoreClock global variable. * * @note * This is an EFM32 proprietary function, not part of the CMSIS definition. * * @return * The current core clock frequency in Hz. ******************************************************************************/ uint32_t SystemCoreClockGet(void) { uint32_t ret; ret = SystemHFClockGet(); ret >>= (CMU->HFCORECLKDIV & _CMU_HFCORECLKDIV_HFCORECLKDIV_MASK) >> _CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT; /* Keep CMSIS variable up-to-date just in case */ SystemCoreClock = ret; return ret; }