/** * \brief Read the period of the frequency signal capture * * \return A value representing the power with which the plate element is * actuated. */ static uint16_t oven_plant_read_signal_period(void) { uint16_t val = 0; if (tc_is_cc_interrupt(&OVEN_FREQ_CAPT_TC, TC_CCA)) { val = tc_read_cc_buffer(&OVEN_FREQ_CAPT_TC, TC_CCA); tc_clear_cc_interrupt(&OVEN_FREQ_CAPT_TC, TC_CCA); } return val >> 1; }
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; }