Пример #1
0
uint16_t qdec_get_frequency(qdec_config_t *config)
{
	uint16_t capture = 0;

	/* While the CC flag is setted, read the CC value.
	 * This allows to read all CC buffers on XMEGA E and read the last value
	 */
	while (tc_is_cc_interrupt(config->freq_opt.timer, TC_CCA)) {
		capture = tc_read_cc(config->freq_opt.timer, TC_CCA);
	}
	if (capture == 0) {
		/* Out of range and certainly due to a rebounce not filtered */
		return config->freq_opt.last_freq;
	}

	config->freq_opt.last_freq = config->freq_opt.coef / capture;
	return config->freq_opt.last_freq;
}
Пример #2
0
uint16_t backlight_get_pwm()
{
	return tc_read_cc(&BACKLIGHT_TIMER, TC_CCB);
}