/* Configure Timer Counter 0 to generate an interrupt with the specific frequency.  */
static void configure_tc(uint32_t freq)
/* Configure Timer Counter 0 to generate an interrupt with the specific frequency.  */
static void configure_tc(uint32_t freq)
{
	uint32_t ul_div;
	uint32_t ul_tcclks;
	uint32_t ul_sysclk = sysclk_get_cpu_hz();
	tc_stop(TC0, 0);
	tc_disable_interrupt(TC0, 0, TC_IER_CPCS);
	tc_find_mck_divisor(freq, ul_sysclk, &ul_div, &ul_tcclks, ul_sysclk);
	tc_init(TC0, 0, ul_tcclks | TC_CMR_CPCTRG);
	tc_write_rc(TC0, 0, (ul_sysclk / ul_div) / 4);
	NVIC_EnableIRQ((IRQn_Type)ID_TC0);
	tc_enable_interrupt(TC0, 0, TC_IER_CPCS);
	tc_start(TC0, 0);
}