/* Retrieves the current system clock frequency, computed from the reference clock. */
static uint32_t get_osc_frequency(void)
/* Retrieves the current system clock frequency, computed from the reference clock. */
static uint32_t get_osc_frequency(void)
{
	tc_clear_status(&tc_comp, TC_STATUS_CHANNEL_0_MATCH);
	tc_start_counter(&tc_calib);
	tc_start_counter(&tc_comp);
	while (!(tc_get_status(&tc_comp) & TC_STATUS_CHANNEL_0_MATCH)) {
	}
	uint64_t tmp = tc_get_capture_value(&tc_calib, TC_COMPARE_CAPTURE_CHANNEL_0);
	return ((tmp * REFERENCE_CLOCK_HZ) >> CALIBRATION_RESOLUTION);
}